Skip to main content
The AutoGen Core API provides a foundation for building distributed, event-driven multi-agent systems. It implements the Actor model, where agents are independent entities that communicate through asynchronous message passing.

Architecture Principles

AutoGen Core is built on three fundamental concepts:
  1. Actor Model: Each agent is an independent actor with its own state and behavior
  2. Message Passing: Agents communicate exclusively through messages (no shared state)
  3. 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

The Agent 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
Key methods:
  • on_message_impl(): Abstract method to implement message handling
  • send_message(): Send a direct message to another agent
  • publish_message(): Broadcast message to topic subscribers
  • save_state() / load_state(): Persist and restore agent state

RoutedAgent

RoutedAgent extends BaseAgent with decorator-based message routing:
Key features:
  • @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 match function for secondary routing

Agent Identification

Every agent has a unique AgentId composed of:
AgentId components:
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