Buddy supports optional runtime-event tracing for debugging and replay.
- Enable with
--trace <path>orBUDDY_TRACE_FILE=<path>. - Output format is JSON Lines (one
RuntimeEventEnvelopeper line). - Tracing is best-effort:
- startup open failures are warnings (runtime continues),
- write failures disable tracing and emit one warning.
Buddy can analyze trace files offline:
buddy trace summary <file>buddy trace replay <file> --turn <n>buddy trace context-evolution <file>buddy traceui <file> [--stream]
buddy traceui is a terminal UI for inspecting raw trace events with
color-coded event families, keyboard navigation, and a split-pane layout.
It parses trace JSONL generically from raw JSON values so unknown future event
shapes still render instead of failing hard.
Interaction and rendering notes:
- left pane: compact event summaries with family-aware colors
- right pane: always-expanded structured detail with colorized keys/scalars
- nested JSON encoded inside string fields is decoded and rendered recursively when valid
j/k, arrows,b/f, andg/Gnavigate the event listu/dscrolls the right-hand detail pane--streamfollows appended events until you start navigating;Escresumes follow mode- redraws are diff-based so unchanged rows are not repainted every poll tick
-venablesinfologs.-vvenablesdebuglogs.-vvvenablestracelogs.BUDDY_LOGoverrides all CLI verbosity with atracingfilter expression.RUST_LOGis also supported whenBUDDY_LOGis unset.
Default verbose filter applies targeted component noise limits:
buddy=<level>reqwest=warnhyper=warnh2=warnrustls=warn
Each line is a serialized RuntimeEventEnvelope:
{
"seq": 42,
"ts_unix_ms": 1762051123000,
"event": {
"type": "Task",
"payload": {
"started": {
"task": { "task_id": 1 }
}
}
}
}seq is monotonic per runtime stream and ts_unix_ms is wall-clock capture time.
Task-scoped events include enriched TaskRef metadata when available:
task_idsession_iditeration(model/tool loop iteration for agent-emitted events)correlation_id(stable per submitted prompt)
Milestone-1 runtime traces include:
- request lifecycle:
Model.RequestStartedModel.RequestSummary(message_count,tool_count,estimated_tokens)Metrics.PhaseDuration(phase = "model_request")
- response lifecycle:
Model.ResponseSummary(finish_reason, tool-call count, content presence, usage)Model.MessageFinalwhen a final assistant response is produced
- tool lifecycle:
Tool.CallRequestedTool.ResultMetrics.PhaseDuration(phase = "tool:<name>")
- compaction lifecycle:
Session.Compactedwith pre/post token estimate fields and removal counts
- cost lifecycle:
Metrics.Costwith request/session USD estimates when pricing metadata exists
Milestone-2 adds tracing spans around key operations:
runtime.command: every runtime actor command branch.gen_ai.turn: prompt task envelope with task/session/correlation metadata.agent.turnandagent.turn_iteration: per-turn loop structure.gen_ai.chat.request: model request/response scope.gen_ai.tool.call: tool execution scope.runtime.session.*andagent.history.compaction: session + compaction lifecycle.
Semconv alignment is pragmatic: fields use snake_case equivalents (for example
gen_ai_system, gen_ai_operation_name, gen_ai_request_model) so traces
can be mapped cleanly into OTel-compatible exporters later.
Before writing a trace record, Buddy redacts obvious sensitive content:
- Secret-shaped key names (
api_key,password,secret,access_token,refresh_token) - Secret markers in free-form strings (for example
Bearer ...,sk-..., private key headers)
Redaction is heuristic and conservative; traces are intended for local operator use.
- Trace records follow runtime event ordering.
- Duplicate sequence IDs are skipped by the trace writer.
- Recommended for incident debugging, tool-flow audits, and model-behavior analysis.
- JSONL runtime traces and
-vlogging are independent and can be combined.