IamBishal
AuthorAI / LLMDeveloper Tools

Agent Retake

Regression testing for AI agents: record real runs, replay them after a change, and see what broke.

Record agent runs as takes, replay them after a prompt, model or code change with tools answered from the recording, and get a statistical verdict: regression, ok, or not enough evidence.

Agent Retake cover: 'Regression testing for AI agents', record → replay → verdict, with a terminal showing a blocked refund, a diff and a regression verdict.
Your role
Author
Language
Python
License
MIT
Status
Active

Overview

Why it exists

Changing an agent's prompt, model or code can quietly break behaviour that worked yesterday, and one green run proves little when the model is not deterministic. Agent Retake records real agent runs as takes: every model call and every tool call, with emails, card numbers and keys redacted at record time.

After a change it replays them. In exact mode the model and the tools answer from the take, offline and free. In model-live mode the model answers live while tools answer from the recording, so a refund never runs twice: a call the take has no answer for is never given an invented result, and a write is reported as a blocked write instead of being run. A diff shows the step where the new run parted ways with the old one, in the terminal or as an HTML page.

retake test runs each take many times, checks your assertions (tools not called, call order, final answer, a Python function or a judge rubric) and compares pass rates with a stored baseline using Fisher's exact test with a Holm correction and a minimum effect. When there are too few runs to promise a drop would have been caught, it says "not enough evidence" instead of passing, and retake power shows what a suite can detect before anything is spent. A judge's agreement with people is measured with Cohen's kappa.

It works with the Anthropic and OpenAI SDKs (streams included), MCP clients and LangChain / LangGraph agents, and ships a GitHub Action that keeps one comment on the pull request up to date, plus JUnit, Markdown and a pytest plugin.

Topics

  • Agentic AI
  • Testing
  • Developer tools

Features

What it can do

  • Records model and tool calls from the Anthropic and OpenAI SDKs, MCP clients and LangGraph, redacted at record time
  • Exact replay: model and tools from the take, offline and free, to check a refactor sends the same things
  • Model-live replay: a live model with tools answered from the recording; writes are never run, only reported
  • A diff that shows where a replayed run parted ways with the original, in the terminal or as an HTML page
  • Verdicts against a baseline: Fisher's exact test, Holm-corrected, with a minimum effect and "not enough evidence"
  • Power analysis before spending: how many runs are needed to catch a given drop
  • Assertions: tool not called, call order, final answer, Python functions and judge rubrics with kappa calibration
  • Hard budget on live spend, and a ledger that caps the total across runs
  • GitHub Action with one up-to-date pull-request comment, JUnit and Markdown output and a pytest plugin

Quick start

Up and running

  1. Install and open the example

    A small support agent for Kestrel Outfitters, on a scripted model: no key, no spend.

    Terminal
    git clone https://github.com/bishal-saha/agent-retake && cd agent-retake
    uv sync --all-groups
    cd examples/kestrel-support
  2. Replay after a prompt change

    The edit drops the ownership rule; tools answer from the takes and the refund is blocked, not run.

    Terminal
    uv run --group examples retake replay takes --agent run.py:live_skips_check \
      --mode model-live --budget 0.05 --out replays
  3. See where the runs parted ways

    Terminal
    uv run --group examples retake diff takes replays
    uv run --group examples retake view takes replays   # the same, as an HTML page
  4. Regression or noise?

    Many runs per take, compared with a stored baseline.

    Terminal
    uv run --group examples retake test . --save-baseline --branch main
    uv run --group examples retake test . --agent run.py:suite_skips_check
  5. Record your own agent

    Python
    import anthropic
    import agent_retake
    
    client = anthropic.Anthropic(http_client=agent_retake.http_client())
    
    @agent_retake.tool(side_effect="irreversible")
    def issue_refund(order_id: str, amount: float) -> dict: ...
    
    with agent_retake.record("takes/T-1.take.jsonl", input=ticket):
        my_agent(client, ticket)

Tech stack

Built with

Language
  • Python 3.12
Integrations
  • Anthropic SDK
  • OpenAI SDK
  • MCP
  • LangGraph
Recording
  • httpx transport
  • JSONL takes
  • redaction
Statistics
  • Fisher's exact test
  • Holm correction
  • Cohen's kappa
CI
  • GitHub Action
  • JUnit
  • pytest plugin

Screens

A look inside

01See where the new run parted ways
02Regression or noise: 20 runs per take
03A PR comment and an honest red

Bishal SahaLet's build together

Have a system to design, or an AI feature to get right?

Tell me about the problem. You'll get a clear, honest view of the best way forward.

  • Reply within 24 hoursOn business days, with my honest view and a next step.
  • Accepting select engagementsArchitecture, AI features and full builds.
  • Remote, worldwideWorking with startups, SMEs and enterprises.