Skip to main content

Error Codes

When errors occur, the server sends an error message with a structured code and human-readable message. This page documents all error codes.


Error Codes Reference

CodeDescriptionRetry?
Connection/Session
WEBRTC_UNAVAILABLEServer missing WebRTC supportNo
CONNECTION_FAILEDConnection establishment failedYes
SESSION_NOT_FOUNDReconnect with unknown session IDNo (start new session)
SESSION_EXPIREDSession timed out due to inactivityNo (start new session)
Provider Errors
STT_ERRORSpeech-to-text provider failedYes (with backoff)
STT_TIMEOUTSTT processing exceeded timeoutYes
LLM_ERRORLLM provider failedYes (with backoff)
LLM_TIMEOUTLLM response exceeded timeoutYes
TTS_ERRORText-to-speech provider failedYes (with backoff)
TTS_TIMEOUTTTS synthesis exceeded timeoutYes
Processing Errors
AUDIO_PROCESSING_ERRORAudio decoding or processing failedNo (check audio format)
VAD_ERRORVoice activity detection failedNo (check audio format)
INVALID_MESSAGEMalformed or unknown message typeNo (fix client)
INVALID_AUDIO_FORMATUnsupported audio formatNo (check format)
Playbook/Tool Errors
TOOL_ERRORTool execution failedMaybe (depends on tool)
PLAYBOOK_ERRORPlaybook orchestration failedNo
Generic Errors
INTERNAL_ERRORUnexpected server errorYes (with backoff)
RATE_LIMITEDToo many requestsYes (after delay)

Retry Guidance

Safe to retry:

  • CONNECTION_FAILED - Network may have recovered
  • *_TIMEOUT codes - Provider may be temporarily slow
  • RATE_LIMITED - After respecting retry-after delay
  • INTERNAL_ERROR - Transient server issues

Not safe to retry (without changes):

  • INVALID_MESSAGE - Fix the message format
  • INVALID_AUDIO_FORMAT - Fix the audio encoding
  • SESSION_NOT_FOUND / SESSION_EXPIRED - Start a new session
  • TOOL_ERROR - May need different parameters

Exponential backoff recommended: Start with 1 second, double each retry, max 5 retries.


Error Message Format

interface ErrorMessage {
type: 'error';
code: ErrorCode; // One of the codes above
message: string; // Human-readable description
}

Example:

{
"type": "error",
"code": "LLM_TIMEOUT",
"message": "LLM response exceeded 30 second timeout"
}

Client Handling

client.on('error', (error) => {
switch (error.code) {
case 'RATE_LIMITED':
// Wait and retry
setTimeout(() => client.start(), 60000);
break;

case 'SESSION_EXPIRED':
case 'SESSION_NOT_FOUND':
// Start fresh session
client.start();
break;

case 'LLM_TIMEOUT':
case 'STT_TIMEOUT':
case 'TTS_TIMEOUT':
// Retry with backoff
showMessage('Processing took too long, retrying...');
break;

default:
// Show user-friendly message
showMessage(`Error: ${error.message}`);
}
});