Skip to content

mecatui: turns end empty/truncated and require a manual re-kick (↑0 ↓0 · 30s → done) #82

Closed

Description

@JAORMX

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 30s matches the configured per_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 ↓0 usage, and the footer context meter reads 0% · 0/1M despite a clearly large conversation (cumulative ↑748.5K). openai/stream.go mapUsage maps response.completed usage 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)

  1. 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-flash over OpenRouter may exceed 30s to first token, the attempt is cancelled, retried, and after retries presents as an empty clean done. Notably, subagent turns (fresh, small context) streamed fine in the same session — only main-engine continuation turns appeared to die.
  2. The model returns response.completed with empty output (no text, no tool call), the loop's no-progress handling nudges then terminates StopNoProgress = 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

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.completed without 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions