Replay for debugging

A structured trace is only useful if you can read it. The observability layer keeps the most recent trace per thread in a small in-memory buffer, and the router exposes a GET endpoint so engineers (and automated probes) can fetch it. In production you replace the buffer with your log store; the interface does not change.

router.py
python
@router.get("/trace/{thread_id}")
async def get_trace(thread_id: str):
    """Return the trace from the most recent interaction on this thread."""
    trace = agent_service.get_trace(thread_id)
    if trace is None:
        raise HTTPException(status_code=404, detail="No trace found for thread_id")
    return {"thread_id": thread_id, "trace": trace}

One endpoint, one job: return the last trace for a thread or a clean 404. Connect this to your dashboard and you have push-button debugging for any user complaint.

Replay workflow

User reports an issue, engineer pulls the trace, every layer is accountable.

Ordering exercise: Order the full request path with trace

Loading practice…

Checkpoint: Layered agent final checkpoint

Loading practice…