Skip to main content

Deterministic record/replay of LLM and tool calls for AI agents, captured into human-readable cassettes.

Project description

AgentTape

Deterministic record and replay for AI agents.

AgentTape captures every external interaction your agent makes—both LLM calls and tool executions—into human-readable "cassettes." It then replays them deterministically so your tests run offline, for free, with zero side effects.

CI PyPI Downloads Python License: MIT


What is it?

AgentTape is a testing and debugging tool for AI applications. It sits between your agent and the outside world.

When you run your agent in record mode, AgentTape saves every API call, prompt, and tool execution to a YAML file (a cassette).

When you run your agent in replay mode, AgentTape intercepts all network and tool calls and serves the exact responses saved in the cassette. Your code thinks it's talking to the real world, but it's completely offline.

Why it exists

Agent tests are traditionally slow, flaky, expensive, and dangerous.

Every test run hits real LLM APIs (incurring latency, cost, and non-determinism) and executes real tools. If a tool charges a credit card, writes to a database, or posts to Slack—a test run will actually perform those actions.

Without AgentTape, you have to choose between writing fragile mocks or running expensive, slow end-to-end tests. AgentTape gives you the best of both worlds: the realism of end-to-end tests with the speed and safety of mocks.

Quick Example

Here is the smallest possible working 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 (hits the real API once, writes to cassettes/hello.yaml)
with agenttape.use_cassette("hello", mode="record"):
    print(run_agent())

# 2. Replay (zero network calls, completely free, perfectly deterministic)
with agenttape.use_cassette("hello", mode="none"):
    print(run_agent()) # Outputs the exact same text, served from the cassette

What happened? The first time you run this, AgentTape talks to OpenAI and saves the prompt and response. The second time, AgentTape blocks the network request and immediately returns the saved response.

Key Features

  • Local-first: No servers, no network required in replay, no telemetry.
  • Deterministic: The same inputs always produce the exact same recorded outputs, byte-for-byte.
  • Zero side effects: A replayed tool never executes for real. Safe for CI.
  • Almost-no-code integration: Add a single decorator or with block to your existing code.
  • Git-friendly: Cassettes are plain YAML. You can read, diff, and hand-edit them.
  • Zero core dependencies: The engine is built entirely on the Python standard library.

Installation

Install AgentTape using pip. The core package has no external dependencies.

pip install agenttape            # core (stdlib only)
pip install "agenttape[openai]"  # + OpenAI adapter
pip install "agenttape[yaml]"    # + PyYAML for extra-robust YAML loading

Documentation

Ready to start building? Check out our documentation:

License

MIT — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agenttape-0.1.5.tar.gz (65.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agenttape-0.1.5-py3-none-any.whl (76.9 kB view details)

Uploaded Python 3

File details

Details for the file agenttape-0.1.5.tar.gz.

File metadata

  • Download URL: agenttape-0.1.5.tar.gz
  • Upload date:
  • Size: 65.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agenttape-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a093603093a0ec98cbee13e8ca38b3c30252f367eef7bb64d4db11f56022db8f
MD5 6cb059435a0d430dde7de132a44b857d
BLAKE2b-256 46f86dbe53c72bdd84a8ae14ecffdcf9fbe8cf1c06e67172907f1784dc8b79d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for agenttape-0.1.5.tar.gz:

Publisher: release.yml on MITHRAN-BALACHANDER/AgentTape

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agenttape-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: agenttape-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 76.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agenttape-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e04838d0144c3580f8b69cd80004e412deb2fe1d199111d3808b18ec18eb8f0d
MD5 febdde9c3f635aecee03d244d5c77e28
BLAKE2b-256 25cc3bacb2f94df6f4478ae703f0e1636c289d4d70749f06787796b86a5fb4c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for agenttape-0.1.5-py3-none-any.whl:

Publisher: release.yml on MITHRAN-BALACHANDER/AgentTape

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page