Repository navigation
fix: reserve reasoning tokens for utility model answers - #169331
Conversation
Preserve explicit plugin completion caps while sizing internal utility answer budgets against the resolved model. Observer and recap reasoning no longer exhaust their small visible-answer allowances. Existing model parameters and caller timeouts remain unchanged. Related: #153391. Builds on the parameter forwarding fix in #153451.
|
🦞👀 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 changesThis PR adds a model-bounded reasoning allowance to internal utility requests while preserving explicit completion caps. Example: A native Ollama reasoning model generates an Activity recap.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses demonstrated utility-model token starvation through the shared completion owner, with no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherUtility callers submit bounded prompts and answer budgets to isolated completion, which selects the runtime, resolves model capabilities, and returns text for titles, status digests, recaps, and meeting notes. flowchart TD
A[Utility task callers] --> B[Isolated completion owner]
B --> C[Resolved model capabilities]
C --> D[Bounded completion allowance]
D --> E[Selected runtime and provider]
E --> F[Visible utility answer]
Technical reviewBest possible solution: Land the shared model-bounded allowance while retaining existing task deadlines and explicit completion caps. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the small shared reasoning-and-answer caps, and supplied native Ollama Gateway captures demonstrate reasoning-only exhaustion; this review ran no target code. Is this the best way to solve the issue? The existing isolated-completion owner is the right boundary: it sizes requests from resolved model capabilities, preserves explicit limits, and avoids another configuration knob. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 072f977edd46. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -11, Tests +114, Docs +7. Total +110 across 12 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel 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 11, 2026, 4:54 PM ET / 20:54 UTC (Revision 4). |
|
Merged via squash.
|
) Related: openclaw#153391. Builds on openclaw#153451. ## What Problem This Solves Reasoning utility models can spend the observer's 300-token or activity recap's 240-token allowance entirely on reasoning, leaving no visible answer. ## User Impact Internal utility requests now reserve room for reasoning within the selected model's output limit. Non-reasoning models retain their smaller task budgets. Explicit plugin completion limits remain absolute. No configuration, public API, or migration changes are required. Existing task timeouts are unchanged. A slow thinking model can still exceed them: live Qwen3 4B observer requests received the repaired token allowance but timed out at the existing 30-second deadline. This fixes token starvation, not inference latency. ## Why This Change Was Made The isolated-completion owner translates a private answer budget using the same reasoning allowance as the exec reviewer. Titles, narration, observer digests, activity recaps, and transcript summaries use that owner; callers retain their sampling settings. V1, V2, and CLI routes preserve explicit limits and the resolved model's capacity. Configured payload parameters were already repaired by openclaw#153451 and native Ollama already carries model parameters to the wire. Thanks to @dwalthour for the report, and @Alix-007 and Ayaan Zaidi for the earlier parameter fix. Production diff: +34/-45 (net -11); tests: +120/-6; docs: +7/-0. Nearby cleanup removes an unreachable result guard and redundant caller constants. No prompt or tool text changed. ## Evidence - Reproduced on main `5740bf11dd7afb3f686e2ec7067614dc694946aa` with an isolated Gateway, native Ollama `qwen3:4b`, and captured `/api/chat` requests. The actual `sessions.create` → subscription/visibility → `chat.send` flow produced observer requests with `think: true`, `num_ctx: 8192`, `temperature: 0.2`, and `num_predict: 300`. Five responses exhausted the cap with 1,164–1,283 reasoning characters and zero visible answer; the Gateway disabled observation after repeated invalid JSON. Activity recap requests similarly exhausted 240 tokens. - Candidate Gateway requests preserve those parameters and send `num_predict: 8192`, the configured model maximum. Native `qwen3:8b` returned a valid observer digest in 6.08 seconds and the Gateway published a `session.observer` event (headline: “Nightly backup guide creation”). An activity recap completed in 384 tokens / 7.59 seconds with visible text; replaying that exact captured request directly against Ollama with the old 240-token cap returned reasoning only and `done_reason: length` (this control is provider-level, not another Gateway run). The real `sessions.title.prepare` RPC returned “Investigate Missing Invoice Table” in 13.61 seconds, with configured `temperature: 0.15`, `think: true`, and `num_ctx: 8192` on the wire. The 4B deadline limitation remains as stated above. - The existing observer/recap owner regressions fail on main for 300/240 instead of 8,492/8,432. The candidate passes 120 tests across eight focused files in 234.28 seconds wall time, then 57 isolated-owner tests after cleanup in 87.04 seconds. The new budget matrix executes in 1.263 seconds; title HTTP transport tests take 15.937 seconds, observer/recap composition 5.997 seconds, and transcript-summary tests 0.312 seconds. These reuse existing integration fixtures; import/worker compilation accounts for most wrapper time. - `pnpm build` passes. Ratchets pass for line counts, assertions, timer races, mocks, database access, config docs, and plugin inventory. Core and test typechecks, scoped lint, dead-export scans, and the remaining changed-file guards pass. The first lint invocation lacked the tracked Solid lint dependency after gateway-only setup; restoring that dependency and resuming lint/remaining guards cleared the environment failure. - Independent Codex autoreview is scoped-clean through P2 on this head. ClawSweeper reviewed this exact head with no findings and no before-merge items. Its test note reflects the stated 4B timeout limitation; successful 8B Gateway publication is documented above. [Exact-head CI](https://github.com/openclaw/openclaw/actions/runs/38171953530) passed in 588 seconds wall time with 45 successful jobs and no failures. The published `openclaw/ci-gate` status is also successful for `19c2a83e73def2454c1ea367af909dea9727e381`.
Related: #153391. Builds on #153451.
What Problem This Solves
Reasoning utility models can spend the observer's 300-token or activity recap's 240-token allowance entirely on reasoning, leaving no visible answer.
User Impact
Internal utility requests now reserve room for reasoning within the selected model's output limit. Non-reasoning models retain their smaller task budgets. Explicit plugin completion limits remain absolute. No configuration, public API, or migration changes are required.
Existing task timeouts are unchanged. A slow thinking model can still exceed them: live Qwen3 4B observer requests received the repaired token allowance but timed out at the existing 30-second deadline. This fixes token starvation, not inference latency.
Why This Change Was Made
The isolated-completion owner translates a private answer budget using the same reasoning allowance as the exec reviewer. Titles, narration, observer digests, activity recaps, and transcript summaries use that owner; callers retain their sampling settings. V1, V2, and CLI routes preserve explicit limits and the resolved model's capacity.
Configured payload parameters were already repaired by #153451 and native Ollama already carries model parameters to the wire. Thanks to @dwalthour for the report, and @Alix-007 and Ayaan Zaidi for the earlier parameter fix.
Production diff: +34/-45 (net -11); tests: +120/-6; docs: +7/-0. Nearby cleanup removes an unreachable result guard and redundant caller constants. No prompt or tool text changed.
Evidence
d789eb10a28293751d980bf23406d6597e42a236with an isolated Gateway, native Ollamaqwen3:4b, and captured/api/chatrequests. The actualsessions.create→ subscription/visibility →chat.sendflow produced observer requests withthink: true,num_ctx: 8192,temperature: 0.2, andnum_predict: 300. Five responses exhausted the cap with 1,164–1,283 reasoning characters and zero visible answer; the Gateway disabled observation after repeated invalid JSON. Activity recap requests similarly exhausted 240 tokens.num_predict: 8192, the configured model maximum. Nativeqwen3:8breturned a valid observer digest in 6.08 seconds and the Gateway published asession.observerevent (headline: “Nightly backup guide creation”). An activity recap completed in 384 tokens / 7.59 seconds with visible text; replaying that exact captured request directly against Ollama with the old 240-token cap returned reasoning only anddone_reason: length(this control is provider-level, not another Gateway run). The realsessions.title.prepareRPC returned “Investigate Missing Invoice Table” in 13.61 seconds, with configuredtemperature: 0.15,think: true, andnum_ctx: 8192on the wire. The 4B deadline limitation remains as stated above.pnpm buildpasses. Ratchets pass for line counts, assertions, timer races, mocks, database access, config docs, and plugin inventory. Core and test typechecks, scoped lint, dead-export scans, and the remaining changed-file guards pass. The first lint invocation lacked the tracked Solid lint dependency after gateway-only setup; restoring that dependency and resuming lint/remaining guards cleared the environment failure.openclaw/ci-gatestatus is also successful for19c2a83e73def2454c1ea367af909dea9727e381.