Goose uses Server-Sent Events (SSE) for streaming agent responses in real-time. This allows clients to receive incremental updates as the agent processes requests and generates responses.
Reply Endpoint
Send a message to the agent and receive a streaming response.
Request Body
The response is a stream of Server-Sent Events. Each event is prefixed with data: followed by a JSON object:
Event Types
The stream can emit several different event types:
Message Event
Contains a message from the agent or tool execution.
Error Event
Indicates an error occurred during processing.
Finish Event
Signals the end of the response stream.
Finish reasons:
stop: Normal completion
length: Max tokens reached
error: Error occurred
cancel: Request cancelled
ModelChange Event
Notifies when the agent switches to a different model.
Notification Event
MCP server notifications (e.g., resource updates, tool changes).
UpdateConversation Event
Provides the full conversation state (sent periodically).
Ping Event
Keep-alive event to maintain connection.
JavaScript Client Example
Python Client Example
curl Example
The -N flag disables buffering to see events in real-time.
Message Content Types
Messages can contain different content types:
Text Content
Image Content
Tool Request Content
Tool Response Content
Token State
Every event includes token usage information:
- Current tokens: Tokens used in this turn
- Accumulated tokens: Total tokens used in the entire session
Error Handling
Always handle connection errors and unexpected disconnections:
Best Practices
- Keep connections alive: The server sends periodic
Ping events
- Handle all event types: Don’t assume only
Message events will arrive
- Track token usage: Monitor
token_state to manage costs
- Graceful degradation: Handle
Error events and connection failures
- Buffer management: Process events as they arrive, don’t wait for completion
- Reconnection logic: Implement automatic reconnection with exponential backoff
Conversation Override
The /reply endpoint supports overriding the conversation history. This is an advanced feature for administrative tools:
For normal operations, the server is the source of truth. Use the session fork/truncate endpoints instead of conversation override.