Skip to main content

reactifact — typed artifacts, reactive steps, auditable state

Agents that can prove their answers. reactifact is a Python runtime for typed, reactive agents: you declare artifacts and steps, the runtime derives the path — no graph to wire. Contracts, scenarios, evals, traces and replay are built in, local-first, with three core dependencies and no API key.

Your types are the graph. Your runs are the receipt.

CI codecov Python PyPI version License: MIT Ask DeepWiki Docs

Is: a Python library (3 core deps) · single-process · typed, versioned artifacts with provenance · deterministic replay · scenarios + evals + traces in the box · optional code-first knowledge base · runs offline, no API key Isn't: a managed platform · a distributed task queue · a pre-built agent/tool marketplace

The three things that matter

  • No graph to draw. @step(reads=Question) -> Answer is the route; a Pipeline binds agents to the artifacts that wake them, and Pipeline.branch handles case routing without edges. The runtime derives execution from which artifacts exist — fan-out, joins, retries and loops are state changes, not edges you maintain.
  • Proof, not logs. Every derived artifact links to its inputs, every answer carries the context hash, and a finished run replays deterministically. “Why did it say that?” is a query, not a guess.
  • The whole loop is built in. Contracts, scenarios, dataset evals, traces, replay and branching live in the same runtime — no second stack for testing or observability.

Sixty seconds, no API key

uvx reactifact demo        # or: uv add reactifact && uv run reactifact demo
uvx reactifact demo --web  # browser: answer, provenance, contracts, traces
reactifact demo — computed, cited, reproducible

question What is the Q2 cloud spend variance, and does policy require approval?
sources  transactions.csv (6 rows) · budget.csv (2 rows) · policy.md

answer   Q2 cloud spend was $45,000 against a $40,000 budget (+12.5%) — exceeds
         the 10% policy threshold. CFO approval is required before the quarter
         is closed.

computed cloud spend $45,000 (2026-04 $12,000, 2026-05 $15,000, 2026-06 $18,000)
policy   threshold 10% → approval required
citations budget.csv, transactions.csv, policy.md

provenance (context.related(answer.id, "supported_by"))
  Answer    → supported_by → Variance, policy.md
  Variance  → calculated_from → Spend, budget.csv
  Spend     → calculated_from → transactions.csv

context sha256 ffeca1bb18cbc34749d3b5bdb40d85677b1ac33d47fb1160f6c89053694b2783
re-run         identical ✓

Three @step functions, none of which imports another by name: they declare what they consume and produce, and the runtime derives the order from state. The figures come from plain Python, and both the answer and the numbers carry the hash of the exact state that produced them. The whole demo lives in reactifact/demo.py.

demo --web serves the same run at / with the provenance graph, plus /contracts, /traces, /api/demo and /docs. No API key, in-memory traces.

One pipeline, four surfaces

The same typed pipeline runs as a library, CLI, HTTP service, daemon or MCP tool. Web and MCP are adapters, not the core.

from reactifact import Agent, Application, Pipeline, RunConfig

pipeline = Pipeline(seed_type=Question, answer_type=Answer, name="qa")
pipeline.bind(Agent("answer", steps=[...]), consumes=[Question])
app = Application(pipeline, config=RunConfig(traces=True))

app.pipeline                             # the Pipeline definition
app.run(seed)                            # library
http = app.http()                        # /run, /stream, /docs, /contracts, /traces

Application(pipeline) validates the wiring and freezes it; app.pipeline remains the inspectable definition (validate(), describe(), mermaid()).

Need ordered barriers? Wrap the wiring in pipeline.stage(...); the same Pipeline then carries .stages and a staged turn schedule.

Surface One line
CLI reactifact run app:pipeline "hello"
HTTP app.http() — typed /run, SSE /stream, OpenAPI /docs
Daemon app.daemon(seed_source=next_tick, interval=60).serve()
MCP create_mcp_server([app.as_tool()])

Need sessions and history? app.chat(store="sessions.db").http() adds /chat/stream plus /runs/{id}; pass ChatRoutes(invoke="/chat", history="/chat/history", clear="/chat/clear") for the DEVOPS-style paths.

HITL is just the next chat turn

Approval is a PendingQuestion, not a separate service. Ask from a step, let Chat report waiting, and the next user message resumes the same pipeline:

import asyncio

from reactifact import Application, Human, PendingQuestion, Pipeline, step


