by Cyrax321
Provides verifiable semantic checkpoints, an idempotent action ledger, and a hash‑chained tamper‑evident event log for long‑running AI agents, exposed via a deny‑by‑default MCP server.
Continuum delivers a reliability layer for autonomous AI agents that execute hundreds of LLM calls and external side effects. Instead of persisting raw conversation logs, it records compact, versioned semantic checkpoints and an append‑only, hash‑chained event log. Each checkpoint component is independently re‑validated against the current environment before a resumed run, guaranteeing that stale or unsafe state never drives further actions.
git clone https://github.com/Cyrax321/CONTINUUM.git
cd CONTINUUM
uv venv
uv pip install -e "[dev]" # core library, CLI, test tooling
uv pip install -e "[mcp]" # adds the MCP server (optional)
continuum --help # list commands
continuum-mcp # start the MCP server (deny‑by‑default)
from continuum import EventType, Run, SQLiteStorage, project
store = SQLiteStorage("agent.db")
store.create_run(Run(run_id="run_001", goal="Analyze PDFs"))
store.append_event("run_001", EventType.RUN_STARTED, {"goal": "Analyze PDFs", "total": 100})
# ... agent does work, appends events ...
state = project("run_001", store.read_events("run_001"))
print(state.progress.completed) # shows already‑done work after a crash
print(store.verify_events("run_001").ok) # True if the hash chain is intact
continuum_validate, continuum_resume, etc.) over stdio. Mutating tools require the caller to be allow‑listed via CONTINUUM_MCP_MUTATING_CLIENTS or a shared secret token.RESUME, REPAIR_AND_RESUME, ROLLBACK, WAIT, REQUEST_HUMAN, ABORT, REPLAN).Q: Do I need to use the MCP server? A: No. The core library and CLI work entirely offline. The MCP server is an optional add‑on for agents that prefer to interact over JSON‑RPC instead of importing the library directly.
Q: How does Continuum prevent duplicate side effects?
A: The Action Ledger stores a deterministic business key for each external call. When an agent attempts to claim the same key twice, the ledger rejects the claim and returns an UNCERTAIN status, requiring human confirmation.
Q: What happens if the SQLite database is corrupted after a hard kill?
A: On server start‑up the MCP process detects orphaned -wal/-shm files and performs a single‑retry self‑healing routine that clears the stale side‑car before reopening the DB.
Q: Can I run Continuum with a cloud database? A: Currently only the SQLite backend is shipped. A PostgreSQL‑based FastAPI cloud API is planned for Phase 13.
Q: How do I allow an external client to mutate state via MCP?
A: Set CONTINUUM_MCP_MUTATING_CLIENTS to a comma‑separated list of allowed client identifiers, or provide a shared secret via CONTINUUM_MCP_TOKEN and include it in the _meta.authToken field of the client’s initialize handshake.
Q: Are the framework adapters production‑ready? A: The generic Python adapter has full crash‑and‑resume coverage. The OpenAI Agents SDK, LangGraph, and LangChain adapters are functional but marked experimental until their integration test matrix matches the generic facade.
Why · Quick Start · How it works · Features · Security Extension · Empirical Verification · MCP Integration · Framework Integration · Core Concepts · Architecture · API and CLI · Roadmap · What CONTINUUM Is Not · Related work · Status and limitations · Contributing · License
Modern AI agents run long tasks (hundreds of LLM calls, tool invocations, file and database writes). When they crash, the usual response is to replay everything from scratch, which duplicates work, duplicates side effects, wastes tokens, and loses decisions.
CONTINUUM asks a narrower, harder question: can an agent resume from a compact semantic representation of its task state while independently verifying that state is still valid in the current environment? It is not a generic agent framework, a memory system, or a workflow engine. Its differentiator is three-part:
Not published to PyPI yet. Install from a clone:
uv venv
uv pip install -e ".[dev]" # library, CLI, and test tooling
uv pip install -e ".[mcp]" # adds the MCP server (optional)
Two entrypoints are installed: continuum (CLI) and continuum-mcp (MCP server). The core library and CLI use only the standard library; the mcp extra is required solely for the server.
Minimal example, record and recover:
from continuum import EventType, Run, SQLiteStorage, project
store = SQLiteStorage("agent.db")
store.create_run(Run(run_id="run_4821", goal="Analyze 10,000 documents"))
store.append_event("run_4821", EventType.RUN_STARTED, {"goal": "Analyze 10,000 documents", "total": 10_000})
for i, doc in enumerate(documents):
analyze(doc)
store.append_event("run_4821", EventType.WORK_COMPLETED, {"doc": i})
# After a crash, a new process picks up exactly where it stopped:
state = project("run_4821", store.read_events("run_4821"))
print(state.progress.completed) # already done, not repeated
print(store.verify_events("run_4821").ok) # True, chain intact after the crash
Run the proof yourself. These scripts are the primary evidence, verified end to end rather than described:
python examples/crash_recovery_agent.py # real process kill, real side effect
python examples/context_compaction.py # transcript lost, checkpoint survives
python examples/model_switch.py # Model A dies, Model B resumes safely
python scripts/mcp_smoke.py # real subprocess, real JSON-RPC traffic
The e2e-autonomy-test/ kit scripts a real invoice-batch task, a hard-kill mid-run, and a fresh resume session, then scores the outbox, ledger, and event chain out of band. Run 1 scored 7/7 mechanics against a real Claude Code session, and the autonomy half was observed (an agent used the tools unprompted, refused to re-send verified invoices, and surfaced the request_human verdict). Full walkthrough and the open questions are in references/quickstart.md and references/e2e.md.
CONTINUUM separates LLM context (temporary) from durable task state (permanent). Instead of saving conversation history, it constructs a semantic checkpoint, the minimum verified information required to continue.
The detailed explanation, the projection model, and the recovery context are in references/architecture.md.
| Capability | What it gives you |
|---|---|
| Semantic checkpoints | Compact, versioned, inspectable state, not a transcript dump |
| Idempotent action ledger | Refuses duplicate external side effects; surfaces uncertain ones for reconciliation |
| Environment revalidation | Every checkpoint component verified against the current world before resume |
| Provenance-aware state | Agent-reported progress is marked REQUIRES_REVIEW, never self-certifying |
| Recovery engine | Seven recovery modes with a deterministic, sealed next-action contract |
| Deny-by-default MCP server | Nine tools, read-only/mutating split, caller allowlist |
| Framework adapters | Generic Python, OpenAI Agents SDK, LangGraph, and LangChain integrations |
| Secure planning loop | Two-signal observation verification escalates high-risk branches to REQUIRES_REVIEW |
| Periodic revalidation | Environment re-checked on a schedule, catching mid-run drift within one cycle |
| Tamper-evident log | Hash-chained event log (32 event types) with integrity verification |
CONTINUUM adds two additive security extensions on top of the existing recovery and checkpoint substrate. They do not change resume, replay, or the existing crash-time revalidation path.
verified / unverified / contested). A plan branch gated on an
observation is escalated to REQUIRES_REVIEW when it is high risk and the
observation is not fully verified, or when an environment observation is
contested. Verification decisions and branch resolutions are appended to the
ledger as PERCEPTION_OBSERVED and BRANCH_RESOLVED events.See docs/PROBLEM.md for the problem statement and honest scope, docs/RESULTS.md for results, and STATUS.md for the implementation status.
CONTINUUM is verified not just with mock unit tests, but against real LLM agents, live protocol boundaries, and hard process crashes.
SIGKILL hard process terminations. Resumed sessions cleanly queried continuum_resume, routed side effects through the two-phase intercept/complete ledger, and scored 7/7 on mechanics. The agent refused to duplicate verified outbox writes and respected the request_human safety verdict.target vs outbox_file, and relative vs absolute paths). This prompted the implementation of canonical path normalization and token-based fallback deduplication in ActionLedger.claim().@modelcontextprotocol/inspector in --cli mode driving real subprocess JSON-RPC 2.0 lifecycles across process deaths.CONTINUUM_MCP_MUTATING_CLIENTS), while read-only tools (validate, resume, list_actions) remain ungated.Origin.EXTERNAL_AGENT provenance and degraded to REQUIRES_REVIEW (safe: false), preventing an agent from validating its own unverified work.kill -9) can leave SQLite in an inconsistent state with orphaned -wal and -shm sidecars. The MCP server startup incorporates single-retry self-healing that clears stale sidecars and reopens cleanly.hypothesis property-based, and concurrency tests).continuum benchmark executes in-process recovery benchmarks across five scenarios (process_crash, dataset_change, unknown_side_effect, partial_completion, early_crash), proving 0 duplicate work, 0 duplicate side effects, and automatic detection of stale environment dependencies.CONTINUUM ships an MCP server so an agent can record progress, checkpoint, and route external side effects through the ledger without embedding the library:
uv pip install -e ".[mcp]"
CONTINUUM_MCP_MUTATING_CLIENTS=your-client-name continuum-mcp
Ten tools over stdio. Three are read-only (continuum_validate, continuum_resume, continuum_list_actions); seven mutate. Side effects are two-phase (claim, perform, complete), and mutating tools deny by default behind an allowlist. Agent-reported state is recorded with Origin.EXTERNAL_AGENT provenance and marked REQUIRES_REVIEW. Verification details, including crash recovery at startup and the end to end Claude Code test, are in references/mcp.md. The authentication limitation is covered in references/architecture.md (MCP server and Security sections), and the MCP narrative is in references/quickstart.md.
CONTINUUM plugs into agent frameworks without becoming one. Four adapters ship in src/continuum/adapters/ (one in-process facade plus three framework integrations), all optional installs so the core stays standard-library-only:
| Adapter | Class | Notes |
|---|---|---|
| Generic Python agent | GenericAgentAdapter |
In-process facade; writes trusted (Origin.DETERMINISTIC) state. |
| OpenAI Agents SDK | OpenAIAgentAdapter |
Experimental. Hooks ToolContext / RunHooks; optional openai-agents. |
| LangGraph | LangGraphAgentAdapter |
Experimental. Wraps a StateGraph; optional langgraph. |
| LangChain | LangChainAgentAdapter |
Experimental. Drops checkpoint_node into an LCEL Runnable pipeline and the create_agent tool-calling loop; optional langchain. |
Each adapter records progress and side effects through the ledger and routes external effects through the two-phase intercept/complete protocol. The framework adapters are newer than the generic facade, but each now has end-to-end integration tests (tests/test_integration_langgraph.py, tests/test_integration_langchain.py, and tests/test_integration_langchain_agent.py for a real create_agent tool-calling loop) covering checkpoint durability, exactly-once side effects, and crash-after-checkpoint resume. All three framework adapters (LangChain, LangGraph, OpenAI Agents SDK) have now
been driven against a live OpenRouter model (examples/langchain_real_llm.py,
examples/langgraph_real_llm.py, examples/openai_real_llm.py; recorded in
STATUS.md), where the runs surfaced and then closed an LLM argument-drift dedup gap
via an explicit idempotency key and two OpenAI-adapter schema/context bugs. Each
adapter also has a examples/*_real_llm_crash.py harness that proves the
hard-crash contract: a mid-side-effect os._exit(137) leaves the side effect
uncertain and blocks resume until a human reconciles it. examples/multitool_real_llm.py
is a richer live demo where one prompt orchestrates lookup, notify, and ticket tools
through the LangGraph adapter, showing exactly-once survives the model's argument
drift. Treat them as experimental until their adapter-specific tests cover the full
crash and resume matrix. Full usage, with runnable examples for every adapter, is in
references/adapters.md.
All three framework adapters were driven against a live gpt-4o-mini through
OpenRouter (key from OPENROUTER_API_KEY, never written to disk). Each was proven
two ways: a soft resume (exactly-once side effect across a second clean invocation)
and a hard crash (os._exit(137) mid-side-effect, then a fresh process asserts the
run is blocked as uncertain). A richer examples/multitool_real_llm.py demo has one
prompt orchestrate lookup_order + notify_customer + create_ticket through the
LangGraph adapter.
| Adapter | Soft resume (exactly-once) | Hard crash (resume blocked) |
|---|---|---|
| LangChain | PASS, 1 side effect, resume safe |
PASS, request_human, 1 uncertain |
| OpenAI SDK | PASS, 1 side effect, request_human* |
PASS, request_human, 1 uncertain |
| LangGraph | PASS, 1 side effect, resume safe |
PASS, request_human, 1 uncertain |
* The OpenAI adapter yields request_human even on a clean soft resume because it
records Origin.EXTERNAL_AGENT: an agent must not self-certify its own unverified
work. That is expected and safe. LangChain and LangGraph use Origin.DETERMINISTIC
and resume cleanly.
Two OpenAI-adapter bugs that only surface with a real model were found and fixed:
the tool JSON schema was emitted with no type key (OpenRouter rejected it), and the
context parameter was dropped from the inspectable signature, which bypassed
interception and let the side effect fire twice. The live runs also confirmed the
idempotency lesson: a stable business key (for example ticket:O-9) is required,
because a key derived from the model's rendered arguments does not dedupe the model's
argument drift and produced a duplicate ticket. Full run logs are in STATUS.md.
State reported over MCP, or through the OpenAI adapter, is recorded with Origin.EXTERNAL_AGENT provenance, which the validator marks REQUIRES_REVIEW. That is intentional: an agent must not validate its own unverified work. The consequence is that such runs resolve to request_human on continuum resume until a human has eyeballed them.
Runs started through the LangGraph or LangChain adapter use Origin.DETERMINISTIC provenance (the adapter is the orchestrator starting the run on CONTINUUM's behalf), so a consistent run resumes (RESUME) without a human in the loop.
To clear that review and resume, confirm the run as the operator:
continuum confirm <run_id> # records REVIEW_CONFIRMED, then re-assesses
continuum resume <run_id> # now reports RESUME
Over MCP the equivalent is the continuum_confirm tool followed by continuum_resume. Confirmation is a one-time, human-attested event; it is the escape hatch for the self-certification safety so an externally-driven run is never permanently stuck.
The deep reference for each concept lives in references/concepts.md.
RESUME, REPAIR_AND_RESUME, ROLLBACK, WAIT, REQUEST_HUMAN, ABORT (plus REPLAN).The system is built on immutable Pydantic v2 models with a cryptographic hash chain. State is projected from an append-only event log by a pure fold, not stored and mutated. The full reference, including the data model, event log, projection, extraction, versioning, durable storage, checkpointing, recovery context, state validation, action ledger, recovery engine, and security model, is in references/architecture.md. A complete system diagram and enumerated reference (tools, recovery modes, policies, reconcilers) is in references/architecture-diagram.md. The project structure and module map are in references/architecture.md.
Key guarantees: append-only events, atomic sequence allocation, durability on append_event return, write races fail loudly, and corruption is refused rather than returned.
Python surface (EventType, Run, SQLiteStorage, diff_states, project) and the adapter API are documented with runnable examples in references/api.md. The CLI is the same surface in shell form:
continuum runs # list runs
continuum inspect <run_id> # semantic state
continuum validate <run_id> --env dataset=v4 # validate, read-only
continuum resume <run_id> --env dataset=v4 # recovery decision + contract
continuum checkpoint <run_id> # force a checkpoint, mutates
continuum actions <run_id> # external side effects
continuum show-contract <run_id> # the machine-readable contract
Every command accepts --json, and the read-only commands never write, so they are safe against a live database while an agent is mid-run. Exit codes are a safety contract (only a verified-safe run exits 0). The full command list, exit-code table, and state-diff output are in references/cli.md.
| Phase | Component | Status |
|---|---|---|
| 1-11 | Data models, semantic state, persistence, checkpointing, validation, action ledger, recovery engine, CLI, crash-recovery examples, environment snapshots/diffs, framework adapters | Complete |
| 12 | Benchmark suite (CONTINUUM-Bench) | Complete (minimal harness) |
| 13 | Cloud API (FastAPI + PostgreSQL) | Planned |
| 14 | Dashboard | Planned |
Beyond the original plan: the MCP server, MCP authorization layer, provenance and anti-self-certification, community files, schema versioning, and a bounded recovery context are shipped. The design for CONTINUUM-Bench is in references/bench.md. See STATUS.md for the verified-vs-believed breakdown and open correctness bugs.
| Not this | This instead |
|---|---|
| An LLM | A reliability layer for agents that use LLMs |
| An agent framework | A recovery layer that plugs into any framework |
| A vector database | Structured semantic state, not embeddings |
| A RAG system | Verified checkpoints, not retrieval-augmented memory |
| A workflow engine | A recovery layer, not an orchestrator |
The core abstraction: semantic state + environment validation + action reconciliation = safe recovery.
CONTINUUM sits at the overlap of durable execution, idempotent side-effect tracking, and crash recovery for LLM agents. The surrounding literature is mostly engineering writing, with a few recent preprints that examine the same failure modes directly.
COMPENSATED action state and dependency-safe repair (saga pattern).Recent preprints that measure or model the same reliability gaps CONTINUUM targets (all arXiv links verified live):
CONTINUUM_MCP_TOKEN is set, the server refuses every mutating tool unless the caller presents that shared secret in the initialize handshake's _meta.authToken. Without it, authorization is by declared identity only (the historical default, preserved for local single-user use). Tracked as #1.GenericAgentAdapter for production recovery until their adapter-specific tests cover the full recovery matrix.REQUIRES_REVIEW, continuum resume returns request_human until a human runs continuum confirm <run_id> (or the MCP continuum_confirm tool). This is by design, not a bug; see Framework Integration.For a full account of what is verified, believed, and neither, see STATUS.md. The current set of open correctness bugs (a 2026-08-12 code audit) is tracked there.
Contributions are welcome. This project is open source under Apache 2.0 and deliberately built to be extended: by researchers validating the recovery semantics, by engineers porting the ledger or MCP server to other frameworks or languages, and by anyone turning the planned roadmap into reality. A good place to start is the good first issue label on the issue tracker, or the open correctness bugs listed in STATUS.md.
Open an issue before submitting large PRs. See CONTRIBUTING.md for the full contribution guide, including the Code of Conduct.
Apache 2.0 - see LICENSE.
Deep reference material:
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
An MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.
by zylon-ai
Provides an open-source API layer that enables local OpenAI‑compatible models to be used for production AI applications, offering standardized message handling, document ingestion, retrieval‑augmented generation, tool integration, and MCP connectivity.
by danny-avila
Provides a self‑hosted ChatGPT‑style interface supporting numerous AI models, agents, code interpreter, image generation, multimodal interactions, and secure multi‑user authentication.
by block
Automates engineering tasks on local machines, executing code, building projects, debugging, orchestrating workflows, and interacting with external APIs using any LLM.
by RooCodeInc
Provides an autonomous AI coding partner inside the editor that can understand natural language, manipulate files, run commands, browse the web, and be customized via modes and instructions.
by pydantic
A Python framework that enables seamless integration of Pydantic validation with large language models, providing type‑safe agent construction, dependency injection, and structured output handling.
by mcp-use
A Python SDK that simplifies interaction with MCP servers and enables developers to create custom agents with tool‑calling capabilities.
by lastmile-ai
Build effective agents using Model Context Protocol and simple, composable workflow patterns.
by Klavis-AI
Provides production‑ready MCP servers and a hosted service for integrating AI applications with over 50 third‑party services via standardized APIs, OAuth, and easy Docker or hosted deployment.