Skip to main content

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

  1. Client connects to WebSocket endpoint
  2. Server sends initial START status
  3. Client sends init message with user context
  4. Bidirectional messaging begins
  5. Server sends END status 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
Purpose:
  • 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
Fields:
  • query: User’s message text
  • user_id: Authenticated user ID
  • session_id: Chat session ID (created by REST API)
  • mode: “agent” (full execution) or “ask” (read-only)
  • model: LLM model to use
  • provider_preference: List of preferred cloud providers
  • selected_project_id: (Optional) Specific cloud project
  • attachments: (Optional) File attachments
  • ui_state: UI configuration to persist

Control Messages

Control workflow execution. Type: control
Actions:
  • cancel: Stop the current workflow execution
Cancellation Behavior:
  • 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
Purpose:
  • 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.
Purpose:
  • 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
Status Values:
  • START: Workflow beginning
  • END: Workflow completed
  • ERROR: Workflow failed

Message Chunks

Streaming text responses from the LLM. Type: message
Streaming Behavior:
  • Tokens arrive as soon as generated by LLM
  • Multiple chunks per response
  • is_chunk: true indicates 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
Streaming 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
Risk Levels:
  • 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:
  1. Client reconnects to the same endpoint
  2. Client sends init message
  3. Client sends confirmation_response to refresh connection
  4. Workflow continues in the background
  5. Messages resume streaming to the new connection
Connection Refresh:

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:
Purpose:
  • 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

  1. Always send init message after connecting
  2. Handle reconnections gracefully with exponential backoff
  3. Store session_id to resume conversations
  4. Monitor connection health with periodic pings

Message Processing

  1. Buffer streaming chunks for smooth UI updates
  2. Queue messages if UI can’t keep up
  3. Handle out-of-order messages using timestamps
  4. Validate message structure before processing

Error Recovery

  1. Retry failed connections with backoff
  2. Cache unsent messages for retry after reconnection
  3. Fetch missed messages via REST API after reconnection
  4. Display clear error messages to users

Performance

  1. Use WebSocket compression for large messages
  2. Batch multiple small messages when possible
  3. Implement client-side throttling for rapid updates
  4. Monitor memory usage with long-lived connections