You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Observability: surface per-turn stop-reason / usage / stream lifecycle (loop is silent by design) #81
When the agent behaves abnormally (e.g. a turn ends empty, or stops early), there is no durable or live signal explaining why. We ran a long session with --perf --perf-mcp and still could not tell whether dead turns were no_progress, error, a truncated stream, or a timeout — because the loop is silent by design and the rich signal is client-only and transient. This issue is to add turn-semantics observability that doesn't violate the loop's 3-line invariant.
Why it's hard today
The loop emits exactly THREE lines (compaction-fail, policy-deny, drain-abandon) — by design. Confirmed live: across a whole session of abnormal turns, the diagnostic log emitted nothing.
The rich signal is client-only and transient.StopReason, EvNoProgress, EvResult.Usage ride the session.Event stream → shown for a blink in the TUI as done, then gone. Never durable.
The resilience wrapper is mute — retries, per-attempt timeouts, idle-timeout fires, breaker trips: all unlogged.
perf gives runtime observability (CPU/heap/goroutines/latency) but no turn semantics.
Proposed additions (ranked by leverage)
Stop-reason-labeled turn metrics on the perf surface.mecatl_turns_total{stop,role} + a turn_empty_total{role} counter. stop is a closed enum → safe label, no cardinality leak; role reuses the existing closed roleFamily set. Then perf://metrics/summary instantly shows "N turns ended no_progress/error/empty." Metrics ≠ diagnostics, so the 3-line invariant is untouched.
--debug-events live tail. The relay already sees every session.Event; tee the full taxonomy (incl. EvNoProgress, EvResult.Stop, EvToolCall) to the diag log (DEBUG) or a sidecar file. Gated; loop untouched.
Stream-lifecycle DEBUG in the adapter. Log first-chunk latency, chunk count, text/reasoning bytes, terminal event (response.completed/incomplete/idle-timeout/per-attempt-timeout). The missing piece to separate upstream truncation from model-stops-early from timeout. Log-level gated.
Activity