Errors & Warnings
Errors & Warnings
Server sends Error for fatal failures and Warning for non-fatal issues.
The server sends two diagnostic event types when something goes wrong:
Errorsignals a fatal issue. The session usually cannot continue and the connection often closes shortly after. Treat everyErroras a session-ending event and reconnect if your application needs to keep talking.Warningsignals a non-fatal issue. The session continues. Log the warning, fix the underlying cause if you control it, and otherwise carry on.
Both events follow the same payload shape: a type discriminator, a code you can branch on, and a human-readable description.
Error
The server sends an Error message when something prevents the session from continuing.
Error codes
Warning
The server sends a Warning message when something needs your attention but does not stop the session.
Warnings are non-fatal. The application continues to function normally.
Warning codes
Maximum session length
A Voice Agent session runs for a maximum of 2 hours. Two events mark the limit:
At 2 hours the server closes the session, so treat the warning as your cue to wrap up. To continue a conversation past the limit, open a new WebSocket connection and pass the prior turns in agent.context.messages — the agent resumes with full awareness of what was said. See Maintaining Context.
KeepAlive holds an idle connection open, but it does not extend the 2-hour limit.
Handling errors and warnings
Treat the two events asymmetrically:
- On
Error, log thecodeanddescription, surface the failure to your application, and reconnect if the use case allows. - On
Warning, log thecodeanddescriptionand continue. If the warning indicates a configuration problem (PROMPT_TOO_LONG,INJECT_AGENT_MESSAGE_DURING_*), fix the cause on the client side.
Always specify a fallback provider for think and speak to survive individual provider outages.