Skip to main content

cuaderna

A durable, replayable execution engine for AI agents, written in Python.

A cuaderna is a rib of a ship's hull: the structure underneath that holds everything else up.

What it is for

An agent solves a task in many steps: it reads files, calls a model, runs commands, calls the model again. When the process dies halfway, the work and the money spent on it are gone, and nobody can say afterwards what the agent did or why.

Cuaderna is the layer underneath that code. It is not an agent and it is not a framework for writing agents. You keep writing your agent as plain Python and mark the steps that matter. Every step is written to a journal with its result as soon as it finishes, and everything else is built on that journal:

  • Resume after a crash. A run that dies picks up after the last recorded step. A recorded step is never executed again.
  • Replay. Any past run can be walked through step by step with the model responses it got at the time, without calling the model. A recorded run becomes a test.
  • Cost limits. Every model call a step annotates with its usage is stored with what it cost; a call that cannot be priced is marked unknown. A run has a budget and stops before its next step once the recorded cost reaches it, without losing what it did: give it a higher budget and it continues. Only costs a step reports are counted, and the call in flight can go over.
  • Permissions and audit. Every step call of a run that has a policy is checked against it before the step runs, a person can be asked first, and the journal records what ran under which rule and the name the approver gave; names are claims, not verified identities. The policy is not a sandbox. Running tools isolated from the machine is not built yet.
  • Fault injection. Recorded runs are used to test how an agent reacts to a tool that fails or a malformed response. Not built yet.

A first run

import asyncio

import cuaderna


@cuaderna.step(max_attempts=3)
async def ask_model(prompt: str) -> str: ...  # call whichever SDK you use


@cuaderna.step
def run_tests(repo: str) -> bool: ...  # a plain function runs in a thread


@cuaderna.run
async def fix_tests(repo: str) -> int:
    rounds = 0
    while not await run_tests(repo):
        await ask_model(f"fix the tests in {repo}")
        rounds += 1
    return rounds


async def main() -> None:
    engine = cuaderna.Engine("cuaderna.db")
    print(await engine.execute("fix-123", fix_tests, "path/to/repo"))
    await engine.close()


asyncio.run(main())

Kill it while it works and run it again: it continues from the last step it recorded. Run it once more after it finished and it returns the stored result without executing anything.

See it

examples/fix_tests is a complete agent that fixes the failing tests of a small repo. The run page is a static page that shows a recorded run of it: one process killed during its model call, a second one stopped by its budget, and a third one that finished the run, with what each step received, returned and cost.

Documentation

  • Writing steps and runs: steps, retries, resume, replay, exporting a run as a test case, and what the journal holds.
  • Cost and budgets: the price table, the cost of each model call, stopping a run at a budget, and what the same run would have cost on another model.
  • Permissions and audit: the policy file, denials, asking a person, the audit entries and checking the journal with verify.
  • The run page: looking at a recorded run in the browser.
  • Security: what cuaderna protects and what it does not.

Install

pip install git+https://github.com/cuaderna/cuaderna

Requires Python 3.12 or newer. The project is in early development and the package on PyPI is still a placeholder, so for now it is installed from this repository.

Contributing

See CONTRIBUTING.md for setup and the checks to run. Issues and questions are welcome.

License

Apache-2.0. See LICENSE.

Metadata

Release files for cuaderna 0.1.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 cuaderna 0.1.0
File Size Uploaded Provenance Actions
cuaderna-0.1.0.tar.gz 74.9 kB With provenance Details for cuaderna-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 119.3 kB

Release files / cuaderna-0.1.0.tar.gz

Download URL cuaderna-0.1.0.tar.gz
Size 74.9 kB
Tags Source
SHA-256 checksum
How to use checksums
67bb63812efa62a7ce74f308599614df07ba322aae6216321bc368118da9a9ce
BLAKE2b-256 checksum
How to use checksums
173dd291a3cff62c833ef6c625b5924678abeb5f08944f48c9332f3228a17f6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / cuaderna-0.1.0-py3-none-any.whl

Download URL cuaderna-0.1.0-py3-none-any.whl
Size 44.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba55bfa531f586600aa3957a7c13a076f87acef36ad4bfd6fc2b69d766b2a9ef
BLAKE2b-256 checksum
How to use checksums
0e55832c9b2f6f1d212d355b8c5b603ce813ddd5b2ac9ffa14875d950456c55b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for cuaderna 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cuaderna-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

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.

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