The first bug had wings
In September 1947, operators of the Harvard Mark II computer, the team Grace Hopper worked with, traced a fault to a moth trapped in a relay. They taped it into the logbook with a note: first actual case of bug being found. The word was older than the moth, but the logbook made the point that has stuck ever since: debugging starts with a good record of what actually happened.
AgentTraceDAG is that logbook for LLM agents. It is a local time-travel debugger, in the spirit of browser developer tools: a FastAPI backend, a SQLite trace store and a DAG visualizer. You can scrub back through a run and inspect each step's context, tool payloads, latency and token use.
To test a debugger, build something broken
A debugger is only as good as the failures it can show you. Real agents are a poor test bed: they need API keys and a network, and they rarely fail the same way twice. So I built a crash-test dummy, a scripted research agent with a fake model and no network. It deliberately fails a cite-check tool at step six, recovers, and records a nine-node trace with real parent-child nesting. Same run, same failure, every time.
The first surprise came before the agent ran at all. The debugger's own command-line entry point crashed on startup because of a missing import, while all 25 tests passed. It was a small fix and a useful warning about what the tests were not covering.
A family tree with no parents
The first real run showed a deceptive failure. The dashboard worked, but the DAG was flat: every step sat at the same level, like a family tree where all the parents have vanished and everyone looks like siblings.
The cause was one assumption. LangChain can pass its serialized description of a component as None for a RunnableLambda. The interceptor assumed it was always a dictionary, so every chain node was silently dropped, and with them went the hierarchy. The repair added a name resolver that falls back to the name the callback supplies.
The fix was small. The dangerous part was that nothing errored. I now treat a missing trace event as a debugging failure, not as an acceptable gap in the picture.
- research agent
- plan
- llm: outline
- gather
- tool: search
- tool: cite-checkfailed
- recover
- tool: cite-check
- llm: answer
A recorder that could not play back
The second bug sat at the storage boundary, and it was the flight-recorder nightmare: a recorder that accepts the tape and then cannot play it back. Chain-end callbacks could emit outputs that were not dictionaries. SQLite stored them happily, but the Pydantic model rejected them when the trace was read back, which permanently broke node listing for that run.
Normalizing every value into a payload before storage made the trace schema durable across those callback shapes. The interceptor also backfilled model names from the LLM output, so each step in the inspector says which model ran instead of showing an anonymous box.
The boring verification that matters
After the fixes, the offline demo rendered nested nodes and showed the planned failure and recovery, and the test suite stayed at 25 passing tests. The dashboard was verified against nine recorded runs, with the DAG tree, node inspector and time scrubber all working.
The lesson is that observability code needs adversarial examples too. A trace that merely exists is not enough. It has to keep its hierarchy and stay readable after it has been stored, or it is a logbook with the pages glued shut.