Once-only actions, approvals bound to exact arguments, and record/replay for Python AI agents
pip install call4agents Copy PIP instructions
Call4Agents makes the actions of a Python agent safe to retry. You add it to the agent you already have: LangGraph, Pydantic AI, the OpenAI Agents SDK, or plain Python. It does not replace any of them.
Version 0.1, early. Standard library only, zero dependencies. Apache-2.0.
Tested on every change (tests.yml). These are the only systems we claim:
With the real frameworks, on all three systems with Python 3.12: LangGraph (+ LangChain), Pydantic AI and the OpenAI Agents SDK. CI installs the latest release of each, and each run prints the exact versions with call4agents doctor.
pip install call4agents call4agents quickstart quickstart runs a plain-Python demo. Then, for each of LangGraph, Pydantic AI and the OpenAI Agents SDK that is installed, it runs a real crash and resume in that framework, using a fake model. Each framework is run once without Call4Agents and once with it. Output on our machine (Windows 10, Python 3.12, all three installed):
Plain Python - crash right after an email is sent, then resume: without the run record emails sent: 2 with the run record (crash after the tool) emails sent: 1 with the run record (crash inside the tool) emails sent: 1 (refused to resend: in doubt) "yes" to pay(10, alice), call changed to pay(9999, mallory): REFUSED; approved call: PAID; payments: 1 Frameworks found: LangGraph, Pydantic AI, OpenAI Agents SDK LangGraph crash after the email, resume: without call4agents 2 emails, with call4agents 1 Pydantic AI crash after the email, resume: without call4agents 2 emails, with call4agents 1 OpenAI Agents SDK crash after the email, resume: without call4agents 2 emails, with call4agents 1 With no framework installed, only the plain-Python part runs (about 5 seconds on our machine). To see the framework rows, install them first: pip install langgraph langgraph-checkpoint-sqlite pydantic-ai openai-agents (about 75 seconds in a fresh virtual environment).
call4agents selftest checks the demo results. Run it from the root of a repository checkout to run the full offline suites instead (kit, production, stress and idempotency checks).
Found a problem, or something missing? call4agents doctor prints your system and framework versions (it sends nothing). Paste it into an issue.
You probably do not need it if your agent only reads data, or if every action already runs inside a durable workflow engine that gives you these guarantees.
import call4agents as c4a c4a.init() # creates .c4a/ledger.sqlite and .c4a/secret @c4a.effect # once per (run, tool, exact arguments) def send_email(to, body): ... @c4a.effect(approval=True) # also needs a "yes" for these exact arguments def pay(amount, to): ... @c4a.effect(idempotent_for=24 * 3600) # the API remembers keys for 24 h (Stripe v1) def charge(amount, to): return requests.post(URL, json={"amount": amount, "to": to}, headers=c4a.idempotency_headers()).json() @c4a.recorded # model calls, for replay and diff def ask_model(prompt): ... with c4a.run("thread-42"): # use the id your framework resumes with send_email("bob", "hi") send_email("bob", "hi") # same action: returns the recorded result, sends nothing send_email("bob", "hi", c4a_key="second") # a deliberate second identical action c4a.approve(pay, amount=10, to="alice") # when the person says yes to what they SAW pay(amount=10, to="alice") Rules worth knowing before you start:
Pydantic AI, the OpenAI Agents SDK, plain Python. Decorate the tool function with @c4a.effect and wrap the run in c4a.run( ). You can see working code for each framework in call4agents/examples/crash_resume.py.
The kit's whole state is one local SQLite file, which we call the run record. Entries are only ever added to it, never changed or deleted.
python -m call4agents ... works the same way.
You can rerun every number in this table. The tests use fake models, fake tools and real process kills.
A dash means the case was not tested in that framework.
Each guard is mutation-tested: when its bug is put back, its check fails. A no-op control is run next to every batch of mutations. Rerun them with python -m tests.mutations.run_kit_mutations.
ai-agents langgraph pydantic-ai openai-agents idempotency approvals human-in-the-loop
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.




