Contributing¶
Development Setup¶
git clone https://github.com/pyagent/pyagent.git
cd pyagent
# Install all packages in development mode
pip install -e packages/pyagent-patterns[dev]
pip install -e packages/pyagent-router[dev]
pip install -e packages/pyagent-compress[dev]
pip install -e packages/pyagent-trace[dev]
Running Tests¶
# All tests
PYTHONPATH=packages/pyagent-patterns/src:packages/pyagent-router/src:packages/pyagent-compress/src:packages/pyagent-trace/src \
python -m pytest packages/ -v
# Specific package
python -m pytest packages/pyagent-patterns/tests/ -v
Code Style¶
- Ruff for linting and formatting (configured in root
pyproject.toml) - mypy for type checking (strict mode)
- async-first — all pattern
_executemethods are async - Docstrings follow Google style
Adding a New Pattern¶
- Create
packages/pyagent-patterns/src/pyagent_patterns/<tier>/<pattern_name>.py - Subclass
Patternand implementpattern_typeproperty and_execute()method - Export from
<tier>/__init__.py - Register in
registry.py - Add tests in
packages/pyagent-patterns/tests/test_<tier>.py - Add docs page in
docs/packages/patterns/<tier>/<pattern-name>.mdwith:- Mermaid sequence diagram
- Code example
- When to Use / Avoid table
- Cost-effectiveness table
Adding a Cookbook Example¶
The Cookbook is a growing library of complete, runnable multi-agent recipes organized by domain. To add one:
- Create
docs/cookbook/<domain>/<example-slug>.md(e.g.docs/cookbook/finance-trading/portfolio-review.md). - Give it a prompt-shaped title — phrase the
# H1and the frontmatterdescriptionthe way a developer would search or prompt for it (e.g. "How to build a multi-agent portfolio review workflow in Python"). -
Add
summary,complexity, and prefixedtags:on three axes (Domain / Pattern / Package) so the recipe appears in the filterable Cookbook browser and on the matching pattern pages:--- description: "How to build a multi-agent portfolio review workflow in Python with PyAgent." summary: "Analyst panel with an evaluator-optimizer quality gate" complexity: Intermediate # Beginner | Intermediate | Advanced tags: - "Domain: Finance & Trading" - "Pattern: Supervisor" - "Pattern: Evaluator-Optimizer" - "Package: pyagent-patterns" --- -
Follow the example template: problem statement → pattern(s) used → full runnable code (open with the exact
pip installandimportlines) → expected output / OTel trace → Related examples / Patterns used cross-links. - Run
python scripts/gen_docs.pyso the recipe is added to the Cookbook browser and the "Cookbook recipes" section of every pattern it uses. - Run
DISABLE_MKDOCS_2_WARNING=true mkdocs build --strict— it must pass (catches broken links).
Use real package names only (pyagent-patterns, pyagent-all, …) so the examples stay copy-paste-runnable.
Documentation¶
pip install mkdocs-material mkdocstrings[python] mkdocs-redirects mkdocs-llmstxt
mkdocs serve # Preview at http://localhost:8000
Generated pages¶
The benchmark tables on docs/benchmarks.md, the filterable recipe browser on
docs/cookbook/index.md, and the "Cookbook recipes" sections on each pattern page
are generated — the regions between <!-- gen:NAME:start --> /
<!-- gen:NAME:end --> markers are computed from data/benchmarks.yml and each
recipe's frontmatter, so tables, cards, and cross-references can't drift. Edit the
data source (or the recipe), not the generated region, then regenerate:
python scripts/gen_docs.py # rewrite generated regions
python scripts/gen_docs.py --check # CI uses this; fails if out of sync
Package Structure¶
pyagent/
├── packages/
│ ├── pyagent-patterns/ # Core: 18 patterns + composites + guardrails + recovery
│ ├── pyagent-router/ # Difficulty scoring + model selection
│ ├── pyagent-compress/ # Message compression + token budgets
│ └── pyagent-trace/ # OTel spans + cost tracking + replay
├── docs/ # MkDocs Material site
├── mkdocs.yml
└── pyproject.toml # Workspace root