Skip to main content

pydantic-team

Type-safe team orchestration for pydantic-ai Agents.

v1 focuses on hierarchical (leader + specialists) teams — the same idea as Agno's TeamMode.coordinate and pydantic-ai agent delegation, without hiding usage/token tracking.

For sequential, branching, or stateful pipelines, use pydantic-graph (already pulled in by pydantic-ai).

Install

uv add pydantic-team
# or from a checkout:
uv sync --group lint --group dev

Requires Python 3.10+.

Documentation

Full guides and API reference (MkDocs + mkdocstrings):

uv sync --group docs
make docs-serve   # http://127.0.0.1:8000
make docs         # build into site/

HierarchicalTeam

The leader registers each member as a tool and passes usage=ctx.usage on nested runs so TeamResult.usage includes every agent involved.

import asyncio

from pydantic_ai import Agent
from pydantic_team import HierarchicalTeam

researcher = Agent(
    'openai:gpt-4o',
    name='researcher',
    instructions='Research the topic and return concise notes.',
)
writer = Agent(
    'openai:gpt-4o',
    name='writer',
    instructions='Turn research notes into a short article.',
)

team = HierarchicalTeam(
    leader_model='openai:gpt-4o',
    members=[researcher, writer],
    system_prompt_override=(
        'Delegate to researcher or writer based on the task, then synthesize a final answer.'
    ),
)


async def main() -> None:
    result = await team.run('Explain pydantic-ai agent delegation briefly.')
    print(result.data)
    print(result.usage)


asyncio.run(main())

You can also pass an existing leader_agent= instead of leader_model=. Nested HierarchicalTeam instances are valid members (set name= for a clear tool id).

See the hierarchical teams guide for nested teams, usage details, and TestModel testing.

Result type

from pydantic_team import TeamResult

# result: TeamResult
# result.data  — final leader output
# result.usage — aggregated RunUsage (requests + tokens)

Sequential / complex control flow

Use pydantic-graph when you need an ordered pipeline, branches, loops, or shared state. This library intentionally does not reimplement that.

Development

make install      # uv sync + pre-commit
make format
make lint
make typecheck
make test         # pytest with --cov-fail-under=100
make ci           # format + lint + test
make ci-strict    # lint + typecheck + test
make docs         # MkDocs build (needs --group docs)
make docs-serve

Unit tests use pydantic-ai TestModel only — no live LLM calls.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_team-0.1.0.tar.gz (180.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_team-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_team-0.1.0.tar.gz.

File metadata

  • Download URL: pydantic_team-0.1.0.tar.gz
  • Upload date:
  • Size: 180.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pydantic_team-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d11c53aa60d2a854f9f881f6a89d6ea262018da1b2e56dc2105ab513f2f6cdef
MD5 564fd6440de8aa3e8c92e53774dbad48
BLAKE2b-256 39a5fd360fe33b0df0ed0f4e25d2eee2b0119e697c5eda06e46c84e806608c30

See more details on using hashes here.

File details

Details for the file pydantic_team-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_team-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pydantic_team-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78e7d3941d4692bcb7f0a9cacb1a4743489295afa1079e2c745e86be46559a00
MD5 3fa9f4abcac93ab94fe18688ec563e90
BLAKE2b-256 250d923f81da38021d1d56dfd5a58125acf6a079ae718c40f7108ce2765467f0

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page