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 theAgentData class, which serves as the single source of truth for agent representation:
backend/core/agents/agent_loader.py:14-57
Agent Loading System
TheAgentLoader 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
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:backend/core/agents/runner/executor.py:93-159
Execution Flow
- Initialization: Load agent configuration and setup execution context
- Message Processing: Process user message through LLM with available tools
- Tool Execution: Execute any tool calls requested by the LLM
- Response Streaming: Stream responses back to client via Redis
- Completion: Mark run as complete and send notifications
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: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
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
backend/core/agents/agent_loader.py:257-326
Agent CRUD Operations
Agents support full create, read, update, and delete operations:backend/core/agents/agent_crud.py
Performance Optimizations
Caching Strategy
The agent system uses multi-level caching:- Runtime cache: In-memory cache for frequently accessed agents
- Redis cache: Distributed cache for agent configs and user MCPs
- Static config: Suna’s static config loaded once at startup
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:backend/core/agents/agent_loader.py:235-255
Related Concepts
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