DEV Community

Cover image for I built Retrace: replay and fork your AI agent runs like a video
Yash
Yash Subscriber

Posted on

I built Retrace: replay and fork your AI agent runs like a video

If you've built anything with LLM agents, you know the annoying part isn't writing the agent — it's figuring out what went wrong when it misbehaves. The run is non-deterministic, the logs are scattered, and reproducing the exact failure is a pain.

I built Retrace to make that loop less miserable: record a run, replay it step by step, and fork from any step to test a fix.

How it works

You wrap your agent function once — a decorator in Python or a wrapper in TypeScript. After that, every LLM call, tool call, and error is captured automatically as a span inside a trace. Calls to OpenAI, Anthropic, and Gemini get picked up without extra instrumentation.

Then two things:

  • Replay — the run shows up as an interactive timeline you can play and scrub through, so you can see exactly where it broke instead of guessing from logs.
  • Fork — pick the step that went wrong, change the input, and Retrace re-executes the agent from that point forward. Everything before the fork replays from the recording, so you're not paying to re-run the whole thing, and you get a side-by-side diff of the original vs. the new path.

The stack

  • Python + TypeScript SDKs (published to PyPI and npm)
  • Fastify + PostgreSQL, with pgvector for semantic search over past runs
  • Buffered ingestion over WebSocket with HTTP and OpenTelemetry fallbacks, so a run isn't lost if the socket drops

Honest context

I built this solo, It's still early — I'd genuinely like feedback from people who run agents in production about what's useful and what's missing.

docs

If you try it, tell me where it breaks. That's the most useful thing right now.

Top comments (0)