Skip to main content
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

Response Headers

Event Stream Format

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

  1. Keep connections alive: The server sends periodic Ping events
  2. Handle all event types: Don’t assume only Message events will arrive
  3. Track token usage: Monitor token_state to manage costs
  4. Graceful degradation: Handle Error events and connection failures
  5. Buffer management: Process events as they arrive, don’t wait for completion
  6. 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.