Skip to content
All Projects

Subagents for Pydantic AI

Multi-agent orchestration with dynamic agent creation

Multi-agent delegation toolset with synchronous, asynchronous, and auto-selected execution modes. Supports nested subagents, runtime agent creation, and parent-child communication.

Installation

Terminal
pip install subagents-pydantic-ai

Define specialist subagents and let a parent agent delegate tasks to them automatically. Three execution modes give you full control: synchronous (blocking — wait for results), asynchronous (background — fire tasks and check later), and auto (the agent chooses the best mode). Subagents can spawn their own subagents for deep delegation chains, and a questions feature lets child agents ask the parent for clarification mid-task.

Features

Sync/Async/Auto Modes
Nested Subagents
Runtime Agent Creation
Parent-Child Comms

Quick Start

subagents_example.py
from pydantic_ai import Agent
from subagents_pydantic_ai import create_subagent_toolset, SubAgentConfig
subagents = [
SubAgentConfig(
name="researcher",
description="Researches topics and gathers information",
instructions="You are a research assistant. Investigate thoroughly.",
),
SubAgentConfig(
name="writer",
description="Writes content based on research",
instructions="You are a technical writer. Write clear, concise content.",
),
]
toolset = create_subagent_toolset(subagents=subagents)
agent = Agent("openai:gpt-4o", deps_type=Deps, toolsets=[toolset])
result = agent.run_sync("Research Python async patterns and write a blog post", deps=Deps())

Use Cases

Research Pipelines

Delegate research to specialist agents that gather, analyze, and synthesize information from multiple sources.

Code Review Delegation

Spawn parallel review agents for security, style, and performance analysis, then merge their findings.

Multi-Step Analysis

Chain agents for complex workflows — researcher gathers data, analyst interprets it, writer produces the report.

Parallel Task Execution

Fire multiple background tasks simultaneously and collect results as they complete, with automatic status tracking.

Ready to build your first production AI agent?

Open-source tools, battle-tested patterns, zero boilerplate. Configure your stack and ship in minutes — not months.