Class AgentSession
java.lang.Object
neqsim.util.agentic.AgentSession
- All Implemented Interfaces:
Serializable
Tracks an AI agent workflow session from start to completion.
Records the sequence of phases an agent traverses while solving an engineering task (scope, research, analysis, validation, reporting). Each phase captures timing, tool invocations, validation outcomes, and the final result status. Sessions can be serialized to JSON for persistent logging and cross-session learning.
Workflow Phases:
- SCOPE — Task classification, standards identification, context gathering
- RESEARCH — Literature review, API discovery, pattern search
- ANALYSIS — Simulation building, flash calculations, equipment sizing
- VALIDATION — Result verification, benchmark comparison, mass/energy balance
- REPORTING — Report generation, figure creation, results.json assembly
Usage:
AgentSession session = AgentSession.start("solve.task", "TEG dehydration sizing");
session.beginPhase(AgentSession.Phase.SCOPE);
session.recordToolUse("thermo.fluid", "Create SRK fluid with water");
session.endPhase(AgentSession.Phase.SCOPE);
session.beginPhase(AgentSession.Phase.ANALYSIS);
session.recordSimulationRun("process.run()", true, 2.3);
session.endPhase(AgentSession.Phase.ANALYSIS);
session.complete(AgentSession.Outcome.SUCCESS);
String json = session.toJson();
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFinal outcome of the agent session.static enumWorkflow phase in the task-solving lifecycle.static classRecord of a single workflow phase with timing.static classRecord of a simulation run.static classRecord of a tool invocation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate longprivate Stringprivate AgentSession.Outcomeprivate final List<AgentSession.PhaseRecord> private static final longprivate final Stringprivate final List<AgentSession.SimulationRun> private final longprivate final Stringprivate final List<AgentSession.ToolInvocation> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAgentSession(String agentName, String taskDescription) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMetadata(String key, String value) Add metadata to the session.voidbeginPhase(AgentSession.Phase phase) Begin a workflow phase.voidcomplete(AgentSession.Outcome outcome) Mark the session as complete.voidendPhase(AgentSession.Phase phase) End a workflow phase.voidMark the session as failed with a reason.Get the agent name.doubleGet duration of the session in seconds.Get the failure reason.Get the session outcome.Get the phases traversed.Get the session ID.intGet the number of simulation runs.Get the simulation runs.intGet the number of successful simulation runs.Get the task description.intGet the number of tool invocations.Get the tool invocations.voidrecordSimulationRun(String description, boolean success, double durationSeconds) Record a simulation run and its outcome.voidrecordToolUse(String toolName, String description) Record a tool invocation during the session.static AgentSessionStart a new agent session.toJson()Serialize the session to JSON.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
sessionId
-
agentName
-
taskDescription
-
startTimeMillis
private final long startTimeMillis -
endTimeMillis
private long endTimeMillis -
outcome
-
phases
-
toolInvocations
-
simulationRuns
-
metadata
-
failureReason
-
-
Constructor Details
-
AgentSession
-
-
Method Details
-
start
Start a new agent session.- Parameters:
agentName- name of the agent (e.g., "solve.task", "process.model")taskDescription- brief description of the engineering task- Returns:
- new session instance
-
beginPhase
Begin a workflow phase.- Parameters:
phase- the phase to start
-
endPhase
End a workflow phase.- Parameters:
phase- the phase to end
-
recordToolUse
-
recordSimulationRun
Record a simulation run and its outcome.- Parameters:
description- what simulation was runsuccess- whether it succeededdurationSeconds- execution time in seconds
-
addMetadata
-
complete
Mark the session as complete.- Parameters:
outcome- the final outcome
-
fail
Mark the session as failed with a reason.- Parameters:
reason- failure reason
-
getSessionId
-
getAgentName
-
getTaskDescription
-
getOutcome
Get the session outcome.- Returns:
- outcome or null if not yet completed
-
getFailureReason
Get the failure reason.- Returns:
- failure reason or null if not failed
-
getDurationSeconds
public double getDurationSeconds()Get duration of the session in seconds.- Returns:
- duration in seconds, or time since start if not yet completed
-
getSimulationRunCount
public int getSimulationRunCount()Get the number of simulation runs.- Returns:
- total simulation run count
-
getSuccessfulSimulationCount
public int getSuccessfulSimulationCount()Get the number of successful simulation runs.- Returns:
- successful run count
-
getToolInvocationCount
public int getToolInvocationCount()Get the number of tool invocations.- Returns:
- tool invocation count
-
getPhases
Get the phases traversed.- Returns:
- unmodifiable list of phase records
-
getToolInvocations
Get the tool invocations.- Returns:
- unmodifiable list of tool invocations
-
getSimulationRuns
Get the simulation runs.- Returns:
- unmodifiable list of simulation runs
-
toJson
-