Skip to main content
The distributed runtime extends AutoGen Core’s capabilities beyond a single process, enabling agents to communicate across process boundaries, machines, and even programming languages.
The distributed runtime implements the same AgentRuntime protocol as SingleThreadedAgentRuntime, making it easy to scale from development to production.

Architecture Overview

The distributed runtime uses a message broker to route messages between agent instances running in different processes or on different machines. Key features:
  • Process isolation: Agents run in separate processes for fault tolerance
  • Horizontal scaling: Add more agent instances to handle load
  • Cross-language: Python agents can communicate with .NET agents
  • Location transparency: Agents don’t know or care where other agents are running

Core Concepts

Message Broker

The distributed runtime uses a message broker (like gRPC, Redis, or RabbitMQ) to route messages between agent processes.

Agent Registration

Each agent process registers its agent types and subscriptions with the runtime. The runtime coordinates with the broker to route messages correctly.

Serialization

Messages are serialized when sent across process boundaries. AutoGen Core supports JSON and Protocol Buffers.

Setting Up Distributed Runtime

The exact distributed runtime implementation may vary based on your deployment. This section covers general patterns. Refer to the AutoGen distributed runtime documentation for specific implementation details.

Example: Multi-Process Setup

Process 1: Worker Agent

Process 2: Coordinator Agent

Cross-Language Communication

The distributed runtime supports agents written in different languages communicating through the message broker.

Python to .NET Example

Python Agent

C# (.NET) Agent

Message types must be compatible across languages. Use simple types (strings, numbers, lists, dictionaries) or shared Protocol Buffer definitions.

Message Serialization

Custom Serializers for Distributed Runtime

Protocol Buffers

For efficient binary serialization:

Fault Tolerance

Agent Restart Handling

Agents in different processes can fail and restart independently:

Timeout Handling

Distributed Subscriptions

Subscriptions work the same in distributed runtime:
The broker ensures published messages reach all subscribers across processes.

Load Balancing

Multiple Worker Instances

The distributed runtime can load-balance messages across multiple instances of the same agent type running in different processes.

Monitoring and Observability

OpenTelemetry Integration

Traces span across processes, showing the complete message flow.

Best Practices

Assume agents can fail and restart. Use state persistence and idempotent message handlers.
Always use timeouts for cross-process RPC calls to prevent indefinite blocking.
Include version information in message serialization to support rolling updates.
Track message queue depths and processing latencies to detect bottlenecks.
Large messages increase serialization overhead and network latency. Pass references instead of large data.
For high-throughput scenarios, Protocol Buffers provide better performance than JSON.

Deployment Patterns

Docker Compose Example

Kubernetes Example

Limitations and Considerations

  • Network latency: Cross-process communication is slower than in-process
  • Serialization overhead: Messages must be serialized/deserialized
  • Broker dependency: The message broker is a single point of failure (use HA broker)
  • Eventual consistency: State across agents may be eventually consistent

Next Steps

Core Overview

Return to Core API overview

Agent Runtime

Learn about runtime operations

Message Passing

Understand message contexts and subscriptions

Event-Driven Architecture

Master event handlers and routing