@step(reads=Question, produces=PendingQuestion)
def approve(question: Question, human: Human) -> None:
    human.ask("Deploy to production?", kind="approval")


pipeline = Pipeline(seed_type=Question, answer_type=Answer)
pipeline.mount([approve])          # plus the rest of the pipeline


async def main() -> None:
    app = Application(pipeline)
    chat = app.chat(
        store="sessions.db",
        resume_pending=True,       # "yes" answers the pending question
    )

    await chat.invoke("ship it")   # {"waiting": True, "question": {...}}
    await chat.invoke("yes")       # same PendingQuestion resumed; pipeline continues


asyncio.run(main())

The message payload carries the structured question (id, kind, schema, notes), and Chat.history shows a waiting: true message across reloads. There is no /hitl endpoint: Chat.http() keeps the normal /chat, /chat/stream and history contract, so the answer is just another turn. Pipeline stays stateless; when it needs a person, wrap it in Chat.

For free-text answers, spread the ready approval flow instead of naming its internal steps:

from reactifact import Application
from reactifact.recipes import ApprovalFlow

pipeline = Pipeline(seed_type=Question, answer_type=Answer)
pipeline.mount([approve, *ApprovalFlow(steps=[deploy])])
chat = Application(pipeline).chat()

ApprovalFlow includes a deterministic yes/no parser plus an optional LLM fallback; ApprovalPolicy is the single place for custom prompts, few-shot examples, domain vocabulary and the confidence threshold. ApprovalDecision records policy_hash, and downstream code still checks decision.allows(min_confidence=0.8) — ambiguity never auto-approves.

LLM calls are provider methods now: a step takes llm: LLMProvider and calls await llm.structured(Schema, user=...) (or llm.reply, llm.structured_json, llm.chat). The function helpers (structured_llm(llm, ...), llm_reply(llm, ...)) remain for callers that prefer a free function.

Define a step, run it

from pydantic import BaseModel
from reactifact import Agent, Application, Pipeline, step

class Question(BaseModel):
    text: str

class Answer(BaseModel):
    text: str

@step                                     # reads/produces inferred from the signature
def answer(question: Question) -> Answer:
    return Answer(text=f"you asked: {question.text}")

pipeline = Pipeline(seed_type=Question, answer_type=Answer, name="qa")
pipeline.bind(Agent("answer", steps=[answer]), consumes=[Question])
app = Application(pipeline)

result = app.run(
    Question(text="why did cloud spend jump in Q2?")
)

print(result.latest(Answer).data.text)
print(result.sources(result.latest(Answer)))   # citations, as a query
print(result.hash)                              # reproducible fingerprint

Pipeline owns both the wiring and the definition (agents, seed/answer types), and Application owns resources and execution and builds a fresh Context + runtime per run. The CLI is the same pipeline:

reactifact run app:pipeline "why did cloud spend jump in Q2?"

run writes .reactifact/traces.db by default; reactifact trace renders the latest run. Use --no-trace to skip it.

The loop is built in

Start with a contract, test the agent, gate a dataset, then inspect the run that actually happened:

Stage Built in
Design pipeline.validate() / .describe(), contracts page, reactifact validate
Test ScenarioLab, @scenario, tool faults, record/replay, check --scenarios
Evaluate Dataset + deterministic metrics + LLM judge, check --evals, online eval
Observe typed TraceStore, spans, reads/writes, provenance, /traces dashboard
Debug reactifact trace, replay, branch, diff, context hashes

One CI command:

reactifact check app.pipeline:pipeline \
  --scenarios app.scenarios \
  --evals evals/qa.json \
  --overall 0.8

It runs contracts, scenarios and dataset evals in one gate and exits non-zero when any stage fails. The same loop is available as code (pipeline.validate(), ScenarioLab, evaluate) — the CLI is not a separate implementation.

What makes it different

Traditional agent (LangGraph / CrewAI / LangChain) reactifact
A program follows a graph / plan Agents react to state changes
Messages and dicts Typed, versioned artifacts (Claim, Evidence, Answer)
Orchestration is explicit wiring Orchestration falls out of the state
A unit of work returns a change object A step returns typed artifacts; the runtime compiles them
Retries/rollback are manual Context is git-like versioned (diff, rollback, branch, merge)
“Who produced this?” is lost Provenance links every derived artifact to its inputs
The model guesses the numbers Calculations are calculated — the LLM reasons, Python computes
Tracing needs a SaaS add-on Native trace store (SQLite + dashboard), exportable
Testing and evals need another stack Scenarios + evals + traces + replay in one runtime
A web framework is the app One pipeline, then CLI / HTTP / daemon / MCP adapters
Pulls in a framework's dependency tree 3 core deps: pydantic, httpx, python-dotenv

