Architecture Overview
WebSocket Connection
The chat uses a persistent WebSocket connection for bidirectional real-time communication:- Client: Next.js frontend with
useWebSockethook - Server: Python WebSocket server (
main_chatbot.py) running on port 5006 - Protocol: JSON messages with types:
init,message,status,tool_call,usage_info,control
Message Flow
1
User sends message
Frontend sends JSON with
query, session_id, user_id, mode, model, and provider_preference2
Agent processes request
LangGraph workflow executes with streaming enabled via
astream_events API3
Tokens stream back
Server sends
token events for each chunk of AI response (real-time streaming)4
Tool calls execute
When AI needs to run a tool, server sends
tool_call event with status updates5
Final status
Server sends
END status when workflow completesChat Modes
Aurora supports two chat modes controlled by the mode selector:Ask Mode
Read-only mode for safe exploration:
- Cannot execute write operations
- No infrastructure changes
- Safe for production queries
- Tools blocked:
cloud_tool(write),kubectl_tool(apply/delete),github_commit,iac_tool(apply)
Agent Mode
Full execution mode for automation:
- Can deploy infrastructure
- Execute kubectl commands
- Commit to GitHub
- Modify cloud resources
- Requires confirmation for high-risk actions
Real-Time Streaming
Token-Level Streaming
The chat uses LangGraph’sastream_events API for token-level streaming:
Gemini thinking models return content as a list of blocks with types
thinking and text. Aurora extracts both for a complete thought stream.Message Consolidation
During streaming,AIMessageChunk objects are accumulated and consolidated into complete AIMessage objects:
Session Management
Creating a New Session
Chat sessions are created lazily on first message:Context Loading
When resuming a session, Aurora loads the full context:- LLM Context (
llm_context_history): Complete conversation for AI (includes tool messages) - UI Context (
chat_sessions.messages): Formatted messages for display (excludes tool details)
Context Compression
For long conversations, Aurora uses LangChain’s context compression:User Workflows
Starting a New Chat
- Navigate to
/chator click “New Chat” in sidebar - The UI shows the empty state with prompt suggestions
- Type a question or click a suggested prompt
- Session is created on first message send
Empty chat state with dynamic prompt suggestions based on connected providers
Chat Input Features
- Text Input
- File Attachments
- Mode & Model Selection
- Rich text editor with markdown support
- Multi-line input with Shift+Enter
- Enter to send
- Character limit: 2000 characters per message
Message Types in UI
Cancelling In-Progress Messages
Click the Stop button while a message is generating:- Cancels the running workflow task
- Waits for ongoing tool calls to complete
- Consolidates partial message chunks
- Saves the partial conversation state
- Adds a cancellation notice to the context
WebSocket Message Types
Client → Server
string
required
Message type:
init, message, control, confirmation_responsestring
User’s question (for
message type)string
Chat session ID (UUID)
string
required
User ID
string
Chat mode:
ask or agentstring
LLM model name:
claude-3-5-sonnet-20241022, gpt-4o, gemini-2.0-flash-thinking-exp-01-21, etc.array
Cloud providers to scope commands:
["gcp", "aws", "azure"]array
File attachments with
filename, file_type, file_data (base64), or server_path for server-side filesServer → Client
string
Message type:
status, message, token, tool_call, usage_infoobject
Message payload (varies by type)
Rate Limiting
WebSocket connections are rate-limited per client:- Limit: 5 messages per 60 seconds
- Scope: Per WebSocket connection ID
- Exceeded: Returns
{"type": "error", "data": {"text": "Rate limit exceeded"}}
API Cost Tracking
Aurora tracks LLM API usage per user:Related Features
Incident Investigation
Background RCA investigations use the same chat backend
Cloud Integrations
Execute commands across GCP, AWS, and Azure via chat