// tool 03 · agent replay

Agent Replay — the rules your agent should have followed, run against what it actually did.

An AI agent keeps a log of everything it did: every tool it called, with what, and what came back. Paste that log in. Then write the rules it should have followed — what it may do, what needs a person to say yes, how often it may retry, how much it may spend. Run the rules over the log and see which actions would have been stopped, where it went round in circles, and what the whole thing cost. Compare two runs of the same job to see what changed.

Runs entirely in your browser · no keys · nothing uploaded · reads OpenAI, Anthropic and plain event logs

1 · What the agent did its log of tool calls, pasted as-is

2 · The rules the "policy" — what it may do, and what needs a person

2b · A second run the same job on another day, to compare

3 · What the rules would have changed press Run the rules

      What do I paste in?

      Every agent framework keeps a log of what the model decided to do: which tool it called, with what, what came back, and how many tokens each turn used. People call it the trace. Agent Replay reads the three common shapes and turns them into one list of steps:

      • Plain events — an array of {"type":"tool_call","name","args"}, {"type":"tool_result","name","ok","ms"}, {"type":"llm","model","input_tokens","output_tokens"} and {"type":"message","role","content"}.
      • OpenAI messages — an array of chat messages where assistant turns carry tool_calls and role:"tool" messages carry results; usage on a turn is read for tokens.
      • Anthropic messages — content blocks of type tool_use and tool_result, with usage per assistant turn.

      The example that behaves is a support agent handling a refund; the one that doesn't is the same job on a night the order lookup keeps timing out — the agent retries six times, reads a file it had no business reading, refunds ten times too much, and emails the customer a card number.

      How do I write the rules?

      The rules are a short JSON object — this is what people mean by a "policy". It lives outside the agent, so the model can't talk itself past it; the big cloud providers are now shipping the same idea as a product. Every line is optional:

      {
        "allow": ["search_orders", "get_order", "refund"],
        "deny":  ["read_file", "shell"],
        "ask":   [ { "tool": "send_email" },
                   { "tool": "refund", "when": { "arg": "amount", "gt": 50 } } ],
        "limits": { "max_calls": 20, "max_retries": 2,
                    "max_cost_usd": 0.25, "max_ms": 60000 },
        "args": { "deny_patterns": ["\\b\\d{16}\\b", "@.*\\.gov$"],
                  "http_allowed_hosts": ["api.stripe.com"] },
        "prices": { "default": [3, 15] }
      }

      allow lists the only tools it may use; deny names tools it may never use and wins over everything; ask marks actions that need a person to say yes — always, or only past a threshold like a refund over $50; limits catch going round in circles, runaway spend and slow runs; deny_patterns are patterns that must never appear in what it sends (card numbers, say); prices are dollars per million tokens, by model, so the bill is real.

      In the toolkit: PromptwatchToken WindowEntropy MeterLog LabAgent ReplayAgent Replay LiveNexus v2 · all tools →