Full breakdown, including where reactifact is not the right choice: docs/en/comparison.md.

Who this is for

  • Knowledge assistants over mixed sources. One question spans Confluence, a spreadsheet and a web page; the next spans a different subset. You declare what artifacts exist and what agents can do with them, and the runtime derives the path. Figures are computed, answers cite their sources, and a run replays to the same hash.
  • Multi-step agents that don’t fit one graph. Search, verification, calculation, human approval and outbound actions compose by type; the next question can take a different subset without rewiring.
  • Teams that need audit and regression gates. Typed contracts, scenarios, dataset evals, provenance and deterministic replay are first-class, not a bolt-on.

Not for a fixed A → B → C pipeline. There a plain function or LangGraph is shorter and just as correct.

Not a connector library or a managed platform. If you need dozens of managed SaaS sources, LlamaIndex is the better tool. reactifact’s Source layer is deliberately small and code-first: filesystem, CSV, embeddings, web, MCP.

Proof in the repo

examples/fintech_audit — a transactions CSV, a budget CSV and a policy doc, no API key. The model never produces the number; plain Python does, and the answer links to its evidence:

cloud spend:        $45,000   (2026-04 $12k, 2026-05 $15k, 2026-06 $18k)
variance vs budget: +12.5%    budget $40,000, policy threshold 10% → over
answer:             Q2 cloud spend was $45,000 against a $40,000 budget (+12.5%) — ...
citations:          budget.csv, transactions.csv, policy.md
audit:              Answer —supported_by→ {Variance, Spend, Table, Policy}
context sha256:     24449f6f…

fintech_audit demo: the variance, the answer, and the reproducible context hash — a second run prints the same hash.

A harder, multi-source version — docs plus a CSV, computed sum, verified answer, no key required — is examples/knowledge:

CLI demo: asking "how much does gpu cost in total?" — search, compute, verify, answer with sources.

Two strategies explore on separate forks and merge cleanly; if they edit the same artifact differently, reactifact raises MergeConflict instead of guessing:

forklab demo: two strategies investigate on separate forks and merge; a conflicting edit raises MergeConflict, then re-merges under an explicit policy.

Optional knowledge layer

If the agent needs a corpus, reactifact.knowledge is a code-first ingestion layer — Connector → RawDocument → Document → Chunk → Index — with incremental DocStore state, BM25 + RRF hybrid retrieval, ACL-aware reconcile, and MemoryIndex / SqliteIndex / QdrantIndex / PgVectorIndex (plus optional ChromaIndex). It reuses the core EmbeddingProvider; IndexSource / IngestStep are the only bridges into Source / Step.

from reactifact.knowledge import KnowledgePipeline, SectionsChunker, SqliteIndex

pipeline = KnowledgePipeline(connector, chunker=SectionsChunker(), index=SqliteIndex(".reactifact/kb.db"))
await pipeline.run(incremental=True)
hits = await pipeline.query("how do I install it?", top_k=5, hybrid=True)

No YAML pipeline, CLI or plugin registry. See Knowledge base (or по-русски).

In the box

  • Typed contracts — @step, Consume, When, Scope, joins and correlation; Pipeline.bind/Binding own reactions, Pipeline.branch owns mutually exclusive cases, and validate_contracts catches missing producers before a run.
  • Atomic state — Context with git-like commits, diff, rollback, branch, three-way merge; artifacts are versioned by content hash.
  • Provenance — Answer —supported_by→ Claim —derived_from→ Evidence — extracted_from→ Doc; walk it with context.related(...).
  • HITL and outbox — human.ask(...) → PendingQuestion; outbox.act(...) → PendingAction, delivered once after commit by the app runtime (app.runtime(ctx, dispatcher=...)).
  • Traces and replay — SQLite trace store + dashboard, portable Markdown/HTML/JSON reports, ReplayLLM, deterministic context_hash.
  • Scenarios and evals — seeded scenarios, tool/resource faults, record/replay, assertions, golden runs, dataset metrics, judges and CI gates.
  • Budgets and lifecycle — hard max_seconds deadlines, stop at a generation boundary, readiness via active_runs() / in_flight.
  • Sessions and chat — Chat with SessionStore, SSE, history, memory policies, per-turn resources and Chat.http().
  • Transports — CLI, FastAPI (/docs, /contracts, /traces), daemon, MCP both ways (create_mcp_server, mcp_stdio_tools, mcp_http_tools).
  • Agent Skills — bundled instructions for Claude Code, Cursor, Codex, Copilot: reactifact, reactifact-agents, reactifact-llm, reactifact-rag, reactifact-testing, reactifact-eval, reactifact-observability, reactifact-from-langchain.

