Type-safe agent SDK wrapping pydantic-ai with Pydantic BaseModel I/O enforcement
Project description
QuantedAgents
Type-safe agent SDK wrapping pydantic-ai with Pydantic
BaseModelI/O enforcement, composable workflow primitives (Pipeline, Router, Loop, Parallel), hierarchical agent orchestration, and built-in observability.
Installation
pip install quanted-agents
Requires Python 3.13+.
Set the API key for whichever LLM provider you use:
export OPENAI_API_KEY="sk-..."
# or ANTHROPIC_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, ...
Quickstart
import asyncio
from pydantic import BaseModel
from quanted_agents import QuantedAgent
class Article(BaseModel):
text: str
class Analysis(BaseModel):
summary: str
sentiment: str
topics: list[str]
agent = QuantedAgent(
"openai:gpt-4o-mini",
input_type=Article,
output_type=Analysis,
system_prompt="Analyze the article: short summary, sentiment, key topics.",
)
async def main() -> None:
result = await agent.run(Article(text="AI is reshaping healthcare ..."))
print(result.data.summary)
print(result.data.sentiment, result.data.topics)
print(f"Tokens: {result.usage.input_tokens} in / {result.usage.output_tokens} out")
asyncio.run(main())
The input and output are real Pydantic models — validated, typed, and IDE-completable.
Why QuantedAgents
- Type-safe I/O — every agent declares an input and output
BaseModel. Inputs are serialized for the LLM automatically; outputs are validated. No string-juggling. - Composable workflows —
Pipeline,Router,Loop, andParallelare first-class primitives that nest recursively. Build complex agentic flows without leaving the type system. - Hierarchical agents — parent agents can delegate to child agents as tools, with shared
WorkflowBudgetenforcement and configurable escalation policies. - Observability built in — every
run()returns usage, step timings, and a trace you can serialize to JSONL viaTraceWriter/TraceSession. - MCP support — connect to Model Context Protocol servers via
MCPTool. - Recovery primitives — JSON repair, structured re-prompting via a restructurer model, configurable retry policies.
- Claude Code skill included — bundled
.claude/skills/quanted-agents/makes Claude Code reach for this SDK by default when building agent workflows.
Workflow primitives at a glance
from quanted_agents import Pipeline, Router, Loop, Parallel
# Pipeline: run agents in sequence, piping output -> input
flow = Pipeline([extract_agent, classify_agent, summarize_agent])
# Router: pick a downstream agent based on a routing decision
router = Router(decider, branches={"refund": refund_agent, "support": support_agent})
# Loop: re-run until a condition is met (or a max iteration count)
loop = Loop(critic_agent, until=lambda r: r.data.is_acceptable, max_iterations=5)
# Parallel: fan out to N agents, gather typed results
fanout = Parallel([researcher_a, researcher_b, researcher_c])
All four nest inside each other and inside QuantedAgent tool definitions.
Documentation
- API Reference — every class, method, and parameter.
- Patterns Guide — 19 production patterns with runnable examples.
- Hierarchical Agents Guide — building parent/child agent systems.
Examples
Thirteen runnable examples in examples/, numbered by complexity:
| # | Example | Concept |
|---|---|---|
| 01 | Single agent | Typed I/O, basic observability |
| 02 | Pipeline | Sequential composition |
| 03 | Router | Branching by routing decision |
| 04 | Loop | Iterate until a predicate is satisfied |
| 05 | Parallel | Fan-out / fan-in |
| 06 | Skills + feedback | On-demand context loading |
| 07 | Trace logging | JSONL traces via TraceWriter |
| 08 | Hierarchical agents | Parent/child orchestration |
| 09 | Dual stream | Streaming + structured output |
| 10 | Soft limits | WorkflowBudget with soft caps |
| 11 | Tool middleware | Wrapping tool calls |
| 12 | Trace sessions | Long-running session tracing |
| 13 | Parallel retry | Per-branch retry policies |
Claude Code skill
The repository ships a Claude Code skill under .claude/skills/quanted-agents/. Drop it into any project and Claude Code will:
- Use
quanted_agentsas its default agent framework. - Read the bundled SDK reference before writing agent code.
- Apply production defaults (restructurer model, recovery retries, soft budgets, trace logging).
- Prefer focused child agents over monolithic single agents.
To install the skill into a project:
mkdir -p /path/to/your/project/.claude/skills
cp -r .claude/skills/quanted-agents /path/to/your/project/.claude/skills/
Or globally for all your projects:
mkdir -p ~/.claude/skills
cp -r .claude/skills/quanted-agents ~/.claude/skills/
Contributing
Issues and pull requests welcome. See CONTRIBUTING.md for the development setup, code style, and PR process. Bug reports and feature requests use the issue templates.
By contributing you agree your contributions are licensed under Apache 2.0 (the project's license).
Security
For security vulnerabilities, please follow the disclosure process in SECURITY.md — do not open a public issue.
License
Licensed under the Apache License, Version 2.0. See NOTICE for attribution.
Copyright (c) 2026 Quanted.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quanted_agents-2.0.0.tar.gz.
File metadata
- Download URL: quanted_agents-2.0.0.tar.gz
- Upload date:
- Size: 175.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
183b1f84be4c1e6873f9135d155e4ffe2177cf0189aebaa1d147e737ad9a854d
|
|
| MD5 |
b6ebb1c27ab555df4a8479d92e297637
|
|
| BLAKE2b-256 |
bbbc7a0df4ad1fa7b912768b75e2fcf0e8e22afd00e4d8af5877bea33828c2b0
|
Provenance
The following attestation bundles were made for quanted_agents-2.0.0.tar.gz:
Publisher:
publish.yml on Quanted-AI/QAgents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quanted_agents-2.0.0.tar.gz -
Subject digest:
183b1f84be4c1e6873f9135d155e4ffe2177cf0189aebaa1d147e737ad9a854d - Sigstore transparency entry: 1592508156
- Sigstore integration time:
-
Permalink:
Quanted-AI/QAgents@044506db730931dc16b5819fa1526d70d686a000 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/Quanted-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@044506db730931dc16b5819fa1526d70d686a000 -
Trigger Event:
release
-
Statement type:
File details
Details for the file quanted_agents-2.0.0-py3-none-any.whl.
File metadata
- Download URL: quanted_agents-2.0.0-py3-none-any.whl
- Upload date:
- Size: 70.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3faf187cfbd45d94fb36e67192dc610ae3da5bb00db25554c8ecae13ccc327ee
|
|
| MD5 |
38acfb9da8160859e27ed63394ac064d
|
|
| BLAKE2b-256 |
7f8a6aa4399c0a99b5c1b92d3c39a7cae7b3b98e8657bd22343801c01936ff40
|
Provenance
The following attestation bundles were made for quanted_agents-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on Quanted-AI/QAgents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quanted_agents-2.0.0-py3-none-any.whl -
Subject digest:
3faf187cfbd45d94fb36e67192dc610ae3da5bb00db25554c8ecae13ccc327ee - Sigstore transparency entry: 1592508195
- Sigstore integration time:
-
Permalink:
Quanted-AI/QAgents@044506db730931dc16b5819fa1526d70d686a000 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/Quanted-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@044506db730931dc16b5819fa1526d70d686a000 -
Trigger Event:
release
-
Statement type: