Repository navigation
fix: reasoning-only retry is refused by Anthropic as reasoning_extraction - #184434
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesRewords the reasoning-only continuation prompt and updates the tests and QA fixtures that recognize it. Example: Anthropic returns a signed reasoning-only response with a normal stop.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main retains the affected prompt, and this focused repair has convincing live Gateway evidence with no introduced defect found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe embedded runner classifies incomplete assistant output, selects a bounded continuation, and sends it through the existing session prompt and provider transport owners. flowchart TD
A[Provider response] --> B[Incomplete turn classification]
B --> C[Recovery policy]
C --> D[Session prompt owner]
D --> E[Provider transport]
E --> F[Visible answer or terminal outcome]
Technical reviewBest possible solution: Use the revised instruction in the existing recovery owner while preserving retry eligibility, refusal handling, and stored transcript history. Do we have a high-confidence way to reproduce the issue? Current source confirms the affected request path, and supplied live baseline/candidate traces reproduce the refusal and recovery; this read-only review ran no target code. Is this the best way to solve the issue? This is the smallest complete repair for the demonstrated prompt-triggered refusal: it replaces the instruction at its existing owner and updates all matching consumers without broadening recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against eb82abff6695. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -1, Tests -2, Other 0. Total -3 across 13 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 28, 2026, 7:46 AM ET / 11:46 UTC (Revision 4). |
…tion The reasoning-only continuation told the model its previous turn "recorded reasoning" and asked it to continue that partial turn. Anthropic refuses that request as reasoning_extraction on claude-opus-5-5. Ask for the missing answer without describing the reasoning, in the style of the empty-reply retry, and keep the instruction not to restate it. Update the tests and QA fixtures that match the retry text, and drop the old wording from the QA mock's recovery prefixes. Refs openclaw#182178
8999ac0 to
e44dd76
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…only-wording # Conflicts: # extensions/qa-lab/src/providers/mock-openai/server.test.ts
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Required coverage: #189395, #187875, #186976, #182429, #184434, and remaining #180247. Preserve stable transport and terminal-settlement owners. Include #190695 sampling parity and only the required symbol/export prerequisites. No broad Gemini transport cutover. Source commits: d6a1327 fe0f8d1 cd486ed e72b356 807075d 28f5f25 ab7631a 9346376 054516f Proof: 216 focused tests passed; dedicated pre-fix regressions failed. Scoped typechecks/lint/format passed. Fresh independent P0-P2 review clean. Live provider/native qualification remains pending. Co-authored-by: Yiğit ERDOĞAN <[email protected]> Co-authored-by: evomach <[email protected]> Co-authored-by: Sasan <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: goslingmanagment <[email protected]> Co-authored-by: Dmitriy <[email protected]> Co-authored-by: Sukhdeep Johar <[email protected]> Co-authored-by: Dallin Romney <[email protected]> Co-authored-by: RomneyDa <[email protected]>
…tion (openclaw#184434) The reasoning-only continuation told the model its previous turn "recorded reasoning" and asked it to continue that partial turn. Anthropic refuses that request as reasoning_extraction on claude-opus-5-5. Ask for the missing answer without describing the reasoning, in the style of the empty-reply retry, and keep the instruction not to restate it. Update the tests and QA fixtures that match the retry text, and drop the old wording from the QA mock's recovery prefixes. Refs openclaw#182178
Backport accepted fixes onto 2026.11.5-beta.2. Base: bc061f9 Canonical source tree before commit: e6c0c39 These are adapted/squashed backports; do not claim each is an exact Git cherry-pick. Source provenance (selected verified commits; other cohorts use their frozen patch/adoption manifests): runtime-B: b20a0cc fix(macos): connect with configured credentials despite stale app environment (#191468) c4c0942 fix(update): failed updates from 10.7–10.9 crash in automatic migration recovery (#189713) 6aae408 fix(update): preserve recovery errors and async triage callbacks (#191495) 8910654 fix(macos): prevent first-launch Gateway failures after upgrades (#191436) 00b2ff4 fix: parent sessions miss child approvals with a custom session store (#189827) c6142a8 fix: avoid copying managed plugin binaries during Gateway startup (#187865) e72b356 fix(anthropic): avoid token profile collisions (#187875) 807075d fix(anthropic): set API workspace at login (#186976) bafe92f fix(exec): preserve no-timeout results from macOS app nodes (#190729) 9b05a64 fix(imessage): use a PostgreSQL-safe recovery cursor key (#184919) 6ba197f fix: session search on PostgreSQL scans every transcript row instead of using the text index (#187909) 4f49aa5 fix(sessions): PostgreSQL session search scans every transcript row again after the 5th search on a connection (#188979) de3936c fix(macos): Mac tab shows a blank or stale page when a load fails (#185432) e977080 fix(macos): prevent duplicate voice sends and false sent feedback (#186271) provider-compaction: 1b43c2e fix(compaction): preserve active request provenance (#180214) 7b0cfe3 fix(google): restore tool calls with Python keyword parameters (#191561) 9039ceb fix(ci): keep compaction attribution helpers internal d6a1327 feat(google): use the Interactions API for Gemini Flash models (#189395) fe0f8d1 fix(google): Gemini models ignore configured topP (#190695) history: c51d733 fix(sessions): stop expanding archive reads from exhausting memory (#190690) 3c8bd4d fix(sessions): page oversized earlier history instead of failing at 8 MiB (#188450) b195f61 fix(sessions): page oversized transcript history in both directions (#188483) b65482e fix(gateway): preserve older history across hidden message gaps (#188557) 3d4fc94 fix(sessions): avoid oversized listing and imported-history reads (#189284) 33e7baf fix(sessions): bound active accounting without blocking writers (#190182) 682ade7 fix: preserve chat history continuation metadata (#188612) runtime-C: 7e005b0 fix(macos): keep secrets when a Gateway config save fails (#187734) 15cf738 fix(macos): keep Gateway auth when Tailscale exposure is turned off (#187664) b53a06b perf(update): read candidate state inventory without copying the shared database (#187921) 970fc4e fix: restore CLI message sends with agent tool policies (#188058) 73ad731 fix: stop model fallback when session capability metadata changes (#179312) 32305db fix: subagent turns fail after session metadata changes (#183501) d13bd0f fix(codex): include relay conversation instructions in trajectory (#189005) e375530 fix: replies after a plugin reload from Control UI go to the session's last external chat (#190982) 9346376 fix: reasoning-only retry is refused by Anthropic as reasoning_extraction (#184434) direct-auth-state: 1b15408 fix(models): keep the model list when one plugin-owned provider lacks a credential (#189014) 7d8dc60 fix: recover startup migration with retained worker index (#189023) capacity: 41772e3 fix(worktrees): settle completed disk debt on refused postchecks (#188727) command-once-189369: 8269137 fix(plugins): plugin commands that continue the agent run three times on native command turns (#189369) pg-board-189564: 7232a8d fix(boards): publish widgets with PostgreSQL storage (#189564) queued-edit-189869: 92b32ca fix: hold queued messages through inline edits (#189869) Preserve source attribution from original commits. For a genuinely exact individual pick only, use the conventional (cherry picked from commit <sha>) line. Full file-level provenance: coverage-manifest.json; reviewed patch hashes: artifact-registry.json. No held136/native82 content adopted by this work. No release or full-candidate qualification claim. Additional original-source identities (exact adapted hunk scope is in frozen artifacts): release-guides-185258: 39c37e6 docs(release): define ledger-first hotfix routing (#185258) UI-history: 10a6e4f fix(ui): scope provider-add discovery warning to its own provider (#188541), 3d7b4c4 fix(ui): never fail loading earlier chat history without a boundary (#188372) obsolete-cache-188203: 90d82c2 fix: preserve completed reasoning and refill chat snapshots (#188203) webhook-169778: b1f643f fix(startup): keep webhook decisions startup recorded for channels Doctor left pending (#169778) schema-lease-188391: ba6cfcd fix(state): keep lease renewal independent of parent admission (#188391) backfill-188976: c75a8a8 fix(gateway): stop session row backfill once the Gateway is closing (#188976) canonical-disable-188846: 88b56ee fix(config): auto-enable reads and writes mixed-case plugin policy under the canonical id (#188846) matrix-177272: 5a6d22c fix(matrix): stop seeding new thread sessions from the room transcript (#177272) provider-hook-189059: 0588f51 fix(models): isolate every per-provider catalog failure (#189059) unicode-189868: 87396e7 fix(oc-path): avoid reading and editing a different Unicode key (#189868) replay-cohort: 2031044 fix(sessions): acknowledge committed input retries without duplicate turns (#188527), 9114431 fix: resume configured fallback after interrupted attempts (#188672) Co-authored-by: RomneyDa <[email protected]>
Closes #182178
What Problem This Solves
Fixes: on Anthropic (
anthropic-messages,claude-opus-5-5), a turn that ends with only reasoning gets no answer, because Anthropic refuses OpenClaw's own retry prompt asreasoning_extraction, and the user is then told to "Revise the request" they did not write.User Impact
User impact: when a reply ends with only reasoning, the automatic retry now gets an answer instead of a refusal.
The output-limit case was already fixed by #182429; this covers the normal-stop case that stayed open.
Chats where the old retry text already ran keep it in their history. In one short test chat that kept later messages refused (3 of 3; 0 of 3 with only that text swapped); the reporter's long chat did not show it. Such a chat recovers with
/new. Rewriting stored history was left out on purpose.Not included: changing the refusal notice. The new retry text was not refused in any run, so the notice no longer appears on this path. Can add it if wanted.
Why This Change Was Made
The retry text told the model its previous turn "recorded reasoning" and asked it to continue that partial turn. With everything else identical, Anthropic refused that text every time and accepted the new text every time (see Evidence). The new text asks for the missing answer without describing the reasoning, in the same style as the existing empty-reply retry, and keeps the instruction not to restate the reasoning. It is one product line; the rest of the diff updates tests and QA fixtures that match the retry text.
Evidence
Live A/B on Anthropic
Direct Messages API calls with OpenClaw's thinking settings for this model (adaptive thinking,
display: "summarized", effortxhigh). Every run sent the same conversation: a user question, one real assistant turn reduced to its signed thinking block (a reasoning-only turn), then the retry text as the next user message. Only that last message changed.reasoning_extraction)The current text was refused before any output (0 output tokens). In the report, refusals came after 496 to 2,475 output tokens, so the output may be judged as well; the new text completed all 42 runs (about 1,000 output tokens each) without a refusal. None of the answers described their own reasoning.
Isolated Gateway on the real Anthropic route
Two isolated Gateways (unchanged main and this PR), real
anthropic-messagesroute with the default base URL,claude-opus-5-5, thinkingxhigh, no fallback models. A local proxy forwarded every request to Anthropic and, for each turn's first reply, removed the text blocks from Anthropic's real response, so OpenClaw received a genuine reasoning-only turn with a thinking block signed for that conversation. The retry went to Anthropic unmodified.reasoning_extraction); user told to revise the requestGateway run output (redacted): reasoning-only stop, generated retry, result
Proxy lines are the local proxy between the Gateway and
api.anthropic.com("text removed" = it dropped the text block from Anthropic's real reply, leaving the signed thinking block;kind=retry= the newest user message carries the reasoning-only retry text). Gateway lines are OpenClaw's own log. The opaquefallback_credit_tokenin the refusal is replaced with<redacted>.main (
872cb2afe98), turn 1:A later request in the same chat on main carried the retry it had sent, stored in history as a user message: "The previous assistant turn recorded reasoning but did not produce a user-visible answer. Continue from that partial turn and produce the visible answer now. Do not restate the reasoning or restart from scratch."
This PR (
8999ac08b98; product line identical to the current head), the chat's turns 1 and 3 (turn 2's reply had no thinking block, so it was passed through unstripped; the proxy numbers only the turns it stripped, so it labels the chat's turn 3 "turn 2"):The Anthropic and GPT/Gemini runs used this branch's first commit, which also carried a refusal-notice change that has since been removed; it only acted after a refused retry, and no retry was refused on this branch, so it never ran.
Proof gap: conversations were short (about 2k tokens for the A/B, a few turns through the Gateway) rather than the reporter's ~142k-token chats.
Tests
run.session-prompt-state.test.ts: the check that the empty-reply retry replaced the reasoning-only retry now looks for a phrase only the reasoning-only retry has, since both now share their first sentence. It fails if the two are mixed up.main(98c56569b53): a test cleanup renamed the QA mock server's retry constant, so the new text moved toreasoningRetry; the compaction replay e2e test now matches the shorter phrase "answer the user's request now", which only the new text contains, so this PR adds no test lines. On the merged head the recovery, terminal-resolution, session prompt state, shared integration and QA mock server tests and the compaction replay e2e test pass.subagent-registry.requester-wake.e2e.test.ts> "drains a restored interrupted predecessor before later cohorts when registry order differs", which fails the same way on unchanged main (872cb2afe98, 2 of 2 runs) and does not reach the changed branch.tsgo:core,tsgo:test:src,tsgo:extensions:test,tsgo:test:root: clean on the final head. oxfmt and oxlint on the changed files: clean.8b02f657ebc): one failure,gateway-kill-restart-send.e2e> "recovers a killed run and replies" (the recovered reply has noreplyToId). It fails the same way on unchangedmain(98c56569b53, 3 of 3 runs) and on this head (3 of 3), and does not use the retry text. The four QA-lab tests that failed on the previous head pass now.GPT and Gemini (shared retry)
Same Gateway setup through OpenRouter's chat-completions route, with the visible text removed from the model's real reply so OpenClaw got a reasoning-only turn:
openai/gpt-6.1-sol: retry gave a visible answergoogle/gemini-4-argon: retry gave a visible answerGPT returned no reasoning on 3 of 5 turns per build here, so only 2 turns per build reached the retry; the OpenAI-route run below has more. The one thinking case was Gemini putting its thoughts in the visible reply on the fifth turn of one chat; it did not recur in 15 later turns. Neither model refused either text.
GPT on OpenAI's own route (Responses API)
Same setup against
api.openai.com,openai/gpt-6.1-sol, thinkinghigh; the assistant message was removed from GPT's real streamed reply and its reasoning item kept.agentRuntime.id: "openclaw"), 20 turns each: reasoning-only turns retriedOn the default Codex runtime for OpenAI models, the same reasoning-only reply is handled as an empty response and retried with the existing empty-reply text, on both builds (3 turns each, all answered). This change does not reach that route.
Not added: no config option, dependency, schema change or fallback.