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. A recorded run can be run again with one step made to fail or to return something else, and the steps you list are answered from the recording, so the model is not called again. What the agent did about it is read from the journal and verdicts are yours: fault injection. Forking a run from a step, delays, hangs and several faults at once are 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. - Fault injection: the fault plan file, rerunning a recorded run with one fault, and reading what the agent did.
- The run page: looking at a recorded run in the browser.
- Security: what cuaderna protects and what it does not.
Install
pip install cuaderna
Requires Python 3.12 or newer. The project is in early development: the API can still change between releases.
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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cuaderna-0.2.0.tar.gz | 91.0 kB | With provenance | Details for cuaderna-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cuaderna-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for cuaderna-0.2.0-py3-none-any.whl |
Total release size: 142.8 kB
Release files / cuaderna-0.2.0.tar.gz
| Download URL | cuaderna-0.2.0.tar.gz |
|---|---|
| Size | 91.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a48dcb6dce4bb363fa4d42386e2ccf5d7f58068c4b07aaa63cd59d5b999822de
|
|
BLAKE2b-256 checksum How to use checksums |
956eab617ef4c2542a0208da95c124a21c6de87a9bac4714a804d60290404370
|
| 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 logRelease files / cuaderna-0.2.0-py3-none-any.whl
| Download URL | cuaderna-0.2.0-py3-none-any.whl |
|---|---|
| Size | 51.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
947fa3097cb4b252728c176e944893daf7813ae28103c302c9c32af4631f84c7
|
|
BLAKE2b-256 checksum How to use checksums |
42e3e6a78695528137e93e5ab4b2a755b0f387b21d9824900df72b2e17ae7641
|
| 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 logSecurity for cuaderna 0.2.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.
Attestation for cuaderna-0.2.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 logA 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.