Using AI effectively

In any AI-based investigation, the quality of the results depends on how you frame the question, and how you interact with the AI agent after it answers. This page collects the practices we have seen work well when using Undo to provide the AI agent with the runtime context it needs to solve a problem, both from your AI agent and in UDB.

How to ask

Treat the AI agent like a technically competent colleague who is unfamiliar with your code.

  • Describe what you want, not how to get it. Describe the outcome (what should be explained, what should be verified) rather than the individual debugging steps. The agent’s tools are designed to drive Undo; asking it to step into a specific function, or set a specific breakpoint, usually leads to worse results.

  • Give the AI agent the context that is not in the code. Name the recording you want it to investigate; mention the symptom you saw (a crash, a wrong output, a timeout); and include any details that would be obvious to a colleague but not from looking at the source (which test failed, which input is wrong, which build options are non-default). You do not need to tell the AI agent anything it can read from the recording, such as the current backtrace, the current function, or the values of variables in scope: the AI agent can fetch these through its tools.

  • Do not micro-manage. When the AI agent is working, let it run. Interrupting an investigation to redirect the AI agent every few seconds tends to disrupt its reasoning and waste the context it has built up. LLMs are good at recognizing when an approach has not succeeded and trying a different one, so a wrong turn is not necessarily a problem. Intervene only when the AI agent persists in going in the wrong direction.

  • Ask follow-up questions. Most non-trivial investigations need multiple rounds. Ask the AI agent to verify a claim, explain a step in more detail, or check an alternative hypothesis. The ai command (in common with most chat-style agents) preserves the conversation so that subsequent interactions have full context.

  • Start a fresh conversation for each new investigation. The preserved context that makes follow-up questions work becomes a liability once you move on to an unrelated problem. Starting a new chat (or, in UDB, loading a different recording) gives the AI agent a clean slate and stops earlier, irrelevant findings from misleading it.

Example prompts

From an AI agent configured to use the undo mcp server:

Please investigate why the program in my-recording.undo crashed, using the undo MCP
server.
The recording rec1.undo finished with a correct result, but rec2.undo (same code,
different input) produced garbage. Please find what differs between the two runs and
why rec2 went wrong.
./my-test sometimes fails when I run it repeatedly. Capture a failing run as an Undo
recording, then investigate why it failed.

From inside UDB, using the ai command:

start 1> ai why did this program crash?
⌛ Thinking…
🔧 inspect_expressions(expressions=['$_siginfo'])
🔧 trace_value(expression='ptr', hypothesis='ptr was freed before this read')
🕖 Now at 12,345:0x7ff8bba9569c in process_data

✨ Here's what I found:

The program crashed because [...]
start 1> ai where did foo's value come from?
⌛ Hitting 88mph…
🔧 trace_value(expression='foo', hypothesis='foo was last written by configure()')
🕖 Now at 9,876:0x7ff8bba94800 in configure

✨ Here's what I found:

foo's current value of 42 was set by [...]
start 1> ai
Compare the value of state at this point with what it was at time
1,2345:0x7ff8bba9569c and explain any differences.
end
⌛ Quantum leaping…
🔧 inspect_expressions(expressions=['state'])
🕖 Now at 1,2345:0x7ff8bba9569c in main
🔧 inspect_expressions(expressions=['state'])

✨ Here's what I found:

At the earlier time the state was [...]

Pair programming with your AI agent

When you use Undo from your own AI agent, the AI agent and a human user can collaborate on the same recording:

  • Bookmarks that the AI agent sets while investigating are visible to you when you later load the same recording in UDB. This makes it straightforward to verify the AI agent’s reasoning by jumping to the points in execution history that the agent considered important.

  • Conversely, bookmarks that you set in UDB are visible to the AI agent on the next investigation. You can use this to give the AI agent a starting point (for example, a bookmark named this-is-where-things-went-wrong) without having to describe it in prose.

Continuous integration

You can use Undo in a CI workflow, for example by capturing an Undo recording of a failing test and then running an AI agent against the recording with the undo mcp server configured. The MCP server still has to run somewhere that has the source code and debug symbols for the program being investigated, so for CI use this usually means running on the same machine (or container) that built and ran the test.

Undo does not currently ship a turn-key CI integration. If you are building one and want to discuss it, contact support@undo.io.