Repository navigation
fix: qwen-chat-template models ignore declared reasoning efforts - #148397
Conversation
Map enabled thinking levels to chat_template_kwargs.reasoning_effort with the Qwen 3.8 template tiers (minimal/low -> low, medium -> medium, high/xhigh/max -> xhigh) in both Chat Completions builders. The bundled vLLM plugin keeps its binary /think profile at the template default effort.
|
🦞👀 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 real behavior proof before merge. What this changesThe PR forwards selected Qwen chat-template reasoning effort while preserving backend defaults and preventing automatic parent tiers from becoming saved child preferences. Example: A Qwen chat-template model declares low, medium, and xhigh efforts with high mapped to xhigh, and the user selects /think high.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain This PR fixes a current reasoning-control bug through the shared request owner; no actionable code findings remain. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway replies, commands, cron jobs, and native subagents resolve thinking choices before the shared Chat Completions serializer turns them into provider request fields. flowchart LR
A[Turn and saved preferences] --> B[Thinking selection owners]
B --> C[Run and queue context]
C --> D[Session transport]
D --> E[Shared completions serializer]
E --> F[Qwen backend]
C --> G[Native child planning]
Technical reviewBest possible solution: Land the shared selected-effort repair with transient provenance and preserved existing saved choices once the remaining validation gates are satisfied. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically omits nested effort for declared Qwen chat-template models, and the supplied Gateway comparison corroborates that path; this review ran no target code. Is this the best way to solve the issue? The patch fixes serialization at the shared owner and carries selection intent from existing resolution owners, avoiding a new default, public option, or durable provenance field. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b3d5dbae8512. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +95, Tests +558, Docs +5, Other 0. Total +658 across 46 files. Added test files: 2. View PR surface stats
Review metrics
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 (32 earlier review cycles; latest 8 shown)
Reviewed October 14, 2026, 6:24 AM ET / 10:24 UTC (Revision 33). |
Default qwen-chat-template models without a provider thinking profile to high, which maps to the Qwen 3.8 template's xhigh default, so forwarding thinking levels does not lower reasoning depth for setups that never selected a level.
Resolve against main's shared reasoning resolver: map Qwen chat-template tiers from the resolved thinking level, which binary and chat-template formats carry independently of scalar reasoning_effort support.
Keep the new `level` field that carries the resolved thinking level to the chat-template and binary controls, alongside main's updated ChatGPT none support comment. Co-Authored-By: Claude Opus 5 <[email protected]>
Keep the high default for qwen-chat-template models in the model thinking profile, and adopt main's three-argument catalog level helper now that Ultra is added by the harness-level resolveThinkingProfile wrapper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep main's removal of the older vLLM chat-template cases, and keep this branch's regression for dropping reasoning_effort from binary chat-template thinking. That case seeds the transport payload, so the capture helper keeps its initialPayload option. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qwen chat-template tiers were applied to every model with that thinking format, although tier vocabularies differ between templates. Send chat_template_kwargs.reasoning_effort only when the model declares compat.supportedReasoningEfforts, resolved like reasoning_effort for other OpenAI-compatible models, and default only those models to high. Undeclared models keep binary thinking and the previous request shape. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preserve thinking selection provenance in the queue run options after main moved the shared run fields into a RunEmbeddedAgentParams Pick.
Integrate upstream removal of two unused Control UI exports reported by the changed checks. The Qwen proposal remains patch-identical relative to the new main, with no fixture repair or default-policy change.
Retain private thinking-selection provenance while incorporating upstream session SDK cleanup. Prepare the existing HTTP fixture command graph before its assertion deadline.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…nclaw#148397) * fix: qwen-chat-template models ignore /think effort levels Map enabled thinking levels to chat_template_kwargs.reasoning_effort with the Qwen 3.8 template tiers (minimal/low -> low, medium -> medium, high/xhigh/max -> xhigh) in both Chat Completions builders. The bundled vLLM plugin keeps its binary /think profile at the template default effort. * fix: keep default depth for unconfigured qwen-chat-template models Default qwen-chat-template models without a provider thinking profile to high, which maps to the Qwen 3.8 template's xhigh default, so forwarding thinking levels does not lower reasoning depth for setups that never selected a level. * fix: send qwen chat-template effort only for declared efforts Qwen chat-template tiers were applied to every model with that thinking format, although tier vocabularies differ between templates. Send chat_template_kwargs.reasoning_effort only when the model declares compat.supportedReasoningEfforts, resolved like reasoning_effort for other OpenAI-compatible models, and default only those models to high. Undeclared models keep binary thinking and the previous request shape. * fix: require an explicit effort list for chat-template tiers The chat-template guard read efforts through the model contract resolver, which infers lists for GPT-family ids. A qwen-chat-template model served under such an alias without compat.supportedReasoningEfforts therefore sent reasoning_effort. Read only the declared compat list, and cover an undeclared GPT-family alias over managed and direct HTTP. * docs: note the default effort for declared chat-template models Declaring supportedReasoningEfforts on a qwen-chat-template model makes OpenClaw send the resolved effort on every enabled turn, including high when no level is selected. Say so, and point to params.thinking for templates whose own default differs. * fix: preserve Qwen template defaults with private thinking provenance * fix(qwen): distinguish cron candidate thinking selector * refactor: keep thinking provenance within bounded owners * chore: finish Qwen effort validation cleanup * test: include thinking provenance in cancellation expectations --------- Co-authored-by: Peter Steinberger <[email protected]>
…off 400 (#172580) * fix(agents): preserve custom provider thinking defaults Do not infer thinking-off support from an OpenAI-compatible endpoint's wire format. Preserve explicit compatibility settings and effort mappings, and warn once per model per minute when conversation-label generation fails without logging provider errors or source content. Fixes #171068. Utility thinking-off requests were introduced in 380c115. * fix(agents): limit inferred thinking-off exception to Z.AI Keep the custom endpoint omission limited to inferred zai while retaining the existing OpenAI proxy off-effort policy. Restore inferred DeepSeek and Together off controls and cover Qwen controls through the simple-completion HTTP path. Preserve the Z.AI/bigmodel title regression and conversation-label warnings. Initialize the shared transport host before timed HTTP cases. Follow-up to #171068. * fix(ai): preserve explicit Z.AI off controls Carry the inferred custom Z.AI off-control exception in resolved compatibility instead of treating any unresolved thinking intent as undeclared support. Preserve explicit binary controls and managed scalar-off contracts while retaining inferred Z.AI omission and DeepSeek/Together controls. * fix(ai): honor declared inferred Z.AI off controls Use canonical reasoning support and mapping resolvers before treating custom inferred Z.AI off controls as undeclared. Preserve supported none/off efforts, normalized declarations, and off mappings while retaining undeclared omission and other provider controls. Clarify the title-generation contract in the model docs. Release adaptation: stable's completions request builder does not carry the thinkingExplicit flag added on main by #148397, so derive it from the request's reasoning/reasoningEffort options and pass it to applyCompletionsReasoningAndRouting. Ported only the conversation-label warning test; the neighbouring main-only runtime-selection tests were dropped. (cherry picked from commit 20299f8)
Related: #131213
What Problem This Solves
Fixes selected reasoning strength being dropped by Qwen chat-template models that declare
compat.supportedReasoningEfforts.User Impact
A selected turn, saved session preference, configured default, or inherited explicit choice sends the mapped
chat_template_kwargs.reasoning_effort. Unselected calls omit effort and preserve the backend default; the logical fallback stays medium. Off disables thinking without sending effort. Undeclared templates retain binary controls.New native children retain explicit/configured thinking preferences without saving automatic parent tiers as explicit child choices. Existing saved levels still count as selections because historical records have no selection provenance. No session schema, public plugin option, dependency declaration, or config knob is added.
Why This Change Was Made
The shared direct/managed Chat Completions owner now serializes selected effort. A bounded private selection bit carries intent through the existing reply, queue, CLI, cron, session, fallback, and child owners, and is stripped from public harness handoffs.
This refresh preserves the contributor's commits, removes vLLM changes superseded by #150149, and deletes the old forwarding-only tests and helper paths. Thanks @areslp for the original repair and @hippoley for the selection-provenance analysis.
Evidence
Before the main refresh, on macOS, an isolated real Gateway used
sessions.createandchat.sendthrough a recording proxy forwarding bodies unchanged to Ollama 0.40.3qwen3:4b. The original main dropped effort for/think high; the candidate sends it. Every real-model case completed with a terminal model answer./think highhighsessions.patch)high/think offA deterministic Gateway fixture independently returns
backend-default,high,backend-default,high, andofffor those five cases. An inline directive is turn-scoped; the next turn is unselected unless a session choice was saved.The HTTP regression produced 16 failures when only the original serializer was restored, then passed all 60 cases with the fix (340.948 / 414.853 s wall). Child persistence, CLI HTTP, logical default, subagent-tool planning, and queue-state checks pass. Public-harness projection checks also pass. The existing cancellation suite now includes the private selection field in its two expected result objects (3 failures before, all 4 cases passing after; 289.72 / 209.46 s wall). CLI HTTP checks cover unselected, selected, mapped configured default, off, and absence of the private flag on the wire.
Core types, all 28 selected test type graphs, targeted lint/format, diff checks, required baseline ratchets, config docs, plugin inventory, and the final
qaRuntimebuild pass. Local extension-wide typing was limited by an existing unlinked QA/Crabbox dependency in the Gateway-only setup; the dependency install waited on a shared package-store operation and was cancelled without bypassing that lock. The pre-refresh CI run on56b53fe9e57eaaff3354f1e9b7b5290a372e3bd2subsequently passed production and selected test type lanes, covering that local dependency limitation. Isolated Codex review of the full behavior change is clean at P0–P2. Subsequent changes remove unused imports, clarify a comment, shrink an assertion allowance, and update two cancellation expectations; production behavior is unchanged. The isolated follow-up review is also clean at P0–P2 on56b53fe9e57eaaff3354f1e9b7b5290a372e3bd2.The child fixture initially timed out during its shared loader before assertions; an unchanged replay passed. One CLI attempt was invalidated by a comment edit during compiler snapshot preparation; the frozen-head replay passed. No timeout or assertion was weakened. Shared-host compilation and artifact-lock waits dominate local wall time; the CLI integration itself took 85.289 s to exercise the real command/config/session path (549.11 s total wall).
Production: +231/−136 (net +95); tests/support: +578/−20. The production growth carries bounded selection intent through existing owners after removing obsolete original-PR paths. No model-facing prompt text changed.
The previous CI run, on
56b53fe9e57eaaff3354f1e9b7b5290a372e3bd2, passed all selected lanes except an inherited release-test inventory mismatch and an X publication composition timeout. Exact-base source/tree evidence established the inventory mismatch. The maintainer classified the X timeout as unrelated main E2E slowness: this PR changes no X publication or authority files, and the exact main base itself used 93.833 seconds of the 120-second local test budget. No further X investigation or timeout change is included.Current main
bde739923e22902f6d8a8d875e6fda68f472e9aawas merged normally, preserving contributor history, in3f31828eec9891d4a5f447fb56626e0f70aea9b8. The four overlapping files merged without conflicts. The Qwen serializer, queue behavior, and private harness projection are unchanged by the merge. Fresh isolated Codex review is scoped-clean at P0–P2; core types, the three selected test type graphs, scoped lint, and formatting pass. All three requested suites passed on the merge commit: HTTP contract (60) plus queue state (15), 478.28 s Vitest wall; harness projection (7), 306.37 s Vitest wall. The complete wrapper exited 0 in 1181.350 s including compilation, input verification, and cleanup. Scoped checks passed in 439.617 s total (core types 76.886 s; three selected test type graphs 247.578 s; lint 107.484 s; format/diff 7.669 s). All nine CI ratchet/config checks passed in 783.047 s. No source repair or baseline expansion was needed after the merge.CI run 38541345995 on head
3f31828eec9891d4a5f447fb56626e0f70aea9b8failed the awaited-bundle timing case atattempt.tool-search-catalog-abort.test.ts:400. Full-file local replays establish this failure is inherited from CI's exact main base0b54949a41012201ca310a583810c46d4c15dc41: both the PR head and that base produce 1 failed / 9 passed withTypeError: Cannot convert undefined or null to object,kind: "failed", andsource: "prompt". The test and shared fixture are unchanged between those revisions. GitHub confirms synthetic merge2e95f5c52a194c8de6b798d69eaf5f263c15641chas those exact base/head parents.Both replays used
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.tool-search-catalog-abort.test.ts --maxWorkers=1on macOS with isolated temporary state and independent compiler caches. Head: 473.916 s total wall / 255.86 s Vitest; exact base: 434.220 s total wall / 204.10 s Vitest. No source, mock, assertion, or timeout change was needed to reproduce either result. This attributes the red check; it does not repair the underlying main-base defect.ClawSweeper reviewed the pre-refresh head
56b53fe9e57eaaff3354f1e9b7b5290a372e3bd2with no actionable code findings. Per maintainer direction, this refresh stops after confirming fresh exact-head CI starts; it does not wait for CI or another bot review. Latest-stable upgrade and live persisted native-child proof remain unrun; those proof-only holds are left to maintainer review. Live proof covers the configured Qwen template over Ollama's OpenAI-compatible endpoint on macOS. It establishes wire controls and completed answers, not reasoning-depth performance, LM Studio, native Ollama/api/chat, or upgrade validation.