Skip to main content

Type-safe agent SDK wrapping pydantic-ai with Pydantic BaseModel I/O enforcement

Project description

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 workflowsPipeline, 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.mddo not open a public issue.

License

Licensed under the Apache License, Version 2.0. See NOTICE for attribution.

Copyright (c) 2026 Quanted.

Project details


Download files

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

Source Distribution

quanted_agents-2.0.0.tar.gz (175.8 kB view details)

Uploaded Source

Built Distribution

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

quanted_agents-2.0.0-py3-none-any.whl (70.1 kB view details)

Uploaded Python 3

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

Hashes for quanted_agents-2.0.0.tar.gz
Algorithm Hash digest
SHA256 183b1f84be4c1e6873f9135d155e4ffe2177cf0189aebaa1d147e737ad9a854d
MD5 b6ebb1c27ab555df4a8479d92e297637
BLAKE2b-256 bbbc7a0df4ad1fa7b912768b75e2fcf0e8e22afd00e4d8af5877bea33828c2b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for quanted_agents-2.0.0.tar.gz:

Publisher: publish.yml on Quanted-AI/QAgents

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

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

Hashes for quanted_agents-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3faf187cfbd45d94fb36e67192dc610ae3da5bb00db25554c8ecae13ccc327ee
MD5 38acfb9da8160859e27ed63394ac064d
BLAKE2b-256 7f8a6aa4399c0a99b5c1b92d3c39a7cae7b3b98e8657bd22343801c01936ff40

See more details on using hashes here.

Provenance

The following attestation bundles were made for quanted_agents-2.0.0-py3-none-any.whl:

Publisher: publish.yml on Quanted-AI/QAgents

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page