Debug a Run
Use this when a run stops unexpectedly or tool behavior is incorrect.
Prerequisites
- Target
thread_idand (if available)run_id. - Access to the emitted event stream and persisted thread data.
Steps
- Confirm termination reason from
AgentEvent::RunFinish { termination, .. }.
termination is authoritative and usually one of:
NaturalEndBehaviorRequestedStopped(...)CancelledSuspendedError
- Inspect event timeline ordering:
StepStart/StepEndToolCallStart/ToolCallDoneInferenceCompleteError
- Verify persisted delta in storage:
- New messages
- New patches
- Metadata version increment
- Check plugin phase behavior if execution is phase-dependent:
BeforeInferenceBeforeToolExecuteAfterToolExecute
- Reproduce with minimal deterministic inputs and compare event traces.
Verify
A fix is effective when:
- The same input no longer reproduces the failure.
- Event sequence and terminal reason are stable across repeated runs.
- Persisted thread state matches expected messages and patch history.
Common Errors
- Debugging only final text output and ignoring event stream.
- Inspecting latest thread snapshot but not patch delta/version movement.
- Mixing protocol-encoded events with canonical
AgentEventsemantics.
Related Example
examples/ai-sdk-starter/README.mdincludes thread-history verification that is useful when debugging replay and persistence issuesexamples/copilotkit-starter/README.mdincludes persisted-thread and canvas flows that surface event-ordering and approval issues quickly
Key Files
crates/tirea-agentos/src/runtime/loop_runner/mod.rscrates/tirea-agentos-server/src/http.rscrates/tirea-agentos-server/tests/run_api.rs