Streaming
Agent responses stream to the client in real-time using Server-Sent Events (SSE). You see tokens appear as the agent generates them, and tool calls are visible as they happen.
How it works
Section titled “How it works”When you send a message, the backend opens an SSE connection and starts streaming events. The frontend renders these events as they arrive, giving you a live view of the agent’s thought process.
Event types
Section titled “Event types”The stream sends different event types as the agent works:
| Event | Description |
|---|---|
token | A chunk of the agent’s text response |
tool_call | The agent is calling a tool (includes tool name and arguments) |
tool_result | The result of a tool execution |
tool_message | An intermediate message during tool processing |
tool_resolved | A pending tool interaction was resolved (e.g., user answered a question) |
entity_updated | A data entity was modified by a tool |
done | The agent finished its response |
stream_end | The SSE connection is closing |
Token streaming
Section titled “Token streaming”Text responses arrive as a series of token events. Each event contains a small chunk of text (typically a few tokens). The frontend concatenates these to build the complete response.
Tool call visibility
Section titled “Tool call visibility”When an agent decides to use a tool, you see:
- A
tool_callevent with the tool name and arguments - The tool executes server-side
- A
tool_resultevent with the output - The agent continues generating its response using the tool result
If the agent calls multiple tools in sequence, you see each call/result pair before the next one starts.
Interactive tool events
Section titled “Interactive tool events”Some tools create interactive moments:
- Human-in-the-loop (
notify_human). The agent pauses and gives you a debugger URL to take manual action (e.g., solving a CAPTCHA). Thetool_resolvedevent fires when you’re done. - Questions (
ask_user_question). The agent asks you a question with options. Your answer triggers atool_resolvedevent. - User takeover (
request_user_takeover). You get direct control of a browser session.
Connection handling
Section titled “Connection handling”The SSE connection stays open for the duration of the response. If the connection drops, the response continues server-side and is persisted to the database. You can reload the chat to see the complete response.
Tool loop limits
Section titled “Tool loop limits”The agent can make up to max_tool_turns tool calls per response (default: 200). This prevents runaway tool loops. If the limit is reached, the agent wraps up its response with whatever information it has gathered.