openclaw - 💡(How to fix) Fix Gateway silently drops user message when every model in fallback chain returns empty assistant turn (no tool calls, zero usage) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#81459Fetched 2026-05-14 03:31:59
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
2
Author
Timeline (top)
commented ×2closed ×1

On 2026-05-13 at 07:53 EDT a user message hit the agent:main:main session, the gateway ran through the full configured model fallback chain, and every single attempt came back as an assistant turn with stopReason="stop", zero content blocks, and zero usage tokens (input/output/cacheRead/cacheWrite/total == 0). The gateway treated each empty completion as a successful turn, exhausted the fallback chain, did not surface an error to the user-facing channel, and ended the run. From the user's side it looked like the assistant ignored the message.

This appears to be the gateway-level failure mode behind a separately-reported "Telegram <-> webchat bridge" symptom; the bridge itself is fine (session.dmScope = "main", transcript is shared), the issue is that the assistant turn produced no content and the gateway shipped that silent success downstream.

Related but distinct from #46080 — that issue is the tool_use → tool_result → empty final-assistant-turn path. This issue has no tool calls involved, empty on the very first turn, across the entire fallback chain, and zero usage tokens (the model was effectively never invoked, or its response was discarded before tokenization completed).

Error Message

On 2026-05-13 at 07:53 EDT a user message hit the agent:main:main session, the gateway ran through the full configured model fallback chain, and every single attempt came back as an assistant turn with stopReason="stop", zero content blocks, and zero usage tokens (input/output/cacheRead/cacheWrite/total == 0). The gateway treated each empty completion as a successful turn, exhausted the fallback chain, did not surface an error to the user-facing channel, and ended the run. From the user's side it looked like the assistant ignored the message. The whole chain completed in ~30 seconds. Combined with the zero token counts on every attempt, this is not the model "deciding" to emit nothing — the provider is returning a successful response with no content and no usage, or the gateway is mis-classifying an error/abort as an empty success. Treating it as a valid assistant turn is the bug. 2. After N consecutive empty turns across the fallback chain, surface a user-visible error on the originating channel (e.g. "model returned empty response, please retry") instead of ending the run silently. // continue fallback chain, then surface error if all attempts empty

Root Cause

On 2026-05-13 at 07:53 EDT a user message hit the agent:main:main session, the gateway ran through the full configured model fallback chain, and every single attempt came back as an assistant turn with stopReason="stop", zero content blocks, and zero usage tokens (input/output/cacheRead/cacheWrite/total == 0). The gateway treated each empty completion as a successful turn, exhausted the fallback chain, did not surface an error to the user-facing channel, and ended the run. From the user's side it looked like the assistant ignored the message.

This appears to be the gateway-level failure mode behind a separately-reported "Telegram <-> webchat bridge" symptom; the bridge itself is fine (session.dmScope = "main", transcript is shared), the issue is that the assistant turn produced no content and the gateway shipped that silent success downstream.

Related but distinct from #46080 — that issue is the tool_use → tool_result → empty final-assistant-turn path. This issue has no tool calls involved, empty on the very first turn, across the entire fallback chain, and zero usage tokens (the model was effectively never invoked, or its response was discarded before tokenization completed).

Code Example

if (assistantContent.length === 0 && usage.totalTokens === 0 && !aborted && !timedOut) {
  markAttemptEmpty();
  // continue fallback chain, then surface error if all attempts empty
}
// after fallback chain exhausted:
if (allAttemptsEmpty) {
  emitTrajectoryEvent("gateway.empty_completion_chain_exhausted", { attempts });
  deliverUserVisibleError("model returned empty response across all fallback models, please retry");
}
RAW_BUFFERClick to expand / collapse

Summary

On 2026-05-13 at 07:53 EDT a user message hit the agent:main:main session, the gateway ran through the full configured model fallback chain, and every single attempt came back as an assistant turn with stopReason="stop", zero content blocks, and zero usage tokens (input/output/cacheRead/cacheWrite/total == 0). The gateway treated each empty completion as a successful turn, exhausted the fallback chain, did not surface an error to the user-facing channel, and ended the run. From the user's side it looked like the assistant ignored the message.

This appears to be the gateway-level failure mode behind a separately-reported "Telegram <-> webchat bridge" symptom; the bridge itself is fine (session.dmScope = "main", transcript is shared), the issue is that the assistant turn produced no content and the gateway shipped that silent success downstream.

Related but distinct from #46080 — that issue is the tool_use → tool_result → empty final-assistant-turn path. This issue has no tool calls involved, empty on the very first turn, across the entire fallback chain, and zero usage tokens (the model was effectively never invoked, or its response was discarded before tokenization completed).

Evidence

