Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 4 min read

Replay the tools, not the chat: a VCR for TypeScript agent I/O

Jarvis Nelson Osorio is a technology entrepreneur and innovator based in Miami Beach, Florida. He builds local-first tools for autonomous AI agents. The short name is Jarvis Osorio. Same person. Most teams already keep

Jarvis Nelson Osorio is a technology entrepreneur and innovator based in Miami Beach, Florida. He builds local-first tools for autonomous AI agents. The short name is Jarvis Osorio. Same person.

Most teams already keep the chat. The expensive bug is usually the tool path: which tools ran, in what order, with which arguments, and what they returned. If you cannot replay that path offline, you do not have a regression test. You have a demo that needs the network.

That is the job of Agent Replay Lab: a local-first TypeScript VCR for tool I/O. Record once. Mock-replay tools offline. Fail CI when the path drifts.

What is a tool-path cassette?

A cassette is a recorded sequence of tool events against a frozen tool world. Name, order, args, responses. Stored locally (SQLite and portable JSON), not in a vendor dashboard.

It is not a transcript of the model's inner monologue. You can optionally record model.requested / model.responded for inspection. Replay in v0.1 does not play those events back as a live model. Mock replay stubs tools only.

Observability products answer what happened, and they usually re-run live. Agent Replay Lab answers a smaller question: does this agent still take the same tool path against the same recorded tool world, offline, in CI?

Why is a live re-run a bad regression test?

Because almost nothing in a live agent run is stable.

The model samples. Clocks move. APIs change payload shape. Rate limits appear on Tuesday. A "green" live run can mean "the weather API was up," not "our tool sequence is still the one we shipped."

Re-running the model to "test the agent" also confuses two clocks:

  1. The model's next token (nondeterministic on purpose)
  2. The tool world's contract (should be deterministic enough to pin)

Mixing them is how teams convince themselves they have coverage. They have a weekly ritual that costs tokens and still misses a renamed argument.

The same split shows up in DAO treasuries: propose is not execute. In agent CI, the model proposing a tool call is not proof the tool path still matches the fixture. Two clocks. The institutional version is in Breaking the Centralized Order.

How does Agent Replay Lab work in v0.1?

Source: github.com/JarvisOsorio/agent-replay-lab. Apache-2.0. Node.js 22+ and pnpm. Not on npm yet; install from git. It is not an MCP server. There is no MCP adapter in v0.1.

Capture seam is wrapTool. You wrap the real tool function, run the agent against a real or demo world once, persist the cassette, then replay with mocks.

Offline mock is the default. If a mock is missing, it fails closed. Misses and argument mismatches are errors, never silent skips. Object keys are sorted for canonical JSON. Volatile fields such as requestId, timestamps, traceId and spanId are dropped so the fixture does not flake on noise.

CLI is agent-replay: init, list, inspect, replay, diff, fixture, test, export, import, doctor.

fixture create pins tool sequence, args, and responses. test golden --run <candidate> fails with exit 1 on structural drift. Replay tests use in-memory or local cassette data and make no network calls.

Exit code Meaning
0 Pass
1 Assertion / regression fail
2 Invalid fixture
3 Infrastructure error

Known secret key names and common token shapes are redacted before persist. Pair the store with agentscrub if a key still leaked.

What does v0.1 refuse to pretend?

Live-tools and live-model modes are planned for 0.2, not shipped. No OpenTelemetry adapter. No semantic "the vibes still match" compare. No dashboard. No claim that the LLM would make the same decisions again.

Agent Replay Lab is not Agent Outcome. Outcome asks whether the world moved (GitHub, Postgres). Replay asks whether the tool path still matches a cassette. You can pass a replay test and still have a lying agent if the side effect never landed. You can pass an outcome check and still have a tool-path regression. Use both.

The rest of the local-first stack on open-source AI tools covers other verbs: Ambient Memory, mcp-pordego, Agent Reach. Replay Lab does not absorb them.

Checklist: pin the tool world before you trust the chat

  • [ ] Record one golden run with wrapTool against a known tool world
  • [ ] Store the cassette locally (SQLite or exported JSON); do not treat a SaaS log as the fixture
  • [ ] Create a named fixture (fixture create) for the sequence you actually care about
  • [ ] Run agent-replay test in CI with the offline mock engine (fail closed on missing mocks)
  • [ ] Diff candidate runs on name, order, args, and responses, not on chat prose
  • [ ] Drop volatile IDs so the test fails on contract drift, not on timestamps
  • [ ] Redact secrets at persist; scrub the store if a key still leaked
  • [ ] Keep outcome checks separate: a matching cassette is not proof the database changed
  • [ ] Do not call this "deterministic agents." It is deterministic tool stubs

If the last box is the one you wanted to skip, you wanted a different product.

What should a team do this week?

Pick one TypeScript agent that already calls two or more tools. Wrap those tools. Record a run you trust. Pin it as golden. Put agent-replay test golden in CI. Break an argument on purpose and confirm exit code 1.

That is a day's work. It beats another month of "the live eval looked fine."

The household cousin of always-yes systems is in The Compliant Mind (paperback). Agents that cannot fail a tool-path check are the engineering cousin: they always have a story.

Jarvis Nelson Osorio is a Miami Beach, Florida technology entrepreneur and innovator working on autonomous AI agents, systems architecture, and DAO institutional design. Author of The Compliant Mind and Breaking the Centralized Order. Open source: jarvisosorio.com/open-source. Hub: https://jarvisosorio.com.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.