Skip to main content

QuantedAgents

PyPI version Python versions License CI

Type-safe agent SDK wrapping pydantic-ai with Pydantic BaseModel I/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, and Parallel are 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 WorkflowBudget enforcement and configurable escalation policies.
  • Observability built in — every run() returns usage, step timings, and a trace you can serialize to JSONL via TraceWriter / 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

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_agents as 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.

Metadata

Release files for quanted-agents 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quanted-agents 2.0.0
File Size Uploaded
quanted_agents-2.0.0.tar.gz 175.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for quanted-agents 2.0.0
File Interpreter ABI Platform
quanted_agents-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 245.9 kB

Release files / quanted_agents-2.0.0.tar.gz

Download URL quanted_agents-2.0.0.tar.gz
Size 175.8 kB
Tags Source
SHA-256 checksum
How to use checksums
183b1f84be4c1e6873f9135d155e4ffe2177cf0189aebaa1d147e737ad9a854d
BLAKE2b-256 checksum
How to use checksums
bbbc7a0df4ad1fa7b912768b75e2fcf0e8e22afd00e4d8af5877bea33828c2b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 21, 2026.

Transparency log

Release files / quanted_agents-2.0.0-py3-none-any.whl

Download URL quanted_agents-2.0.0-py3-none-any.whl
Size 70.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3faf187cfbd45d94fb36e67192dc610ae3da5bb00db25554c8ecae13ccc327ee
BLAKE2b-256 checksum
How to use checksums
7f8a6aa4399c0a99b5c1b92d3c39a7cae7b3b98e8657bd22343801c01936ff40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release 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