Skip to main content
The Microsoft.AutoGen.Core namespace provides the foundational components for building distributed, event-driven multi-agent systems in .NET.

Agent Classes

Abstract base class for all agents in the AutoGen system.
AgentId
required
Unique identifier for the agent instance
IAgentRuntime
required
Runtime environment for message passing
string
required
Description of the agent’s capabilities
ILogger<BaseAgent>?
Optional logger instance

Properties

AgentId
Gets the unique identifier of the agent
AgentMetadata
Gets metadata associated with the agent
IAgentRuntime
Gets the runtime environment

Methods

ValueTask<object?>
Handles an incoming message
object
required
The received message
MessageContext
required
Context information about the message
ValueTask<object?>
Send a message to another agent
ValueTask
Publish a message to a topic
ValueTask
Called when the agent is being closed
Single-process agent runtime for local execution.
ValueTask<AgentType>
Register an agent factory function
ValueTask<object?>
Send a message to an agent
ValueTask
Publish a message to a topic

Contracts & Interfaces

Core interface for all agents.
AgentId
Gets the unique identifier of the agent
AgentMetadata
Gets metadata about the agent
ValueTask<object?>
Handles incoming messages
Interface for agents that can be hosted in a runtime.
ValueTask
Called when the runtime is closing
Defines the runtime environment for agents.

Methods

ValueTask<object?>
Send a message to a specific agent and await response
object
required
The message to send
AgentId
required
Target agent identifier
AgentId?
Sender agent (null for external)
string?
Unique message identifier
CancellationToken
Cancellation token
ValueTask
Publish a message to all topic subscribers
object
required
The message payload
TopicId
required
Topic to publish to
ValueTask<AgentType>
Register an agent factory for dynamic creation
AgentType
required
Unique agent type
Func<AgentId, IAgentRuntime, ValueTask<IHostableAgent>>
required
Factory function
Interface for handling messages of a specific type.
type parameter
Message type to handle

Identity & Types

Unique identifier for an agent instance.
string
required
Agent type name (alphanumeric and underscores)
string
required
Instance key (ASCII 32-126 characters)

Methods

static AgentId
Parse from “type/key” format
string
Convert to “type/key” format
Agent type definition.
string
required
Type name identifier
Topic identifier for pub/sub messaging.
string
required
Topic type
string
required
Topic source namespace
Metadata about an agent.
Proxy for remote agent communication.

Messaging

Context information for message handling.
AgentId?
Identifier of the message sender
TopicId?
Topic the message was published to
string
Unique message identifier

Subscriptions

Subscribe to messages by exact type match.
string
required
Topic type to subscribe to
string
required
Agent type that will receive messages
Subscribe to messages matching a type prefix.
Attribute for declarative subscriptions.

State Management

Interface for agent state persistence.
ValueTask<JsonElement>
Save the agent’s state to JSON
ValueTask
Load state from JSON

Application Host

Application host for agent systems.
static Task<AgentsApp>
Create a new agents application
Task
Register an agent type
Task
Start the application
Task
Stop the application

Exceptions

Thrown when an agent cannot handle a message.
Thrown when a message cannot be delivered.

Utilities

Utilities for agent reflection and discovery.
Invokes message handlers dynamically.

Telemetry

OpenTelemetry integration.

See Also