Trajectory file: ~/.openclaw/agents/main/sessions/7f3a8844-3092-4456-b424-2ea147aa0014.trajectory.jsonl

  • traceSchema: openclaw-trajectory, schemaVersion: 1
  • sessionKey: agent:main:main
  • provider: anthropic, modelApi: anthropic-messages
  • finalPromptText: "[Wed 2026-05-13 07:53 EDT] when do you think testing will begin on metatrader strategy tester?"

Ten consecutive model.completed events, each with the assistant message in data.messagesSnapshot having content: [], usage.totalTokens: 0, stopReason: "stop", and promptErrorSource: null:

ts (UTC)modelIdstopblockstotalTokens
2026-05-13T11:53:14.784Zclaude-opus-4-7stop00
2026-05-13T11:53:18.080Zclaude-opus-4-7stop00
2026-05-13T11:53:20.772Zclaude-sonnet-4-6stop00
2026-05-13T11:53:22.982Zclaude-sonnet-4-6stop00
2026-05-13T11:53:26.994Zclaude-opus-4-6stop00
2026-05-13T11:53:30.732Zclaude-opus-4-6stop00
2026-05-13T11:53:34.162Zclaude-opus-4-5stop00
2026-05-13T11:53:37.534Zclaude-opus-4-5stop00
2026-05-13T11:53:41.013Zclaude-sonnet-4-5stop00
2026-05-13T11:53:44.726Zclaude-sonnet-4-5stop00

That's the entire configured fallback chain (claude-opus-4-7claude-sonnet-4-6claude-opus-4-6claude-opus-4-5claude-sonnet-4-5), each attempted twice (consistent with DEFAULT_EMPTY_RESPONSE_RETRY_LIMIT = 1), every one returning empty.

The whole chain completed in ~30 seconds. Combined with the zero token counts on every attempt, this is not the model "deciding" to emit nothing — the provider is returning a successful response with no content and no usage, or the gateway is mis-classifying an error/abort as an empty success. Treating it as a valid assistant turn is the bug.

A second occurrence was observed the same day in session 9a7a035e-... for the prompt "look in the V14 folders" (23:04 EDT 2026-05-12). Same pattern: full fallback chain, every attempt content:[], totalTokens:0. Session was later reset (...jsonl.reset.2026-05-13T11-14-23.357Z).

Expected behavior

When an assistant turn returns zero content blocks and zero output tokens (usage.totalTokens == 0) and was not aborted/timed-out, the gateway should:

  1. Not count it as a successful assistant turn.
  2. After N consecutive empty turns across the fallback chain, surface a user-visible error on the originating channel (e.g. "model returned empty response, please retry") instead of ending the run silently.
  3. Emit a structured gateway.empty_completion trajectory event so this is queryable post-hoc instead of having to detect it from data.messagesSnapshot[*].content == [].

Actual behavior

All 10 empty completions are recorded as model.completed with no distinguishing flag. The run ends. The user-facing channel receives nothing. The user perceives the assistant as having ignored the message. The existing EMPTY_RESPONSE_RETRY_INSTRUCTION / DEFAULT_EMPTY_RESPONSE_RETRY_LIMIT = 1 machinery in dist/plugin-sdk/src/agents/pi-embedded-runner/run/incomplete-turn.d.ts is firing (each model is retried once), but the terminal "all models exhausted with empty" state is not surfaced.

Suggested fix area

A check in the gateway turn-completion path along the lines of:

if (assistantContent.length === 0 && usage.totalTokens === 0 && !aborted && !timedOut) {
  markAttemptEmpty();
  // continue fallback chain, then surface error if all attempts empty
}
// after fallback chain exhausted:
if (allAttemptsEmpty) {
  emitTrajectoryEvent("gateway.empty_completion_chain_exhausted", { attempts });
  deliverUserVisibleError("model returned empty response across all fallback models, please retry");
}

Environment

  • OpenClaw version: 2026.5.7
  • provider: anthropic (first-party Anthropic API, not a custom provider — distinguishes from #46080)
  • modelApi: anthropic-messages
  • session.dmScope: main
  • workspaceDir: /Users/egerges/.openclaw/workspace
  • Dates observed: 2026-05-12, 2026-05-13
  • Trajectory schema: openclaw-trajectory v1

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When an assistant turn returns zero content blocks and zero output tokens (usage.totalTokens == 0) and was not aborted/timed-out, the gateway should:

  1. Not count it as a successful assistant turn.
  2. After N consecutive empty turns across the fallback chain, surface a user-visible error on the originating channel (e.g. "model returned empty response, please retry") instead of ending the run silently.
  3. Emit a structured gateway.empty_completion trajectory event so this is queryable post-hoc instead of having to detect it from data.messagesSnapshot[*].content == [].

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Gateway silently drops user message when every model in fallback chain returns empty assistant turn (no tool calls, zero usage) [2 comments, 2 participants]