Session Lifecycle
Task in the queue, an agentic SSE stream in the chat API, and an audit log of all tool calls made during execution.
Starting a Session
The primary way to start an agentic session is through the chat API:Session Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
effort | string | medium | low | medium | high | max - controls step budget |
maxSteps | number | Varies | Hard cap on autonomous steps (1-200) |
maxBudget | number | None | Token budget for the session |
showThinking | boolean | true | Stream reasoning blocks |
securityMode | string | full | Tool permission mode for agentic runs |
securityMode: full - all tools are pre-approved. For interactive approval, use the with-tools endpoint instead.
Session Timeout
Sessions have a hard timeout of 3 minutes. When reached, anerror SSE event is sent with code: "TIMEOUT" and the stream closes. Long-running tasks should be broken into smaller steps.
Viewing Session History
Each agentic session saves tool calls and the final summary as a conversation message. Retrieve them via:assistantMessage in the response includes toolCalls with each tool call, its arguments, result, and status: "success" | "error".
Memory Session Integration
Agentic sessions optionally link to a memory session for context persistence:POST /api/memory/warm before starting an agentic session to pre-load relevant memory into context.
Execution Engine
Under the hood,streamAgenticChat() from src/chat/index.ts drives the agentic loop:
- Builds system prompt with
agentMode: true(appendsAGENT_MODE_SUFFIX) - Calls the AI model with all available tools
- Executes each tool call via the
ChatToolHandler - Repeats until the model stops calling tools or
maxStepsis reached - Emits typed SSE events at each step for real-time UI updates
securityMode: full in agentic mode, meaning all tools execute without approval prompts. This matches the behavior of autonomous agent runners like Claude Code.
Related
- Chat Streaming - SSE event format for session progress
- Chat API - Start agentic execution via conversations
- Memory API - Pre-load context for sessions
- Security Overview - Security modes and tool permission controls