Skip to main content

pydantic-team

CI PyPI Python

Type-safe team orchestration for pydantic-ai Agents.

v1 provides hierarchical and collaborative teams for pydantic-ai Agents:

  • HierarchicalTeam — leader delegates via tools (Agno coordinate / agent delegation)
  • CollaborativeTeam — shared task board with parallel claim/assign

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

Install

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

Depends on pydantic-ai-slim (core agents only — no provider SDKs). Install a provider extra when you need a live model, e.g. pydantic-ai-slim[openai].

Requires Python 3.10+.

Documentation

Published docs: etiqa.github.io/pydantic-team

Local build (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-4.1',
    name='researcher',
    instructions='Research the topic and return concise notes.',
)
writer = Agent(
    'openai:gpt-4.1',
    name='writer',
    instructions='Turn research notes into a short article.',
)

team = HierarchicalTeam(
    leader_model='openai:gpt-4.1',
    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.

CollaborativeTeam

Shared TaskBoard: the leader creates tasks and assigns them by role; members complete their assigned work in parallel rounds (max_rounds). Peer messaging is not included yet.

from pydantic_ai import Agent
from pydantic_team import CollaborativeTeam

researcher = Agent(
    'openai:gpt-4.1',
    name='researcher',
    instructions='Complete only research tasks assigned to you.',
)
writer = Agent(
    'openai:gpt-4.1',
    name='writer',
    instructions='Complete only writing tasks assigned to you.',
)

team = CollaborativeTeam(
    leader_model='openai:gpt-4.1',
    members=[researcher, writer],
    max_rounds=3,
)
result = await team.run('Draft a short brief on agent teams')

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.

Examples

Runnable scripts (live model API — not part of the test suite). Core deps stay pydantic-ai-slim only; the examples group pulls in the OpenAI provider extra, logfire, and python-dotenv. Examples call logfire.configure(send_to_logfire='if-token-present'), logfire.instrument_pydantic_ai(), and instrument_pydantic_team() so spans print locally without auth; set LOGFIRE_TOKEN or run logfire auth for cloud.

# Put OPENAI_API_KEY in examples/.env (auto-loaded) or export it.
# optional: export PYDANTIC_TEAM_MODEL=openai:gpt-5.6-luna
uv sync --group examples
uv run examples/hierarchical_basic.py
uv run examples/collaborative_basic.py
# one-shot without a prior sync:
# uv run --group examples examples/hierarchical_basic.py

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.

On a v* tag, CI publishes to PyPI (Trusted Publisher / environment release) and deploys docs to GitHub Pages.

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.2.0.tar.gz (130.2 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.2.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_team-0.2.0.tar.gz
  • Upload date:
  • Size: 130.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pydantic_team-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bfa9d12e3df6a870ea409660c740d1693df56836f3da25da11e2c8301fa2683a
MD5 6aa90d8421a342e4aded040cc91f8ab3
BLAKE2b-256 07fd87d7988adf8c3c736bee7f062a3ce868908312a7868ba226eb9a0e113935

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_team-0.2.0.tar.gz:

Publisher: ci.yml on Etiqa/pydantic-team

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pydantic_team-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pydantic_team-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afd721a4ed9736ea0d2fc51189f7dad09947efe0cbdaead055a92e804c75179b
MD5 79b654b494615288b0b54eca3657486a
BLAKE2b-256 e52e4eeb718c813999f0ce8c5f6d6fc2f976b5320de6b14459e3c553600c81c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_team-0.2.0-py3-none-any.whl:

Publisher: ci.yml on Etiqa/pydantic-team

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

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