Skip to main content
The AgentRegistry class maps agent IDs to their implementation or location, enabling unified routing between local agent classes and remote transports.

Import

Constructor

Creates a new empty registry.

Methods

register

Register a route pattern for agent ID matching.

Parameters

str
required
Regex pattern for agent ID matching (e.g., “writer”, “room-.*”, “worker-[0-9]+”). Simple alphanumeric patterns are automatically anchored (e.g., “writer” becomes “^writer$”).
RegistryTarget
required
The target to route to:
  • Agent class: Local instantiation (e.g., WriterAgent)
  • AgentTransport: Remote communication (e.g., HTTPTransport("..."))

Examples


resolve

Find the target for a given agent ID by testing registered patterns in order.

Parameters

str
required
The agent ID to resolve.

Returns

Raises

  • ValueError: If no matching route is found for the agent ID.

Examples


Complete Example


Pattern Matching

The registry uses Python regex patterns with special behavior for simple names: Patterns are tested in registration order, so register more specific patterns first.

Integration with AgentServer