Skip to main content

Overview

Agents are the core execution units of the platform. Each agent represents a configurable AI assistant with its own personality, capabilities, and tool access. Agents are versioned, allowing you to iterate on configurations while maintaining historical versions.

Agent Architecture

Agent Data Model

Agents are represented by the AgentData class, which serves as the single source of truth for agent representation:
Reference: backend/core/agents/agent_loader.py:14-57

Agent Loading System

The AgentLoader provides unified agent loading with consistent behavior:
  • Single agent loads: Full configuration including system prompt, model, and tools
  • List operations: Metadata only for performance (no version loading)
  • Batch loading: Efficient version fetching for multiple agents
Reference: backend/core/agents/agent_loader.py:160-233

Agent Execution

Pipeline Architecture

Agent execution uses a stateless pipeline architecture that processes messages through multiple stages:
Reference: backend/core/agents/runner/executor.py:93-159

Execution Flow

  1. Initialization: Load agent configuration and setup execution context
  2. Message Processing: Process user message through LLM with available tools
  3. Tool Execution: Execute any tool calls requested by the LLM
  4. Response Streaming: Stream responses back to client via Redis
  5. Completion: Mark run as complete and send notifications
Agent runs are fully asynchronous and support real-time streaming of responses, tool outputs, and status updates.

Agent Versioning

Every agent has versioned configurations, allowing safe iteration:
  • Version snapshots: Each version captures the complete agent config at that point in time
  • Current version: The active version used for new runs
  • Version history: Full audit trail of configuration changes

Configuration Structure

Agent configurations include:
Reference: backend/core/agents/agent_loader.py:515-541

Suna: The Default Agent

The platform includes a special default agent called Suna:
  • Centrally managed: Configuration loaded from static in-memory config
  • User-specific MCPs: Each user can add their own MCP integrations to Suna
  • Fast loading: Static config is instant, user MCPs are cached
Reference: backend/core/agents/agent_loader.py:412-495

Agent Templates

Templates are pre-configured agent blueprints that users can instantiate:
  • Template marketplace: Public templates created by other users
  • Quick setup: Pre-configured with system prompts, tools, and MCP requirements
  • Customizable: Users can fork and modify templates for their needs
Reference: backend/core/agents/agent_loader.py:257-326

Agent CRUD Operations

Agents support full create, read, update, and delete operations:
Reference: backend/core/agents/agent_crud.py

Performance Optimizations

Caching Strategy

The agent system uses multi-level caching:
  1. Runtime cache: In-memory cache for frequently accessed agents
  2. Redis cache: Distributed cache for agent configs and user MCPs
  3. Static config: Suna’s static config loaded once at startup
Reference: backend/core/agents/agent_loader.py:198-204

Batch Loading

When loading multiple agents (e.g., agent list), the system uses batch queries to minimize database calls:
Reference: backend/core/agents/agent_loader.py:235-255

Threads

Learn about conversation threads where agents execute

Tools

Understand the tool system that extends agent capabilities

MCP

Explore Model Context Protocol integrations

Sandboxes

Understand the isolated execution environments