Architecture Principles
AutoGen Core is built on three fundamental concepts:- Actor Model: Each agent is an independent actor with its own state and behavior
- Message Passing: Agents communicate exclusively through messages (no shared state)
- Event-Driven: Asynchronous, non-blocking message processing
Core Components
Agent Types
AutoGen Core provides three base classes for building agents:Agent
Protocol defining the agent interface
BaseAgent
Abstract base class with lifecycle management
RoutedAgent
Handler-based routing with decorators
Runtime Environments
SingleThreadedAgentRuntime
Development runtime with in-process message queue
Distributed Runtime
Production runtime with cross-process/language support
Agent Protocol
TheAgent protocol defines the minimal interface all agents must implement:
BaseAgent
BaseAgent is an abstract base class that provides:
- Agent lifecycle management (initialization, registration, cleanup)
- Runtime binding and ID assignment
- Message sending and publishing utilities
- State persistence hooks
on_message_impl(): Abstract method to implement message handlingsend_message(): Send a direct message to another agentpublish_message(): Broadcast message to topic subscriberssave_state()/load_state(): Persist and restore agent state
RoutedAgent
RoutedAgent extends BaseAgent with decorator-based message routing:
@event: Handler for one-way messages (no response expected)@rpc: Handler for request-response messages (returns a value)@message_handler: Generic handler for both event and RPC messages- Automatic routing based on message type
- Optional
matchfunction for secondary routing
Agent Identification
Every agent has a uniqueAgentId composed of:
string
required
Agent type that associates with a factory function. Must match pattern:
^[\w\-\.]+$string
required
Unique instance identifier within the agent type
Message Flow
AutoGen Core supports two message patterns:Direct Messaging (RPC)
Publish-Subscribe (Events)
Registration Patterns
Agents can be registered using factories or instances:Factory Registration
Instance Registration
State Management
Agents can persist and restore state:Complete Example
Next Steps
Agent Runtime
Learn about runtime environments and lifecycle
Message Passing
Deep dive into messages, contexts, and subscriptions
Event-Driven Architecture
Explore event handlers and message routing
Distributed Runtime
Scale across processes and languages