Skip to main content

Overview

Aurora’s AI agent is built on LangGraph, a framework for building stateful, multi-step workflows with large language models. The agent can execute cloud operations, search knowledge bases, run commands, and more through a tool-based architecture.

LangGraph Architecture

State Graph

The agent workflow is implemented as a directed graph with nodes representing operations and edges defining the flow.
Reference: server/chat/backend/agent/workflow.py:103-113

State Management

The workflow state stores conversation context and execution metadata:
Reference: server/chat/backend/agent/utils/state.py

Memory Persistence

LangGraph uses a memory saver to persist conversation context across requests:
Reference: server/chat/backend/agent/workflow.py:60-64

Agent Execution Flow

1. Initialize Connection

User connects via WebSocket with authentication:
Reference: server/main_chatbot.py:94-133

2. Receive Query

User sends a question with context:
Reference: server/main_chatbot.py:806-839

3. Set User Context

The agent sets thread-local context for tools:
Reference: server/chat/backend/agent/agent.py:200-208

4. Build System Prompt

Dynamic system prompt based on connected providers and mode:
Reference: server/chat/backend/agent/agent.py:244-250

5. Load Available Tools

Tools are filtered based on mode and connected providers:
Reference: server/chat/backend/agent/agent.py:168

6. Execute LangGraph Workflow

The workflow streams events as the agent thinks and acts:
Reference: server/main_chatbot.py:331-470

7. Tool Execution

When the LLM decides to use a tool:
The tool result is added to the conversation and the LLM continues reasoning.

8. Stream Response

Final answer is streamed token-by-token to the frontend:
Reference: server/main_chatbot.py:439-470

Agent Tools

Aurora provides 30+ tools across multiple categories:

Cloud Operations

Command Execution

Source Control

Monitoring & Observability

File Operations

Reference: server/chat/backend/agent/tools/

Tool Execution Pattern

Tool Definition

Tools are defined using LangChain’s @tool decorator:

Tool Context Access

Tools access user context via thread-local storage:
Reference: server/chat/backend/agent/tools/cloud_tools.py:58-98

Tool Output Streaming

Tools can send real-time updates via WebSocket:
Reference: server/main_chatbot.py:176-215

Error Handling

Tools return structured JSON with status:

Access Control

Agent vs Ask Mode

Aurora supports two operational modes: Agent Mode (Full Access):
  • Can execute infrastructure changes
  • Can commit code to GitHub
  • Can deploy Terraform resources
  • Can run destructive operations
Ask Mode (Read-Only):
  • Can read cloud resources
  • Can search knowledge bases
  • Cannot modify infrastructure
  • Cannot commit code
Reference: server/chat/backend/agent/access.py

Tool Filtering

Reference: server/main_chatbot.py:867-876

LLM Integration

Multi-Provider Support

Aurora supports multiple LLM providers:
Supported providers:
  • OpenRouter: Access 100+ models (default)
  • OpenAI: GPT-3.5, GPT-4, GPT-4o
  • Anthropic: Claude 3.5 Sonnet, Claude 3 Opus
  • Google: Gemini Pro, Gemini 2.0 (with thinking)
Reference: server/chat/backend/agent/llm.py

Prompt Caching

Aurora uses prefix caching to reduce latency and costs:
Reference: server/chat/backend/agent/utils/prefix_cache.py

MCP Integration

Aurora supports Model Context Protocol (MCP) for extending agent capabilities:

MCP Preloader

MCP servers are preloaded on startup for faster response times:
Reference: server/main_compute.py:102-106

Dynamic Tool Loading

MCP tools are dynamically loaded based on user connections:
Reference: server/chat/backend/agent/tools/mcp_tools.py

Streaming Architecture

Token Streaming

LLM responses stream token-by-token for perceived speed:
Reference: server/main_chatbot.py:341-360

Tool Call Streaming

Tool execution status is streamed in real-time:
Reference: server/main_chatbot.py:386-414

Cancellation & Cleanup

Workflow Cancellation

Users can cancel in-progress workflows:
The system:
  1. Cancels the asyncio task
  2. Waits for ongoing tool calls to complete
  3. Consolidates message chunks
  4. Saves context for resumption
  5. Sends END status to frontend
Reference: server/main_chatbot.py:709-800

Terraform Cleanup

Terraform state is cleaned up after deployment:
Reference: server/chat/backend/agent/agent.py:40-78