agentflow
YAML-defined agent workflows where each step is its own GitHub repo. The runtime pulls each repo, starts the steps, carries every message between them (steps never know the topology), and writes every movement to a queryable event log. A Next.js dashboard shows the workflow as a live flow graph, per-run traces, and a SQL console over the logs.
workflows/*.yaml ──▶ runtime (python) dashboard (next.js)
├─ fetch each step: git clone repo@ref (or path) ├─ Workflow: live graph, λ/X/wait/service/ρ,
├─ start N replicas per step (own venv if │ Little's law check, bottleneck + advice,
│ requirements.txt), supervise, restart │ run example / generate load
├─ per-step bounded queues (backpressure), ├─ Runs: per-run timeline (queue wait vs
│ retries with backoff, dead letters, routing │ service), every event
│ on `when:`, fan-out, sinks, sessions └─ Logs: read-only SQL (DuckDB) + presets
└─ event log: DuckDB (columnar) + JSONL
Run it
# runtime
uv sync # installs deps from pyproject.toml / uv.lock
uv run python -m agentflow validate workflows/doc-triage.yaml
uv run python -m agentflow up workflows/doc-triage.yaml # API on :7070
# dashboard (another terminal)
cd dashboard && npm install && npm run dev # http://localhost:3000 (proxies /api → :7070)
AGENTFLOW_API=http://127.0.0.1:7071 npm run dev # if the runtime is elsewhere
# drive it
uv run python -m agentflow run '{"customer_id":"acme","title":"Q3 report","text":"...","kind_hint":"report"}' --wait
uv run python -m agentflow load --rate 3 --duration 60 # watch `summarize` become the bottleneck
uv run python -m agentflow query "select step, count(*) from events where event='retry' group by step"
uv run pytest -q
State lives in .agentflow/ next to the workflow's folder (event log events.duckdb + events.jsonl, cloned repos,
per-step venvs, process logs), or in --workdir.
As a library in another project
Published on PyPI as pyagentflow (the name agentflow was taken); the import is still import agentflow.
uv add pyagentflow # or: pip install pyagentflow
uv add "pyagentflow @ git+https://github.com/MatthewDegtyar/agentflow" # unreleased main
python -m agentflow up path/to/flow.yaml --workdir .agentflow # also installed as the `agentflow` command
The wheel ships the agentflow package and the step SDK as a top-level agentflow_step module, so step processes
started by an installed runtime can from agentflow_step import Step. Step path: values and sink paths resolve
relative to the YAML file. To embed the engine in-process:
from agentflow import Engine, load
wf, base_dir, text = load("flow.yaml")
engine = Engine(wf, base_dir, text, work=Path(".agentflow"))
await engine.start(); run_id = await engine.start_run({"msg": "hi"}); ...; await engine.stop()
Workflow YAML
name: doc-triage
steps:
classify:
repo: github.com/your-org/agent-classify # cloned at startup; private repos: set GITHUB_TOKEN
ref: main # branch, tag or commit SHA (recorded per event)
path: ../examples/steps/classify # local override while the repo doesn't exist
run: python main.py # starts the step server; it must listen on $PORT
replicas: 2 # processes
concurrency: 4 # items in flight per process → capacity = 8 slots
timeout_s: 30
retries: 2 # for retryable failures (exceptions, timeouts, crashes)
max_queue: 1000 # bounded queue: when full, upstream waits (backpressure)
env: { MODEL: "${MODEL:-claude-sonnet-5}" }
flow:
- { from: input, to: intake }
- { from: classify, to: summarize, when: "output.kind in ['report', 'contract']" }
- { from: summarize, to: sink.jsonl, with: { path: out/summaries.jsonl } }
session:
key: input.customer_id # shared state across steps for the same customer
examples: [ ... ] # sample inputs for `load` / the dashboard
path: wins over repo: until you set AGENTFLOW_USE_REPOS=1 (with both set, path becomes a subdirectory of the
repo). when: is a safe expression over output, input (the run's original input) and session.
Writing a step (the contract for each agent repo)
A step repo needs main.py (and optionally requirements.txt, installed into the step's own venv):
from agentflow_step import Step # provided by the runtime on PYTHONPATH; stdlib only
step = Step()
@step.handler
def handle(ctx, payload):
ctx.log("working", level="info", chars=len(payload["text"])) # → event log, tied to run/item/step
ctx.usage(model="claude-sonnet-5", input_tokens=812, output_tokens=64, cost_usd=0.003)
ctx.session["seen"] = ctx.session.get("seen", 0) + 1 # shared per session key
if not payload.get("text"):
ctx.fail("invalid_input", "no text") # non-retryable → dead letter
return {"kind": "report"} # or ctx.emit(...) N times (fan-out)
step.run() # serves POST /invoke + GET /health on $PORT
Raising an exception is a retryable failure: its type becomes the reason and the traceback is kept. Any language
works if it serves GET /health and POST /invoke with the same JSON contract (see sdk/python/agentflow_step.py).
Event log
One events table (DuckDB, so columnar): ts, event, workflow, run_id, item_id, parent_id, step, replica, attempt, session_id, wait_ms, service_ms, status, reason, error, message, data (JSON).
Events: run_started, run_completed, enqueued (with blocked_ms = backpressure), started (with wait_ms =
time queued), completed, retry, dead_letter, routed, unrouted, sink, log, usage, step_source
(repo and commit), step_process. Every item links to its parent (parent_id), so any output traces back hop by
hop to the run input.
Flow metrics (per step, sliding window)
λ arrivals/s, X throughput/s, Wq queue wait, Ws service time, L items in system, ρ utilization = busy slot-seconds ÷ (slots × window). Little's law (L = λ·W) is shown both ways; the bottleneck is the most-utilized step at ρ ≥ 85% or with a growing queue, with the slot count needed to run at 80%.
Not yet
Containers (steps run as local processes today), multi-host placement, autoscaling from the metrics, auth on the API, a TypeScript step SDK, and log retention / compaction.
Metadata
Release files for pyagentflow 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyagentflow-0.1.0.tar.gz | 30.7 kB | Without provenance | Details for pyagentflow-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyagentflow-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pyagentflow-0.1.0-py3-none-any.whl |
Total release size: 61.3 kB
Release files / pyagentflow-0.1.0.tar.gz
| Download URL | pyagentflow-0.1.0.tar.gz |
|---|---|
| Size | 30.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe48bde2dc88ad0402d56dcae89c1bfac5f0364d3e812df647a184fcb3a062c0
|
|
BLAKE2b-256 checksum How to use checksums |
d3773ec38c822cba6e06f691f0fade4eec42f0297aa2d19d895dcfccbc469815
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyagentflow-0.1.0-py3-none-any.whl
| Download URL | pyagentflow-0.1.0-py3-none-any.whl |
|---|---|
| Size | 30.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b78f5d3797210630604a81c2c02ef7b409ec76ec159394a838049378a82d593
|
|
BLAKE2b-256 checksum How to use checksums |
7bc775bce1c6d12b96b98c975bcfd7307c078dc8d9de7e5e5e51250feb4da10a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pyagentflow 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.