Start here

Minimal agent, no web

uvx reactifact new agent my-agent
cd my-agent && uv sync
uv run reactifact run main:pipeline "hello"
uv run reactifact trace

Production HTTP shell

uvx reactifact new app my-app
cd my-app && uv sync --extra dev
cp .env.example .env
uv run reactifact dev

Existing project

uv add reactifact
uv run reactifact skills install   # teach your coding agent the model

Then read Quickstart or Concepts.

Examples (in-repo, not shipped)

  • starter_app — copy-pasteable FastAPI app: structured call, RAG, tools, session chat (Application(CHAT_PIPELINE).chat()).
  • knowledge — multi-source chat: search → evidence → claim verification → answer, with CSV calculation.
  • knowledge_base — real ingestion: connector → chunks → SQLite/Qdrant, incremental state, hybrid query.
  • medic_lab — hypothesis laboratory: competing hypotheses scored, HITL steering, honest report.
  • devops — HITL tool agents + LLM tool router + trace dashboard.
  • code_review — deterministic-first diff review: rules + optional LLM findings → linked report.
  • repair — budget-aware replanning (chat/data in Russian by design).
  • chat — minimal offline single-model multi-turn conversation.
  • forklab — deterministic branch & merge.
  • fintech_audit — auditable, reproducible CSV answer with content hashes and provenance.
  • approval_gate — HITL approval in one chat: ask, interpret free text, deploy only on ApprovalDecision.allows().

Documentation

  • English · Русский — concepts, sources, providers, recipes, patterns, observability, eval, branching, replay, viz/CLI, API.
  • Quickstart — demo, CLI, HTTP, daemon and MCP in a few lines.
  • Migrating — from LangGraph / CrewAI / LlamaIndex / plain Python: concept map, port-one-node, interop, checklist.
  • Why reactifact — why the graph is derived rather than drawn, why determinism, why provenance.
  • Comparison — reactifact vs LangGraph/CrewAI, feature by feature, and when not to use reactifact.
  • docs/constitution.md — the design rationale and invariants.
  • Roadmap — what’s next, and what’s deliberately out of scope.

Development

uv sync --extra dev --extra web
.venv/bin/python -m pytest
.venv/bin/mypy
.venv/bin/ruff check
npx --yes pyright

Status & contributing

Active, pre-1.0 — the API is stabilizing and 1.0 will freeze it (see the roadmap); releases follow Keep a Changelog. Questions and design discussion live in GitHub Discussions; a star, or a good first issue, helps more than you’d think.

License

MIT — see LICENSE.

Metadata

Release files for reactifact 0.30.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 reactifact 0.30.0
File Size Uploaded Provenance Actions
reactifact-0.30.0.tar.gz 921.3 kB Without provenance Details for reactifact-0.30.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for reactifact 0.30.0
File Interpreter ABI Platform Actions
reactifact-0.30.0-py3-none-any.whl Python 3 none any Details for reactifact-0.30.0-py3-none-any.whl

Total release size: 1.7 MB

Release files / reactifact-0.30.0.tar.gz

Download URL reactifact-0.30.0.tar.gz
Size 921.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7d139c655789494c91351426d73b5bd19fd09448f0d33e04995336d46548cda5
BLAKE2b-256 checksum
How to use checksums
575fb6f83e7fbfcc1163d42d30640c7f84e2e080fcddf5f3f46542a3bc2ac1df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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 / reactifact-0.30.0-py3-none-any.whl

Download URL reactifact-0.30.0-py3-none-any.whl
Size 805.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61c91cb95025545f091403421d5b54368336c28a6215c2dd02b5ff839d2389e8
BLAKE2b-256 checksum
How to use checksums
8406c6315b5dd4771534898c96cda7426d6286198b96fe5bd6adffe56ff5a949
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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 reactifact 0.30.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.

Release history Release notifications | RSS feed

This release

0.30.0 This release

2 release files No provenance

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