Overview
Aurora uses WebSockets for real-time bidirectional communication between the frontend and the chatbot service. This enables streaming responses, live status updates, and interactive tool execution.Connection Details
Endpoint
Connection Lifecycle
- Client connects to WebSocket endpoint
- Server sends initial
STARTstatus - Client sends
initmessage with user context - Bidirectional messaging begins
- Server sends
ENDstatus when workflow completes
Message Format
All messages are JSON objects with a consistent structure:Client-to-Server Messages
Init Message
Initialize the WebSocket connection with user context. Type:init
- Establishes user identity
- Triggers MCP (Model Context Protocol) preloading
- Starts API cost cache warming
- Initializes deployment listeners
Chat Query
Send a chat message to the agent. Type:query
query: User’s message textuser_id: Authenticated user IDsession_id: Chat session ID (created by REST API)mode: “agent” (full execution) or “ask” (read-only)model: LLM model to useprovider_preference: List of preferred cloud providersselected_project_id: (Optional) Specific cloud projectattachments: (Optional) File attachmentsui_state: UI configuration to persist
Control Messages
Control workflow execution. Type:control
cancel: Stop the current workflow execution
- Cancels pending infrastructure confirmations
- Terminates running Celery tasks
- Consolidates message chunks
- Saves context for session resumption
- Sends END status to frontend
Confirmation Response
Respond to infrastructure change confirmations. Type:confirmation_response
- Approve or reject infrastructure changes
- Refreshes WebSocket connection if user reconnected
- Allows workflow to proceed or abort
Direct Tool Call
Execute a specific tool without AI routing.- Bypass AI decision-making for specific operations
- Direct execution of known actions (e.g., Git commits)
- Faster response for deterministic operations
Server-to-Client Messages
Status Messages
Indicate workflow state changes. Type:status
START: Workflow beginningEND: Workflow completedERROR: Workflow failed
Message Chunks
Streaming text responses from the LLM. Type:message
- Tokens arrive as soon as generated by LLM
- Multiple chunks per response
is_chunk: trueindicates partial content- Final chunk may have
is_complete: true
Tool Call Messages
Indicate tool execution start. Type:tool_call
Tool Output Messages
Streaming output from tool execution. Type:tool_output
- Tool output streams in real-time
- Large outputs split across multiple chunks
- Final chunk indicates completion
Tool Result Messages
Final result of tool execution. Type:tool_result
Confirmation Request
Request user approval for infrastructure changes. Type:confirmation_request
low: Safe operations (read-only, reversible)medium: Infrastructure changes (creation, updates)high: Destructive operations (deletion, data loss)
Usage Info
API cost tracking information. Type:usage_info
Error Messages
Error information. Type:error
Connection Management
Rate Limiting
WebSocket connections are rate-limited to prevent abuse: Rate: 5 messages per 60 seconds per client Exceeded Response:Connection Recovery
If the WebSocket connection drops:- Client reconnects to the same endpoint
- Client sends
initmessage - Client sends
confirmation_responseto refresh connection - Workflow continues in the background
- Messages resume streaming to the new connection
Background Execution
Workflows continue running even if the WebSocket disconnects:- Messages saved to database
- Tool execution continues
- Context preserved for reconnection
- Results available via REST API
Timeout Handling
Workflows have a 30-minute timeout: Timeout Message:Authentication
kubectl Agent WebSocket
Special authentication for kubectl agent connections. Header:- Authenticate kubectl agent running in user clusters
- Enable bi-directional command execution
- Secured with long-lived bearer tokens
Code Examples
JavaScript/TypeScript Client
Python Client
Best Practices
Connection Handling
- Always send
initmessage after connecting - Handle reconnections gracefully with exponential backoff
- Store session_id to resume conversations
- Monitor connection health with periodic pings
Message Processing
- Buffer streaming chunks for smooth UI updates
- Queue messages if UI can’t keep up
- Handle out-of-order messages using timestamps
- Validate message structure before processing
Error Recovery
- Retry failed connections with backoff
- Cache unsent messages for retry after reconnection
- Fetch missed messages via REST API after reconnection
- Display clear error messages to users
Performance
- Use WebSocket compression for large messages
- Batch multiple small messages when possible
- Implement client-side throttling for rapid updates
- Monitor memory usage with long-lived connections