Skip to main content

PolyAgent — a model-agnostic multi-agent orchestration framework.

Project description

PolyAgent

A model-agnostic multi-agent orchestration framework — declare Agent roles, let the orchestrator run them through a Plan → Execute(parallel) → Critique → Synthesize pipeline, with reliability middleware and observability at every layer.

CI Python Tests

polyagent is a pure-backend, dependency-light Python framework for building multi-agent systems on top of LLMs. It ships as a reusable SDK plus a CLI. No UI, no web framework — just orchestration.


Why

A single agent calling an LLM directly hits three walls on real work:

  1. Context explosion — one agent planning + executing + summarizing balloons the prompt.
  2. Single-point unreliability — one timeout / rate-limit kills the whole task.
  3. No observability, no evaluation — you can't tell what it cost or how good it was.

PolyAgent answers this with role separation + an orchestration layer + a reliability middleware chain, turning raw LLM calls into a schedulable, degradable, observable system.


Install

# editable install with dev tooling
pip install -e ".[dev]"

# (optional) RAG extras — heavier vector backends
pip install -e ".[rag]"

Requires Python ≥ 3.11.

Quick start

polyagent version                       # sanity check
polyagent run "build a small web app"   # run the full multi-agent pipeline (mock, offline)
polyagent eval                          # run the eval dataset, print pass-rate
polyagent chat                          # interactive single-agent chat (Ctrl-D to exit)

SDK usage:

import asyncio
from polyagent.core import Agent, AgentSpec
from polyagent.llm import LLMClient, MockProvider
from polyagent.orchestration import Orchestrator, Planner, Worker, Critic, Synthesizer
from polyagent.observability import Tracer

async def main():
    tracer = Tracer()
    # ...assemble Planner/Worker/Critic/Synthesizer with LLMClients...
    orch = Orchestrator(planner, worker, critic, synth, tracer=tracer)
    result = await orch.run("your goal")
    print(result.answer, result.task_graph, result.estimated_cost_usd)

asyncio.run(main())

Architecture

polyagent/
├── core/           # Agent, Message/Role/ToolCall, AgentSpec, exceptions
├── llm/            # LLMProvider protocol, DeepSeek/Mock, reliability middleware, LLMClient
├── tools/          # Tool base, registry, pydantic->JSON Schema, 5 built-ins, sandbox
├── memory/         # ConversationBuffer, VectorMemory, context compressors
├── rag/            # Embedder/VectorStore protocols, HashEmbedder, InMemoryVectorStore, TextSplitter, RAGIndex
├── orchestration/  # Planner/Worker/Critic/Synthesizer, DAG scheduler, critique retry
├── observability/  # Tracer(span tree), Metrics, structlog, ObservabilityMiddleware
├── eval/           # Dataset, Scorer, EvalRunner, EvalReport
└── cli/            # typer: run / chat / eval / version

See docs/ARCHITECTURE.md for the full design.

Reliability middleware chain (LLM layer)

request → RateLimit → Retry(backoff+jitter) → Fallback → BudgetCheck → provider → CostAccount → response

Each link is composable and unit-testable; ObservabilityMiddleware adds an llm.chat span per call.


Roadmap — all done ✅

Milestone Status What
M0 scaffold: pyproject, package tree, ruff/mypy, CI, smoke tests
M1 LLM provider abstraction + reliability middleware + single agent
M2 tool system + pydantic→schema + 5 built-ins + sandbox
M3 memory + RAG (pluggable embedder/vectorstore)
M4 orchestrator: 4-role pipeline + DAG + critique fallback
M5 observability: span-tree tracing + metrics + structured logs
M6 CLI: run / chat / eval / version
M7 eval: datasets + scorers + runner
M8 docs + repo-analysis showcase

Showcase: code repository analysis

python examples/repo_analysis/analyze.py .

A Planner decomposes "analyze repo" into inventory → entrypoints → tests → smells → report; Workers carry grep_files + read_file; a Critic reviews; a Synthesizer writes the report. Mock mode runs offline. See examples/repo_analysis/README.md.


Resume highlights

  • LLM orchestration & reliability — provider protocol, DeepSeek + Mock, retry / fallback / rate-limit / token-budget / cost accounting (llm/).
  • Tool-use & plugins — function-calling schema auto-generated from pydantic, registry, 5 built-in tools, subprocess sandbox (tools/).
  • Memory & RAG — short-term buffer, vector memory, pluggable embedder/vectorstore, context compression (memory/, rag/).
  • Observability & evaluation — contextvars span-tree tracing, metrics, structlog, eval datasets + scorers + pass-rate (observability/, eval/).
  • Multi-agent architecture — role pipeline with DAG scheduling, parallel workers, critique-driven retry, failure blocking (orchestration/).

The one-liner: "A model-agnostic multi-agent orchestration framework that turns raw LLM calls into a schedulable, degradable, observable, evaluable system — SDK + CLI, 55 offline tests, zero UI."


Testing

pytest -q          # 55 tests, all offline (MockProvider)
ruff check .       # clean

CI runs on Python 3.11 / 3.12 / 3.13.


License

MIT.

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

scgnb666-0.1.2.tar.gz (68.3 kB view details)

Uploaded Source

Built Distribution

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

scgnb666-0.1.2-py3-none-any.whl (68.9 kB view details)

Uploaded Python 3

File details

Details for the file scgnb666-0.1.2.tar.gz.

File metadata

  • Download URL: scgnb666-0.1.2.tar.gz
  • Upload date:
  • Size: 68.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for scgnb666-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bd74b6f3a84601a744ce8de19be2abfa45db985a5b15317f24045d5585a71185
MD5 c57bb99ccd25765f69396352ed5de3a7
BLAKE2b-256 bab51489e86e5ee0ff0ca16e09047eeaeb95c3fee6bdbc2ff4d9ab014f9dfac2

See more details on using hashes here.

File details

Details for the file scgnb666-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: scgnb666-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 68.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for scgnb666-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b9c2dae98ab4bf478b5d382c775018b59a0849df73444b5c2b63c7d58f099667
MD5 cddd098fb72bebf77988aec5b23af7fc
BLAKE2b-256 229ef6d85f1ca0766ada0a2a0ff1170721bc0c69877bb80ef940cee7efa510dd

See more details on using hashes here.

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