How do I replay a failed agent session turn by turn?
Replaying a session turn by turn means feeding the model the same message history it had at each step, and returning the same tool outputs it received then, instead of letting live tools answer again. Capture three things per turn: the messages up to that point, the tool call and its recorded output, and the configuration, model, prompt version, settings, that was active. Replay the turns in order, holding tool outputs fixed, so each step sees exactly what the original run saw. If a step calls a tool again instead of reading the recorded result, you’re not replaying, you’re running a new session that happens to start the same way and can diverge from turn one. Doing it turn by turn, rather than replaying the whole session as one unit, lets you stop at the turn where things went wrong and inspect the model’s state right there.