Repository navigation
Description
Summary
In a long mecatui session, turns frequently end with no output and require a manual re-kick: the agent reaches done (idle) with an empty/truncated assistant turn shown as ↑0 ↓0 · 30s, and the user must send another message to get it going again. Reported behaviour: "it starts responding, the response gets truncated, then I need to send a message to re-kick the agent."
Observations (live session, deepseek/deepseek-v4-flash over OpenRouter)
- Multiple turns ended
↑0 ↓0 · 30s→done, with no visible output, after a tool result. Sending any user message revives it. - The
30smatches the configuredper_attempt_timeout=30s(resilience config:max_attempts=3 per_attempt_timeout=30s stream_idle_timeout=2m0s) — strongly suggesting a timeout interaction rather than a clean end-of-turn. - A separate but related symptom: some turns that did produce a large visible output still reported
↑0 ↓0usage, and the footer context meter reads0% · 0/1Mdespite a clearly large conversation (cumulative↑748.5K).openai/stream.go mapUsagemapsresponse.completedusage verbatim; when OpenRouter omits usage on a turn, it's recorded as{0,0}with no fallback, which also corrupts the context meter.
Hypotheses (not yet root-caused — needs #81)
- Large main-context turns hit the 30s per-attempt timeout before the first chunk. The main session re-sends its full (~750K-token) context each turn;
deepseek-v4-flashover OpenRouter may exceed 30s to first token, the attempt is cancelled, retried, and after retries presents as an empty cleandone. Notably, subagent turns (fresh, small context) streamed fine in the same session — only main-engine continuation turns appeared to die. - The model returns
response.completedwith empty output (no text, no tool call), the loop's no-progress handling nudges then terminatesStopNoProgress=done.
We could not distinguish these live because the loop emits nothing for either case — see #81.
Why it's currently undiagnosable
The terminal stop reason (StopEndTurn vs StopNoProgress vs StopError vs incomplete/truncated) is a client-only transient event, never logged, and mecatui uses the in-memory store so there's no event-log black box. This bug is blocked on observability + a durable store.
Dependencies
- Needs Observability: surface per-turn stop-reason / usage / stream lifecycle (loop is silent by design) #81 (turn stop-reason / stream-lifecycle visibility) to root-cause.
- Needs mecatui: persist session + event log by default (durable local store) #79 (durable session/event store) to get a post-hoc black box of a repro.
Acceptance
- A repro is captured with a definitive stop reason + stream lifecycle (silent-30s-timeout vs streamed-then-cut vs empty-completion).
- The identified cause is fixed (e.g. tune per-attempt timeout for large-context first-chunk latency; and/or handle empty
response.completedwithout dropping the turn to idle). - Zero-usage turns no longer corrupt the context meter (detect/fallback rather than recording
{0,0}verbatim).
Filed from a live debugging session.
Activity
feat(subagent): project live usage and monotonic tool counts on runni…
feat(subagent): project live usage and monotonic tool counts on runni…
feat(subagent): project live usage and monotonic tool counts on runni…
feat(subagent): project live usage and monotonic tool counts on runni…