AgentTape
Deterministic record & replay for AI agents.
AgentTape captures every external interaction your agent makes — both LLM calls and tool executions — into human-readable YAML "cassettes," then replays them deterministically so your tests run offline, for free, with zero side effects.
Full documentation: https://MITHRAN-BALACHANDER.github.io/AgentTape/
What it does
AgentTape sits between your agent and the outside world.
- Record — run your agent against the real OpenAI API, database, and tools. AgentTape saves every call to a YAML cassette.
- Replay — run the same code with the network off. AgentTape serves the saved responses in milliseconds. Your code can't tell the difference.
The usual alternative — hand-written mocks — tests your assumptions about a service, not the service itself. AgentTape records the real interaction once, then replays it.
Why it exists
Agent tests are normally slow, flaky, expensive, and dangerous: every run hits live LLM APIs (latency, cost, non-determinism) and executes real tools. If a tool charges a card, writes to a database, or posts to Slack, a test run actually does it. AgentTape gives you the realism of end-to-end tests with the speed and safety of mocks.
Quick example
import agenttape
from openai import OpenAI
def run_agent():
client = OpenAI()
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Say hi in 3 words"}],
)
return resp.choices[0].message.content
# 1. Record — calls the real API once, writes cassettes/hello.yaml
with agenttape.use_cassette("hello", mode="record"):
print(run_agent())
# 2. Replay — zero network, free, identical output every time
with agenttape.use_cassette("hello", mode="none"):
print(run_agent())
The first block calls OpenAI and saves the prompt and response. The second block blocks the network and returns the saved response instantly.
Record your own tools
Wrap any side-effecting function. It runs normally while recording and returns the saved output during replay — it never executes for real on replay.
@agenttape.tool
def charge_card(amount: int) -> dict:
return payment_api.charge(amount) # real side effect, skipped on replay
Key features
- Local-first — no servers, no telemetry, no network during replay.
- Deterministic — same inputs → same recorded output, byte-for-byte (time, UUIDs, and randomness are frozen).
- Zero side effects — a replayed tool never runs for real. Safe for CI.
- Almost-no-code — one
withblock or one decorator; your agent code is unchanged. - Git-friendly — cassettes are plain YAML you can read, diff, and hand-edit.
- Partial replay — run the LLM live against a new prompt while tools stay frozen.
- Zero core dependencies — the engine runs on the Python standard library alone.
Installation
pip install agenttape # core (stdlib only, zero deps)
pip install "agenttape[openai]" # + automatic OpenAI interception
pip install "agenttape[yaml]" # + PyYAML for faster large-cassette parsing
pip install "agenttape[all]" # everything
pytest integration
import pytest
@pytest.mark.agenttape("weather_agent")
def test_weather(agenttape_cassette):
result = run_agent()
assert "sunny" in result.lower()
agenttape_cassette.assert_tool_calls(["get_location", "get_weather"])
pytest # offline replay (mode=none) — the default
pytest --agenttape-record # (re)record against real services
CLI
agenttape init # scaffold agenttape.toml + cassettes/
agenttape inspect cassettes/x.yaml # interactions, latency, tokens
agenttape timeline cassettes/x.yaml # ASCII waterfall
agenttape diff a.yaml b.yaml # structured diff of two runs
agenttape view cassettes/x.yaml # self-contained HTML viewer
Documentation
| Start here | Go deeper |
|---|---|
| What is AgentTape? | Core Concepts |
| Your First Recording | Testing AI Apps |
| Quickstart | Python API Reference |
License
MIT — see LICENSE.
Metadata
Release files for agenttape 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agenttape-0.1.8.tar.gz | 73.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agenttape-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 157.6 kB
Release files / agenttape-0.1.8.tar.gz
| Download URL | agenttape-0.1.8.tar.gz |
|---|---|
| Size | 73.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21065cd5606f815f723949b21452617088ffc70a188f29fa567f436c19fbea9a
|
|
BLAKE2b-256 checksum How to use checksums |
80fbf0ce10f15b52a3c54ab7f6a8237e6d9989af9251fb1e8758a3cf394d5886
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 17, 2026.
Transparency logRelease files / agenttape-0.1.8-py3-none-any.whl
| Download URL | agenttape-0.1.8-py3-none-any.whl |
|---|---|
| Size | 83.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
039fdc1a6984424bce56a617a61037cf1764bbc0d9a8bab88bde1dbd9bff1cbf
|
|
BLAKE2b-256 checksum How to use checksums |
96f05b9fd3b2c7aaf79a7ac07c6d5b5e3a810ad965901ded2e2962846abd7628
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 17, 2026.
Transparency log