← Back to Work

// 27 / AI AGENTS  ·  03 Dec 2026

Agent Replay — Which Actions
Would the Rules Have Stopped?

TypeBrowser tool · live
StackSingle HTML file · vanilla JS
ReadsOpenAI · Anthropic · plain events
Network callsNone

// the idea

The question has moved from "can it do it" to "should it have"

Everyone can build an agent now: a model in a loop with tools. What people who run them — and people who hire — are asking has moved on. What did it do? What did it cost? What stopped it? Three things go wrong in the loop, and none of them is the model being stupid. It loops — a tool times out, the model tries again, and every retry is another model turn, so a flaky lookup quietly becomes most of the bill. It reaches — given a file tool to read a config, it will happily read the customer export too, because nothing said it couldn't. It commits — it refunds $420 instead of $42 and emails the customer, card number included, because no step needed a human.

The fix isn't a better prompt. It's a policy that lives outside the agent and is checked on every call — the idea behind the enforcement layers the cloud providers started shipping this quarter. Agent Replay is that idea at desk scale: paste a trace you already have, write the policy, and see what it would have done.

A concrete example

A support agent is handling "order 48213 arrived broken". The good run is four tool calls: find the order, find the customer, refund $42, send one email. $0.019. The bad run is the same task on a night the order lookup is timing out. Replayed against a six-line policy:

StepCallVerdictWhy
3–9search_orders ×3allowedthe lookup times out; two retries are within the limit
12–18search_orders ×3 moreblockedretry 3, 4 and 5 of the same call — a loop; the policy ends it at retry 2
21read_file customers_export.csvblockedon the deny list; it was never meant to see that file
24refund $420needs a humanamount crosses the $50 threshold — a person approves, or catches the extra zero
27send_email, card number in the bodyblockedargument matches a denied pattern (16 digits)
30http_get pastebin.comblockeddenied tool, and the host isn't on the allowed list either

Ten tool calls, five failed, $0.064 and 26 seconds. With the policy on, the run stops at step 12 having spent a third of that. Everything after step 12 is what it did because nothing said no.

agent replay · policythe whole thing
{
  "allow": ["search_orders", "get_order", "refund", "send_email"],
  "deny":  ["read_file", "shell", "http_get"],
  "ask":   [ { "tool": "send_email" },
             { "tool": "refund", "when": { "arg": "amount", "gt": 50 } } ],
  "limits": { "max_calls": 12, "max_retries": 2, "max_cost_usd": 0.10, "max_ms": 30000 },
  "args":   { "deny_patterns": ["\\b\\d{13,16}\\b", "password"],
             "http_allowed_hosts": ["api.stripe.com"] },
  "prices": { "gpt-4o": [2.5, 10], "claude-sonnet": [3, 15], "default": [3, 15] }
}

Try it — two built-in runs

Hit Load: the one that goes wrong and read the verdict column down. Then Compare two runs to diff it against the good one, or paste a trace of your own.

Open Agent Replay →

// what it does

Three panels: what it did, the rules, what would have changed

01

What the agent did (the trace)

The agent's log, pasted as-is. Three shapes are recognised and normalised to one list of steps: plain events (tool_call, tool_result, llm, message); OpenAI chat messages, where assistant turns carry tool_calls and role:"tool" messages carry results; and Anthropic messages with tool_use and tool_result content blocks. Token counts are read from usage on each turn.

02

The rules (the policy)

A short JSON object, every field optional. allow is a whitelist when present; deny beats everything; ask marks calls that need a human, optionally only past a threshold on one argument; limits catch loops, runaway spend and slow runs; deny_patterns are regexes run over every argument before it leaves; http_allowed_hosts fences any HTTP tool; prices are dollars per million tokens by model-name prefix, so the cost is real.

03

What the rules would have changed

Five numbers — verdict, tool calls, loops caught, cost, wall time — then every step with a badge: allowed, blocked, needs a human, with the reason on each blocked call. Notes underneath say where the run would have stopped and what was over budget. Compare two runs diffs the tool-call sequences of two traces and reports the calls only in one or the other and how the cost moved — a regression test for behaviour, the way Promptwatch is one for prompts. Export writes the verdict and the policy out as markdown.

// how it was built

Build notes

Normalise first, judge once

The three trace shapes are handled by one function that turns each into the same four event types; the replay only ever sees plain events. That kept the policy code to one pass over one list, and it means a fourth shape — LangGraph's, MCP's — is a dozen lines in the normaliser, not a change to the rules.

agentreplay.htmljavascript
for (const m of raw){
  if (m.type) { out.push(m); continue; }              // already a plain event
  if (m.role === 'assistant' && m.tool_calls)             // OpenAI
    for (const tc of m.tool_calls) out.push({ type:'tool_call', name: tc.function.name, args: JSON.parse(tc.function.arguments) });
  if (Array.isArray(m.content))                             // Anthropic
    for (const b of m.content) if (b.type === 'tool_use') out.push({ type:'tool_call', name: b.name, args: b.input });
}

A retry is "same tool, same arguments, after a failure"

Loop detection compares a signature of tool name plus normalised arguments with the previous call, and also counts a same-tool call straight after a failed result, so an agent that nudges the query ("48213" → "order 48213") still reads as a retry. An agent that varies its arguments every time will look like separate calls — that's what the max_calls budget is for, and the write-up says so rather than pretending the heuristic is smarter than it is.

Deny beats allow beats ask

The order of checks is the policy. A denied tool is blocked whatever else is true; an allowed tool can still be blocked by a pattern match or a host rule; only a call that survives all of that can be sent to a human. Getting the precedence wrong is how an "ask" rule accidentally lets a denied call through, so it's one function, in one order, with the reason string built as it goes.

Lines
~310 incl. CSS
Trace shapes
plain · OpenAI · Anthropic
Policy rules
allow · deny · ask · limits · patterns · hosts
Network calls
None

// what this demonstrates

Why this matters

"AI agents" is the fastest-growing requirement recruiters search for — roughly four times what it was a year ago — and the interview questions behind it are "what did it cost to run" and "what broke in production". A tool that answers both about any trace you paste into it felt like the most useful thing to add to the toolkit, and the natural fourth corner: Promptwatch tests the prompt, Token Window counts the context, Agent Replay checks the behaviour, Log Lab reads what happened.

It also closes a loop with the agent primer from June, whose argument was that the loop is easy and the boundary is the work. This is the boundary, made into something you can run against yesterday's logs.

What it isn't

It replays; it doesn't enforce. Design the policy against runs you already have, see what it would have caught, then put the same rules in front of the live agent — as middleware around the tool dispatcher, or in whatever enforcement layer your platform offers.

Where it could go next

Enforce mode

The same policy as a 60-line middleware for the OpenAI and Anthropic SDKs: every tool call checked before it runs, "ask" calls parked for a human.

Batch replay

Drop a folder of traces and get one table: runs blocked, loops caught, cost per task, the calls that would have been stopped most often.

More shapes

LangGraph and MCP server logs in the normaliser; OpenTelemetry spans from the agent frameworks that emit them.

Policy from traces

Read twenty good runs and propose the allow list, the thresholds and the retry limit that would have passed all of them — a starting policy, not a final one.

Source

The tool is the source — view the page and it's all there, MIT. agentreplay.html