Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Summary
For openai-completions reasoning models whose API does not require reasoning_content on assistant messages (e.g. gemma4 / Gemma-4-12B on vLLM), OpenClaw drops the model's in-turn reasoning when replaying multi-turn tool conversations. Since the provider doesn't 400 on the missing field (unlike DeepSeek/Moonshot/Xiaomi), the failure is silent: no error, just degraded multi-step tool behavior — tool-call arguments intermittently collapse to {}, and the model re-issues identical tool calls because it can't see its own prior reasoning.
This is distinct from the known API-compat issues (#70392, #81419, #91558, #89660, #91106): those inject an empty reasoning_content: "" to satisfy strict provider schemas and avoid a 400. Here the provider is fine without the field — what's missing for quality is the real in-turn reasoning text, so the model keeps continuity across tool calls.
Evidence (captured off the wire)
TCP tee between OpenClaw and vLLM; one multi-turn tool exchange via openclaw agent --local --thinking high. Deepest request OpenClaw sent (system, user, 3× assistant tool-call, 3× tool):
- ✅ structured
tool_callspreserved - ✅ tool-call / tool-result IDs match exactly
- ❌
reasoning_contentpresent on 0 / 3 in-turn assistant tool-call messages
The Gemma 4 chat template re-injects in-turn reasoning (reasoning/reasoning_content → <|channel>thought…<channel|>, gated to messages after the last user turn — it correctly keeps in-turn reasoning and drops completed-turn reasoning). OpenClaw sends nothing, so re-injection never fires. Across stored trajectories on this install: 13 exec calls with empty arguments (exec requires a command), plus repeated identical tool calls within sessions.
Suspected root cause
reasoningContent appears empty at replay for these models, so the existing populate path never runs:
if (reasoningContent.length > 0) assistantMsg.reasoning_content = reasoningContent.join("\n");
else if (allowReasoningContentReplay) /* inject empty placeholder */requiresReasoningContentOnAssistantMessages only governs the else (empty-field API-compat shim) and so does not restore real reasoning. The gap looks upstream: in-turn reasoning isn't carried from the session store into reasoningContent for openai-format models that aren't on the DeepSeek/Xiaomi detect list. (Same populate code in 2026.6.1 and 2026.6.5-beta — not a regression.)
Proposed direction
Preserve real in-turn reasoning (reasoning generated since the last user message) on replayed assistant tool-call messages for openai reasoning models, independent of the empty-field API-compat path. This matches what the Gemma model card + chat template assume, and the community reports of the same symptom (Gemma-4-12B tool-calling PSA on r/LocalLLaMA; Qwen3.6 analogue: earendil-works/pi#3325 — "after 2-3 turns every tool call collapses to arguments: {}").
Steps to reproduce
- Configure a gemma4 model via
api: openai-completionson vLLM,compat.thinkingFormat: "openai",reasoning: true. - Run a multi-step agent task that needs 2+ sequential tool calls,
--thinking high. - Capture the request bodies OpenClaw sends to the model (LLM proxy / tee).
- Observe: in-turn assistant tool-call messages carry
tool_callsbut noreasoning_content; over several turns, arguments degrade / tool calls repeat.
Environment
- OpenClaw 2026.6.1
- Gemma-4-12B (NVFP4) via vLLM 0.22,
api: openai-completions,compat.thinkingFormat: "openai",reasoning: true,--thinking high
Workaround
Make each tool action self-contained (a single call returns the final value — e.g. server-computed totals, or a gog | jq | date one-liner) so turns don't depend on cross-turn reasoning. Restores correctness for those flows but doesn't help genuinely multi-step reasoning.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 9, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 9, 2026, 3:30 AM ET / 07:30 UTC.
Summary
Keep open: current main still has a Gemma 4 exclusion in the OpenAI-compatible replay sanitizer, so the reported in-turn reasoning_content preservation gap is not resolved by the existing empty-field compatibility flag or prior DeepSeek/Xiaomi fixes.
Reproducibility: yes. with source-level confidence: current main still has the Gemma 4 replay trust exclusion and the issue includes live request-body captures. I did not independently rerun vLLM/Gemma in this read-only review.
Next step
The issue is concrete, but the fix needs maintainer judgment on the Gemma same-turn replay policy before an automated repair lane should change provider behavior.
Review details
Best possible solution:
Keep the issue open for a maintainer-owned provider replay decision: preserve real same-turn Gemma/OpenAI-compatible reasoning only when the provider emitted replayable reasoning, while keeping completed-turn stripping where that remains intentional.
Do we have a high-confidence way to reproduce the issue?
Yes, with source-level confidence: current main still has the Gemma 4 replay trust exclusion and the issue includes live request-body captures. I did not independently rerun vLLM/Gemma in this read-only review.
Is this the best way to solve the issue?
Unclear: the requested same-turn exception is plausible, but it changes provider replay policy and should be reviewed by the provider/replay owner before implementation.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f57c3b55fdc4.
Label changes
Label justifications:
P2: The issue affects multi-turn tool quality for a specific OpenAI-compatible local model/provider setup without making the core runtime unusable.impact:session-state: The failure mode is loss of in-turn reasoning state during tool-call replay.impact:auth-provider: The affected surface is provider/model compatibility and OpenAI-compatible reasoning replay behavior.Evidence reviewed
Acceptance criteria:
What I checked:
src/agents/openai-transport-stream.ts:3978, f57c3b55fdc4)src/llm/providers/openai-completions.ts:996, f57c3b55fdc4)src/agents/embedded-agent-runner/thinking.ts:444, f57c3b55fdc4)src/agents/openai-transport-stream.ts:3991, 2e08f0f4221f)src/agents/openai-transport-stream.ts:3978, 5097749de32c)Likely related people:
src/agents/openai-transport-stream.ts,src/agents/embedded-agent-runner/thinking.ts,src/llm/providers/openai-completions.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.bfox55 commentedon Jun 9, 2026
Followed up by testing whether the now-settable
requiresReasoningContentOnAssistantMessagesflag (schema exposed in2026.6.5-betavia #89660) is sufficient. It is not — it injects the field but empty.Method: isolated sandbox install of
2026.6.5-beta.5(separate prefix + HOME, production untouched), gemma4/vLLM model withcompat.requiresReasoningContentOnAssistantMessages: true, routed through a TCP tee to capture the exact request bodies. Multi-step tool task,--thinking high.Result (deepest request, 8 in-turn assistant tool-call turns):
reasoning_contentpresentreasoning_contentnon-empty (real text)""So the flag flips the field from absent to present-but-empty — which is exactly the API-compat behavior (avoid a strict-provider 400), and confirms it does not restore the model's real in-turn reasoning.
The populate path itself is fine and identical across 6.1 and the beta:
The gap is upstream:
reasoningContentarrives empty at replay for openai-format models that aren't on the DeepSeek/Xiaomi detect list, so only the empty-placeholder branch ever runs. Fixing this for non-400 reasoning models (gemma4, etc.) needs the in-turn reasoning to actually be carried intoreasoningContent— the empty-field flag alone won't do it.bfox55 commentedon Jun 9, 2026
Thanks for the detailed triage — I can close the
needs-live-reprogap. This report is from a live vLLM / Gemma-4-12B run, not source inspection, and the wire evidence lines up exactly with your source trace (which is more precise than my original "arrives empty upstream" framing — the field is preserved indropReasoningFromHistory, then stripped by the Gemma-4 exclusion inshouldTrustReasoningContentReplayMetadatabefore serialization).Setup: Gemma-4-12B (NVFP4) on vLLM 0.22,
api: openai-completions,compat.thinkingFormat: openai,reasoning: true. A TCP tee between OpenClaw and vLLM captured the exact request bodies duringopenclaw agent --local --thinking highon a multi-step tool task.Observed on the wire (deepest request, in-turn assistant tool-call turns):
reasoning_contentpresentrequiresReasoningContentOnAssistantMessages: true""In both cases
tool_callsare structured and tool-call/result IDs match exactly — onlyreasoning_contentis missing/empty. The beta+flag result confirms the empty-field path is the API-compat placeholder, not a restore of real reasoning, consistent with the Gemma-4shouldTrustReasoningContentReplayMetadatareturning false.Expected vs actual:
reasoning_content, so the Gemma 4 chat template can re-inject it as<|channel>thought…<channel|>.argumentsoccasionally collapse to{}, and identical tool calls repeat.On the product decision: your proposed boundary — keep completed-turn Gemma reasoning stripped, add a narrow same-turn tool-call replay exception when the provider emitted a replayable reasoning field — matches what the Gemma 4 template already assumes (its re-injection is gated to messages after the last user turn). I'm happy to re-run the tee capture against a candidate fix to confirm
reasoning_contentlands non-empty on the in-turn path.@clawsweeper re-review
clawsweeper commentedon Jun 9, 2026
🦞🧹
ClawSweeper re-review requested.
I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow
sweep.yml, eventrepository_dispatch).Result: the existing ClawSweeper review comment will be edited in place when the review finishes.
Re-review progress:
fix(agents): preserve reasoning_content replay for Gemma 4 openai-com…
fix(agents): preserve reasoning_content replay for Gemma 4 openai-com…