Skip to main content
Pre-release

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 a Patch.
  • Patch — the compiled, validated change-set the runtime applies as one atomic commit (§24).
  • Agent — a thin container declaring consumes/produces; logic lives in Produce.
  • 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 via effects.resume(...) like any agent (§60).

Highlights

  • Deterministic work stays deterministic (§67): calculations over structured data (CSVSourceSpreadsheetCalculation) instead of hallucinated numbers.
  • Claims carry confidence and 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-way merge() with explicit MergeConflict, BranchStore over KV.
  • Replay (§55) — ReplayLLM records 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 ctxloom with graph/context/trace/replay/branch.
  • Sessions & checkpointsSessionStore over FileKVBackend/SQLiteKVBackend for 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

ctxloom-0.1.0rc1.tar.gz (158.4 kB view details)

Uploaded Source

Built Distribution

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

ctxloom-0.1.0rc1-py3-none-any.whl (125.7 kB view details)

Uploaded Python 3

File details

Details for the file ctxloom-0.1.0rc1.tar.gz.

File metadata

  • Download URL: ctxloom-0.1.0rc1.tar.gz
  • Upload date:
  • Size: 158.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.31

File hashes

Hashes for ctxloom-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 7817bc57d3cd09be80ce5e1201dc4d47f34bcf8ddff7561e29eff77f93e0a746
MD5 755beaba9dacceef66fe6aa906a1f68b
BLAKE2b-256 c32aae4845ef1c2e269544434fa4bfad4d63ca55bb4918a6cfe31f1db714752e

See more details on using hashes here.

File details

Details for the file ctxloom-0.1.0rc1-py3-none-any.whl.

File metadata

  • Download URL: ctxloom-0.1.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 125.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.31

File hashes

Hashes for ctxloom-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0ed55627887a37c871eb21368b1e3a41a55d2ae335884f678a39d38f6a6701c
MD5 7f7b501ef399c6263c7ac2e2c1234c1a
BLAKE2b-256 5bd98011c262c6bba8ae36ce14e0657d3757d65418318464b370bfa6411176fc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0rc1 This release

2 files

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