AI-assisted engineering/Debug the agent trace

The agent looped and gave up: find the first bad span

Debug the agent traceMedium30 min

An agent failed in production. Read its trace, name the root cause, fix it so the replay passes.

Your task

The agent looped and gave up. Name the span where it first went wrong, then fix the routing so the replay passes.

  • root_cause_span() returns the FIRST span whose plan contradicted what the agent already knew
  • route(order) returns the action for that order: "cancel", "return", or "escalate"
  • a shipped or delivered order is a return, never a cancel
  • a pending order still cancels
  • a status the agent does not understand escalates instead of looping
  • leave call_tool() and check() alone; the environment is not the bug

The replay runs your route() across four orders at submit, and your named span is checked against the key. Your prompts, runs, and edits are the trace the critique reads.