Skip to main content
The autogen_core package provides the foundational components for building distributed, event-driven multi-agent systems.

Agent Classes

Base class for implementing agents with message handling capabilities.
agent_id
AgentId
required
Unique identifier for the agent instance
runtime
AgentRuntime
required
Runtime environment for message passing and agent coordination
id
AgentId
Returns the agent’s unique identifier
Decorator-based agent with automatic message routing.
description
str
Optional description of the agent’s capabilities

Decorators

@message_handler
decorator
Marks a method as a handler for published messages of the parameter type
@rpc
decorator
Marks a method as an RPC endpoint for direct invocation
@event
decorator
Marks a method as an event handler
Agent implementation using closure functions for simple message handling.
name
str
required
Agent name identifier
handler
Callable
required
Async function to handle incoming messages
runtime
AgentRuntime
required
Runtime environment

Runtime & Messaging

Protocol defining the runtime environment for agent execution and communication.

Methods

send_message
async method
Send a message to a specific agent and await response
message
Any
required
The message payload to send
recipient
AgentId
required
Target agent identifier
sender
AgentId | None
Sender agent identifier (None for external)
cancellation_token
CancellationToken | None
Token to cancel the operation
message_id
str | None
Unique message identifier
publish_message
async method
Publish a message to all subscribers of a topic
message
Any
required
The message payload
topic_id
TopicId
required
Topic to publish to
sender
AgentId | None
Sender agent identifier
register_factory
async method
Register an agent factory for dynamic agent creation
type
str | AgentType
required
Unique agent type identifier
agent_factory
Callable
required
Factory function that creates agent instances
expected_class
type[Agent] | None
Expected agent class for type checking
In-process runtime for single-threaded agent execution.
start
method
Start the runtime message processing loop
stop
async method
Gracefully stop the runtime
Context information for message handling.
sender
AgentId | None
Identifier of the message sender
topic_id
TopicId | None
Topic the message was published to
message_id
str
Unique message identifier
cancellation_token
CancellationToken
Token for cancelling operations

Identity & Types

Unique identifier for an agent instance.
type
str
required
Agent type name (alphanumeric and underscores)
key
str
required
Instance key (ASCII 32-126 characters)
Agent type definition for factory registration.
name
str
required
Type name identifier
Topic identifier for pub/sub messaging.
type
str
required
Topic type
source
str
required
Topic source namespace
Proxy for remote agent communication.

Subscriptions

Subscribe to messages by exact type match.
topic_type
str
required
Topic type to subscribe to
agent_type
str
required
Agent type that will receive messages
Subscribe to messages matching a type prefix.
topic_type_prefix
str
required
Topic type prefix to match
agent_type
str
required
Agent type to receive matching messages
Subscribe to all messages in a namespace.

Serialization & Components

Protocol for custom message serialization.
Declarative component configuration.
Component
decorator
Marks a class as a configurable component
ComponentModel
class
Serializable component configuration
component_type
str
required
Component type identifier
config
dict
required
Component configuration data
Image data container for multimodal messages.
from_bytes
classmethod
Create image from byte data
from_file
classmethod
Create image from file path
from_url
classmethod
Create image from URL

State Management

Protocol for agent state persistence.
In-memory cache store implementation.

Intervention & Control

Protocol for intercepting and modifying messages.
Exception to prevent message delivery.
Token for cancelling long-running operations.

Telemetry

OpenTelemetry integration for distributed tracing.
Structured logging configuration.
ROOT_LOGGER_NAME
str
Name of the root logger: "autogen_core"
EVENT_LOGGER_NAME
str
Name for structured event logging
TRACE_LOGGER_NAME
str
Name for development trace logging

Types & Protocols

Represents a tool or function call.
id
str
required
Unique call identifier
name
str
required
Function or tool name
arguments
dict
required
Function arguments
Represents a message with unknown type.

Constants

See Also