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.
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.
Runs a prompt synchronously, returning the final response.
Injects a steering message.
Streams a prompt, returning an enumerable of events.