HTTP-level errors
These are returned by the API before any SSE event is emitted. The response body is typically a JSON object with adetail field (for validation errors) or a plain
error message. Your HTTP client should check the response status before consuming
the stream.
Use a small wrapper such as
response.raise_for_status() (in Python’s requests)
to convert HTTP errors into exceptions before entering the streaming loop. Trying
to consume the SSE stream from a non-2xx response will silently produce zero events.
Stream-level errors
Once the HTTP response is established with a 2xx status, errors are delivered as typed messages inside the stream. Three message types matter:LLM_RETRY
The agent’s upstream LLM call hit a transient failure (rate limit, timeout,
short-lived error) and is being retried automatically. The stream will resume
without further action.
TOOL_ERROR
A specific tool failed. The tool_name field identifies which one. The agent will
continue, possibly calling a different tool or synthesizing without that source.
Most integrations log these events and only surface a user-visible warning if the
final answer is materially degraded (for example, if every search call failed).
ERROR
The request cannot continue. The stream terminates immediately after this event;
no COMPLETE will follow. Surface the error to the user and stop reading the
stream.
error field is a human-readable string suitable for logging, but not always
suitable for direct display to end users. Wrap it in your own UX-friendly message
where appropriate.
Worked example: error-aware streaming handler
The handler below distinguishes HTTP-level failures, stream-level errors, and informational retries. It logs per-event details and only raises when the request can no longer succeed.- Pre-stream HTTP errors — raised immediately so callers do not waste cycles reading an empty stream.
- In-stream recoverable events — logged at appropriate levels but never raised.
- In-stream fatal events — raised so callers can surface the failure.
- Truncated streams — detected by the absence of a
COMPLETEevent, preventing silent “empty answer” bugs.
Retry and backoff
For429 and 5xx HTTP responses, exponential backoff with jitter is the safe
default:
400, 401, 403, or 404: those reflect client-side or
identity problems that will not resolve on retry.
In-stream events do not benefit from retry at the request level. LLM_RETRY and
TOOL_ERROR already represent the agent’s own internal retry behavior; the
request is doing the right thing without your help.
When to abort versus continue
Next steps
Streaming responses
Full reference for every message type the stream may emit.
Conversation continuity
Recover from a 404 on
from_checkpoint_id by resetting the thread.