GenServer that manages an agent session.
The session maintains:
- Conversation history (messages)
- Current model configuration
- Available tools
- Streaming state
The Agent Loop
When a prompt is received:
- Add user message to history
- Call LLM with system prompt, messages, and tools
- If LLM returns tool calls:
- Execute each tool
- Add tool results to history
- Go to step 2
- If LLM returns text only, return response
Summary
Functions
Aborts the current operation.
Returns a specification to start this module under a supervisor.
Clears the conversation history.
Runs the configured compactor against the current message history.
Queues a follow-up message.
Returns the conversation history.
Returns the unique identifier for this session.
Runs a prompt synchronously, returning the final response.
Injects a steering message.
Streams a prompt, returning an enumerable of events.
Functions
Aborts the current operation.
Returns a specification to start this module under a supervisor.
See Supervisor.
Clears the conversation history.
Runs the configured compactor against the current message history.
No-op when no compactor is configured. The compacted snapshot is immediately persisted if a session store is configured.
Queues a follow-up message.
Returns the conversation history.
Returns the unique identifier for this session.
Sessions are identified by a UUIDv7 generated when the session starts, or by
the value passed via the :id option to start_link/2 / start/2. The id
is included in telemetry metadata so subscribers can group all events
emitted by a single agentic run.
Runs a prompt synchronously, returning the final response.
Injects a steering message.
Streams a prompt, returning an enumerable of events.