Repository navigation
Description
Summary
DeepSeek V4 Flash via OpenRouter produces incomplete turns (payloads=0, tools=2, replaySafe=no, stopReason=stop) in OpenClaw 2026.5.27 and 2026.5.28. The model worked without issues in 2026.5.26.
Steps to reproduce
- Configure
openrouter/deepseek/deepseek-v4-flashas primary model - Send any message that triggers tool calls (e.g. "search for X" or "read file Y")
- After a few turns, especially when the conversation context grows, the model starts generating partial tool calls — it begins
{"tool_calls": [{"function": {"name": "...but stops mid-JSON withstopReason=stop - Since
replaySafe=no, OpenClaw does not retry the turn — surfaces "Agent couldn't generate a response"
Expected behavior
Incomplete turns from the model should be retried (at least once) even when replaySafe=no, or the underlying cause of partial tool call generation from DeepSeek Flash on OpenRouter should be fixed.
Actual behavior
incomplete turn detected: provider=openrouter/deepseek/deepseek-v4-flash stopReason=stop payloads=0 tools=2 replaySafe=no planningRetries=0/1 reasoningRetries=0/2 emptyRetries=0/1 missingAssistantRetries=0/1 — surfacing error to user
The model receives stopReason=stop (not length, not content_filter), meaning the model itself decided to stop — but it stopped before completing the tool call JSON. OpenClaw then checks replaySafe=no and refuses to retry.
Context
- OpenClaw: 2026.5.28 (also broken on 5.27; worked on 5.26)
- Model:
openrouter/deepseek/deepseek-v4-flash - Provider: OpenRouter (
https://openrouter.ai/api/v1) - OS: Ubuntu 24.04, npm global install
- Install method: npm global
What was tried (did not help)
queue.mode=interrupt+debounceMs=1000session-memory.enabled=falsethinkingDefault=offtimeoutSeconds=120- Compaction adjustments (
reserveTokens=20000,keepRecentTokens=40000)
Workaround
Switching to openrouter/deepseek/deepseek-v4-pro eliminates the issue — Pro completes tool calls reliably. This is expensive compared to Flash.
Notes
deepseek-v4-flashvia native DeepSeek API (api.deepseek.com) reportedly works fine — the issue appears to be specific to the OpenRouter bridge for Flash- The
replaySafe=no+emptyRetries=0/1logic means no retry occurs at all, which makes the agent fully unusable when this happens
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 31, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Current main implements a safer recovery for the reported settled post-tool empty-stop boundary: it runs one isolated, tools-disabled finalizer rather than replaying side-effectful tools. The latest release supplied in context predates the fixing commit, so this is fixed on current main only.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the current settled-tool finalizer, which preserves completed side effects and requests only the missing user-visible response.
Do we have a high-confidence way to reproduce the issue?
Yes, source-reproducible: current-main logic explicitly recognizes the required-reply, settled-tool, empty-stop boundary described by the newest live report and dispatches an isolated finalizer. This read-only review did not run a live provider.
Is this the best way to solve the issue?
Yes: a tools-disabled finalizer is safer than blindly retrying the original replay-unsafe turn because it retains the settled transcript without re-executing tools.
Security review:
Security review: No proposed patch is under review.
AGENTS.md: found and applied where relevant.
What I checked:
src/agents/embedded-agent-runner/run/terminal-resolution.ts:162, 1c80cf86cfd0)src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:183, 1c80cf86cfd0)src/agents/harness/builtin-openclaw.ts:115, 1c80cf86cfd0)src/agents/embedded-agent-runner/run/terminal-resolution.test.ts:616, 1c80cf86cfd0)src/agents/embedded-agent-runner/run/settled-turn-finalization.ts:73, 9a0ea5d69b6e)Likely related people:
src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts,src/agents/embedded-agent-runner/run/terminal-resolution.ts)src/agents/embedded-agent-runner/run/settled-turn-finalization.ts,src/agents/harness/builtin-openclaw.ts)Codex review notes: model internal, reasoning high; reviewed against 1c80cf86cfd0; fix evidence: commit 9a0ea5d69b6e, main fix timestamp 2026-08-10T13:24:11-07:00.
mondychan commentedon Jun 1, 2026
quick and dirty fix is changing the config key
from
"api": "openai-completions",
to
"api": "anthropic-messages",
DaleXiao commentedon Jun 8, 2026
Additional live repro: github-copilot + claude-opus-4.8,
stopReason=toolUsevariant (OpenClaw 2026.6.1)Confirming this class of incomplete-turn failure on a different provider/model, with the
replaySafe=no+tools>0combination — providing the live repro this issue is tagged as needing (needs-live-repro).Environment:
2026.6.1 (2e08f0f)github-copilot/claude-opus-4.8(api:anthropic-messages, contextWindow 1M)Log signature (reproduced dozens of times in a single session):
User receives:
⚠️ Agent couldn't generate a response. Note: some tool actions may have already been executed…— the real assistant reply is discarded and replaced with this fallback.Trigger conditions:
exec/edit), hencereplaySafe=no.claude-opus-4.7; failover events still surfaced the same error.tools=0 replaySafe=yesvariant also occurs in the same session.How this differs from existing open work: this is the
stopReason=toolUsevariant — distinct from thestopReason=stopafterupdate_plancase in #80918, and from thestopReason=length/missingtruncation in #89160 (whose tests explicitly asserttoolUseis not flagged as truncated). None of the current open PRs appear to address this exacttoolUse + tools>0 + replaySafe=nocombination.Happy to provide a full session transcript or run targeted diagnostics on this live environment if a maintainer wants more signal.
lileilei-camera commentedon Jun 8, 2026
同样遇到了类似问题,使用 deepseek-v4-pro (deepseek-art/deepseek-v4-pro) 时,模型经常在最后一轮 stop 后只输出 thinking 块没有实际回复内容,且 emptyRetries=0/1 意味着完全不会重试。
这个问题非常影响使用 —— agent 对话经常无响应就停了,用户那边看到的是空消息。希望能提高优先级解决,至少在思考模型产出空内容时能自动触发一次重试(比如把 thinking 降级为 visible text 再回传)。
谢谢!
dante4567 commentedon Jun 14, 2026
Still reproduces on 2026.6.6 (filed here against 2026.5.27/28). Adding a live repro + an isolation result that should narrow this to the embedded agent runner rather than the provider/backend.
Environment
8c802aa), gateway as a systemd user service, embedded runtime.openrouter/deepseek/deepseek-v3.2(primary), reasoning model,tools.profile: "coding".tools=Nranges 1–13.Log signature (representative)
replaySafe=no→ no retry bucket applies, so it surfaces directly to the user/cron:(One cron turn:
outcome=error duration=346534ms— i.e. the turn ran for minutes before surfacing.)Isolation result — it is NOT the OpenRouter backend
I tested every tool-capable OpenRouter backend for
deepseek/deepseek-v3.2directly against the OpenRouter API (bypassing OpenClaw), pinning each viaprovider: {order:[slug], allow_fallbacks:false}and sending atools[]+reasoning:{effort:"medium"}request that mirrors the gateway's shape:tool_callsAll 7 reachable backends return a well-formed
finish_reason: "tool_calls"with a real tool call — single-tool and multi-tool prompts (e.g. "call get_weather for Tokyo, Paris, London separately"; the model correctly emits one tool call at a time, neverstop). ThestopReason=stop+ pendingtools=Nmalformation does not reproduce against the raw provider — so it appears to originate inside the embedded agent runner's handling of deepseek-v3.2 reasoning+tool turns across the multi-round loop, not in the upstream completion.Note for anyone trying a config workaround
provider.require_parameters: truedoes not help and actively breaks deepseek-v3.2: the gateway's request carries a parameter union (reasoning/include_reasoning+tools+response_format+ …) that no single backend supports in full, so OpenRouter returns404 No endpoints found that can handle the requested parametersand the model fails 100% of turns.Happy to capture a full request/response trace on a live malformed turn if you can point me at the right log level / env flag to dump the embedded-runner round payloads.
dante4567 commentedon Jun 16, 2026
Confirming this still happens in 2026.6.6 with
deepseek-v3.2— and a live repro that narrows the causeWe hit the identical signature on a different deepseek model and two minor versions later, so this isn't Flash-specific or fixed:
8c802aa), system install, systemd user service,tools.profile=coding,reasoningenabledopenrouter/deepseek/deepseek-v3.2(primary), multi-round reasoning+tool turnsNew signal: it is not the model stopping mid-JSON, nor an OpenRouter-bridge defect (at least for v3.2)
The summary here hypothesizes the model "stops before completing the tool call JSON" and that it's "specific to the OpenRouter bridge." We tested that directly. A read-only harness hits the OpenRouter API itself, pinning each tool-capable
deepseek-v3.2backend (provider.order=[slug],allow_fallbacks=false) and mirroring the gateway request shape (atools[]function +reasoning). On a single-round tool prompt every reachable backend returns a well-formedfinish_reason="tool_calls"with a populatedtool_calls[]:So a single tool round is faithful end-to-end at the provider. The
stopReason=stop+tools>0malformation only surfaces inside the gateway's multi-round reasoning+tool loop — which points at the runner's round assembly / replay-safety classification rather than the model or the OpenRouter bridge.Dead ends (so others can skip)
require_parameters: trueon provider params backfires → OpenRouter 404, model dies 100%. Rolled back.Re the product decision (
needs-product-decision)This strengthens the case for making the turn replay-safe when
tools>0&&hasLastAssistant=yes&&payloads=0(re-issue the round) rather than surfacing an error with zero retries. In our data the turn is otherwise recoverable — the prior assistant message is intact and no payload was emitted, yetreplaySafe=nospends none of the retry budgets.Happy to share the repro harness or adapt it to a minimal gateway-side reproduction.
DaleXiao commentedon Jun 17, 2026
Follow-up to our
claude-opus-4.8repro above (comment): a config-level workaround that empirically eliminated the symptomTo be explicit up front: this is a workaround, not a root-cause fix. We did not touch the runner's replay-safety classification (the
replaySafe=no+ zero-retry path is unchanged). We changed model/reasoning config and thetoolUseincomplete-turn signature stopped firing in our environment. Sharing the before/after in case it helps others triaging the same signature, and to narrow where the trigger lives.What we changed (single hot-reload, 2026-06-14 18:32 local)
Two edits, applied together via config hot-reload + gateway restart:
reasoningexplicitly per github-copilot model (previously the provider'smodels[]was empty{}and inherited default metadata):claude-opus-4.8:reasoning: trueclaude-opus-4.7:reasoning: falseclaude-opus-4.6:reasoning: falseparams.thinking: "off"on theclaude-opus-4.7fallback.Session-level reasoning was also off for the interactive session.
Before/after (gateway
incomplete turn detectedcounts, same machine, same OpenClaw version)The OpenClaw version did not change across this window (steady
2026.6.5), so the config edit was the only variable:incomplete turn detected(toolUse variant)18:32:49Last emitted line, 17s after the hot-reload landed and just before the restart:
Nothing with this signature has fired since.
What this suggests (not proves)
The trigger appears sensitive to the reasoning/thinking configuration of the active + fallback models, not just the provider bridge. Turning reasoning off (and pinning the fallback's
thinking: "off") on the github-copilotanthropic-messagespath made thetoolUse + replaySafe=nomalformation stop surfacing entirely in our traffic.Caveat / honesty: this is an empirical correlation (symptom gone, timestamps aligned, single changed variable over a steady version) — not a confirmed source-level fix. The underlying product question from the summary still stands: when
tools>0 && hasLastAssistant=yes, the turn surfaces an error while spending none of its retry budgets. A reasoning/thinking config change shouldn't be what's load-bearing here.Happy to share the exact config diff or run targeted diagnostics on this live environment if a maintainer wants more signal.
24 remaining items
Suidge commentedon Aug 17, 2026
Additional live reproduction on a different routing chain:
2026.7.1-2 (0790d9f)volcengine-plan/deepseek-v4-flashopenai-responsesagentTurncron sessionsIn all four sessions, the model first produced a valid tool call (
stopReason=toolUse). The tool completed successfully and returned a normal result. On the follow-up model turn, DeepSeek V4 Flash returnedstopReason=stopwith an empty text block and zero output tokens. OpenClaw then surfaced:Because the completed tool might have had side effects, the run was marked replay-unsafe and was not automatically retried. A controlled minimal tool-follow-up test reproduced the same boundary four times with DeepSeek V4 Flash (
0/4successful final replies), whileark-code-latest,glm-5.3, anddeepseek-v4-proeach completed the same pattern successfully (4/4). Plain text-only DeepSeek V4 Flash turns also succeeded.This suggests the failure is specifically at the post-tool continuation boundary and is not limited to the original OpenRouter/OpenAI-completions route. A safe recovery should continue to avoid replaying tools with uncertain side effects; the newer tools-disabled finalizer after exact settled-tool evidence appears to be the appropriate direction for this case.