Skip to content

Orchestrator

A standalone component that manages the LLM conversation loop with advanced routing, execution control, and observability hooks.

Why a Standalone Orchestrator?

While Pydantic AI provides built-in orchestration, a standalone orchestrator offers:

  • Rule-based routing - Route different queries to different models or tools
  • Multi-model orchestration - Use different models for different tasks
  • Embeddable - Integrate into existing applications and pipelines
  • Customizable loop - Inject logic at any point in the execution cycle
  • Observable - Full visibility into decisions, timing, and costs

Architecture

Orchestrator Architecture

Sub-components

ComponentResponsibility
Conversation ManagerMessage history, context limits, conversation forking
Model RouterRule-based model selection (fast vs smart, code vs chat)
Tool RouterRule-based routing to MCP servers and backends
Execution EngineParallel execution, retries, timeouts, result transformation
HooksMiddleware for logging, metrics, and custom logic

Model Router

Select different models based on task characteristics:

Routing TypeExample
By complexitySimple queries → fast model, complex → smart model
By intentCode tasks → code-optimized model
By costBudget constraints → cheaper models
By capabilityVision tasks → multimodal models

Tool Router

Route tool calls to appropriate backends based on patterns:

PatternDestinationUse Case
fs_*Filesystem serverFile operations
db_*Database serverData queries
*Armory (default)Everything else

Hooks for Observability

Register handlers for various events in the orchestration loop:

EventUse Case
model_requestLog model calls, track usage
tool_callsMonitor tool usage, metrics
completeCost tracking, budget management
errorError logging, alerting

Comparison with Pydantic AI Agent

FeaturePydantic AI AgentStandalone Orchestrator
Setup complexitySimpleMore configuration
Routing rulesLimitedFull control
Multi-modelOne model per agentDynamic selection
Hooks/middlewareLimitedExtensive
EmbeddabilityAgent owns loopComponent in your system

Building efficient AI agents