This release is a pre-release and may not be stable for production use.
ctxloom
Reactive, artifact-driven agent runtime.
ctxloom is a framework for building agents as reactive, stateful processes
that transform versioned, typed, provenance-aware artifacts inside an
evolving context — instead of describing execution as a graph.
ARTIFACT CREATED / UPDATED
│
▼
AGENTS REACT ──self.effects──► Effects ──compile──► Patch
▲ │
└──────────────────────────────────────────────────────┘
Context v+1
You describe what data exists, what artifacts exist, what agents can do with
them. The runtime derives execution from state changes: a produce writes
self.effects.create/update/link/ask and returns None; the runtime compiles
the effect set into one atomic Patch and moves the context to the next
version. No explicit graphs, no node pipelines.
Core primitives
- Context — versioned working state, git-like commits,
diff/rollback/merge. - Artifact — a first-class typed object (
Claim,Evidence,Answer, …), not a string blob. - Effects — the produce's authoring surface (
self.effects.create/update/link/ask); the runtime compiles them into aPatch. - Patch — the compiled, validated change-set the runtime applies as one atomic commit (§24).
- Agent — a thin container declaring
consumes/produces; logic lives inProduce. - Source — a retrieval capability. Vector search is one strategy; direct API, keyword, SQL, and filesystem are equally first-class. Embeddings optional.
- Provenance — every derived artifact links back to what produced it
(
Answer —supported_by→ Claim —derived_from→ Evidence —extracted_from→ Doc). - HITL — humans interact through
effects.ask(...)→PendingQuestion, answered viaeffects.resume(...)like any agent (§60).
Highlights
- Deterministic work stays deterministic (§67): calculations over structured data
(
CSVSource→Spreadsheet→Calculation) instead of hallucinated numbers. - Claims carry
confidenceand explicit contradictions (§35–§36), so the model is a reasoning component, never the source of truth. - Observability built in: every run traces agent spans, reads/writes, LLM calls, tokens — SQLite store + web dashboard, exportable to Langfuse/Postgres.
- Budget by runs/time/iterations/tool-calls with replanning on decline.
Also in the box
- Recipes (
ctxloom.recipes) —fan_out_sources,materialize_doc,StatusMachine, keyword scoring (EN/RU stems), and the change→rebuild rollback helpers — pure, LLM-free. - Branching & merge (§39-§40) —
context.branch(), three-waymerge()with explicitMergeConflict,BranchStoreover KV. - Replay (§55) —
ReplayLLMrecords every LLM call and replays a run deterministically; state replay via the CLI. - Evaluation harness (§56) —
ctxloom.eval: metrics over the final state (evidence/claim/provenance/calc/answer), weighted report. - Observability — SQLite trace store + web dashboard (sequence and evidence-graph diagrams), Langfuse/Postgres sinks.
- Viz & CLI — Mermaid
blueprint/context_to_mermaid/trace_to_mermaid;python -m ctxloomwithgraph/context/trace/replay/branch. - Sessions & checkpoints —
SessionStoreoverFileKVBackend/SQLiteKVBackendfor durable chat memory across requests.
Quick start
from pydantic import BaseModel
from ctxloom import (
Agent,
Budget,
Consume,
Context,
Patch,
Produce,
Runtime,
RuntimeResources,
)
from ctxloom.sources import FileSystemSource
class Question(BaseModel):
text: str
class Answer(BaseModel):
text: str
class Echo(Produce[Answer]):
artifact_type = Answer
async def produce(self, context, inputs, event=None):
question = next(a for a in inputs if isinstance(a.data, Question))
self.effects.create(Answer(text=f"echo: {question.data.text}"))
return None
class EchoAgent(Agent):
name = "echo"
consumes = [Consume(Question)]
produces = [Echo()]
ctx = Context(resources=RuntimeResources(sources={"docs": FileSystemSource("./docs")}))
runtime = Runtime(ctx, agents=[EchoAgent()], budget=Budget(max_runs=10))
ctx.create(Question(text="hello")) # agents that consume it react automatically
runtime.run()
You describe artifacts, what agents consume and produce — and the runtime derives
the execution from state changes. Full documentation lives in docs/
in two languages (English & Русский); the design and invariants are in
CONSTITUTION.md; the examples/ ship several full demos and a tutorial ladder.
Examples (in-repo, not shipped)
examples/knowledge— multi-source chat: search → evidence → claim verification → answer, with CSV calculation (CLI + FastAPI/SSE web).examples/research— research agent that goes to the web (WebSource): lazy page fetch → evidence → verified claims → answer with URL provenance.examples/medic-lab— hypothesis laboratory: a question spawns competing hypotheses, each is investigated over an evidence pool, scored by support/contradiction, and ended with an HITL steering + honest report.examples/devops— ops assistant: HITL tool agents + LLM tool router + trace dashboard.examples/repair— budget-aware replanning demo (chat and data are in Russian by design).examples/forklab— deterministic branch & merge demo (§39-§40): two research strategies on their own forks, explicit three-way merge, evaluate on the merged state.examples/llm_ladder— the LLM workflow from simplest to state-changing patches (3 self-contained levels, offline fallbacks, model mode via.env).
Run a demo
uv run python ./examples/llm_ladder/level1.py # the simplest LLM turn (offline too)
uv run python ./examples/repair/web.py # room renovation: plan, estimate, CSV export
uv run python ./examples/devops/web.py # HITL ops assistant + trace dashboard
Documentation
- English docs — the produce contract & mental model, concepts, sources, providers, recipes, patterns, observability, eval, branching, replay, viz/CLI, examples, API reference.
- Русская документация — контракт produce и ментальная модель, концепции, источники, провайдеры, рецепты, паттерны, наблюдаемость, eval, ветвление, replay, viz/CLI, примеры, справочник API.
- Tutorial · llm-ladder — learn the workflow from a single LLM call to linked and lifecycle patches.
Development
uv sync --extra dev --extra web
.venv/bin/python -m pytest
.venv/bin/mypy
.venv/bin/ruff check
License
MIT — see LICENSE.
The full design rationale and invariants live in CONSTITUTION.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctxloom-0.2.0rc1.tar.gz.
File metadata
- Download URL: ctxloom-0.2.0rc1.tar.gz
- Upload date:
- Size: 160.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.5.31
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba815817fda6706c1da2afd82fc2c3a0ee594c4b85021891042a5e209c4f63ec
|
|
| MD5 |
daac9389cddff10cdf676453d00faf78
|
|
| BLAKE2b-256 |
6106a0906d32d62df88a26de6b52f1b0db0d2a6251997fd833cfee72a9e7ad9b
|
File details
Details for the file ctxloom-0.2.0rc1-py3-none-any.whl.
File metadata
- Download URL: ctxloom-0.2.0rc1-py3-none-any.whl
- Upload date:
- Size: 127.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.5.31
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c69e05b8b5abc93f004447bb893d9ca99e7b5a2f0b4014ff5ddea459ed1a9509
|
|
| MD5 |
4148ef4b619269fc86b87359f6b14e8a
|
|
| BLAKE2b-256 |
e50f9e0b391852ba6f81239718ae06d89fec26f4c1d11a09802f883c73964370
|