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
Bug: chat turn generation hard-fails with "Agent returned empty response" while the model returned 314 text tokens — 5 dead turns in 28 min for one demo user (08-12) #3110
Source: GlitchTip sweep of demo.tale.dev, 2026-08-31. Not covered by #3100 (backend micro-stalls — different failure), #3088 (auth refusals), or #2767 (human-input banner cosmetics in the same UI area).
Evidence
TALE-PROJECT-113 — Uncaught NonRetryableError: Agent generation failed: {"message":"Agent returned empty response: …"} at handler (convex/agents/chat_turn_generate.ts:692), func agents/chat_turn_generate:runChatTurnGeneration (node runtime) — 5 events in 28 minutes, 2026-08-12T13:02:17Z → 13:30:33Z, then quiet. One demo user retried chat five times in half an hour and every turn died.
The contradiction that makes this a pipeline bug, not a provider hiccup: the error payload itself embeds the provider usage of the "empty" response — model anthropic/claude-sonnet-4.6, inputTokens 8864, outputTokens 355 of which textTokens 314 and reasoningTokens 41. The model returned ~314 tokens of text and the pipeline still classified the response as empty, then threw NonRetryableError — no retry, turn dead.
Same-window signal worth one look while in there: TALE-PROJECT-10O — Stream is not streaming; did it timeout? from @convex-dev/persistent-text-streaming via streaming/internal_mutations:appendToStream, 2 events 2026-08-07T21:40Z / 2026-08-12T12:56Z — a persistent stream dying minutes before the 13:02 failures; possibly the same stall, possibly unrelated.
Read
chat_turn_generate.ts is private-overlay (ships in the demo build; the public tree's convex/agents/ carries only file_actions/file_utils/validators). The emptiness guard at :692 fires on a generation whose raw usage proves non-empty text output. Likeliest shapes: the extractor reads the wrong field of the provider response (e.g. checks a top-level text while the content landed in a parts array as reasoning-then-text), or streamed aggregation lost the text before the guard ran. Because the guard throws NonRetryableError, the user gets a dead turn even where a retry or correct extraction would have produced content.
Fix direction
Reproduce against anthropic/claude-sonnet-4.6 via the demo provider path and compare what the guard at chat_turn_generate.ts:692 sees vs the raw provider response (reasoning + text parts ordering is the prime suspect).
Fix extraction so a text-bearing response can never classify as empty; keep the guard for genuinely empty responses.
Reclassify genuinely-empty generation as retryable (it is transient provider behavior), or at minimum surface a user-actionable message instead of an uncaught NonRetryableError.
Check whether the 10O stream-timeout path can eat a slow turn's text (same 08-12 window) — if yes it is the same defect seen from the other side.
Acceptance
A turn whose provider response contains text never fails with "Agent returned empty response".
TALE-PROJECT-113 stays flat; a forced genuinely-empty response yields a retried turn or a clear user-facing error, not an uncaught NonRetryableError; TALE-PROJECT-10O explained (folded here or explicitly ruled unrelated).
Closing as obsolete. The guard and its NonRetryableError exist nowhere at v0.5.58. The direct pipeline settles a reply without text as completed and stores stream failures as structured message errors (services/platform/lib/chat/turn.ts); on the agent-harness path any text, tool call or output token counts as an answer, and empty_turn is retried automatically.
Activity
yannickmonney commentedon Sep 27, 2026
Closing as obsolete. The guard and its
NonRetryableErrorexist nowhere at v0.5.58. The direct pipeline settles a reply without text ascompletedand stores stream failures as structured message errors (services/platform/lib/chat/turn.ts); on the agent-harness path any text, tool call or output token counts as an answer, andempty_turnis retried automatically.