AgentRegistry class maps agent IDs to their implementation or location, enabling unified routing between local agent classes and remote transports.
Import
Constructor
Methods
register
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
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.