Skip to content

fix: reserve reasoning tokens for utility model answers - #169331

Merged
steipete merged 1 commit into
mainfrom
fix/utility-model-reasoning-params
Oct 11, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/utility-model-reasoning-params

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Reproduced on main d789eb10a28293751d980bf23406d6597e42a236 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 passed in 588 seconds wall time with 45 successful jobs and no failures. The published openclaw/ci-gate status is also successful for 19c2a83e73def2454c1ea367af909dea9727e381.

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.
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 11, 2026
@steipete steipete added the ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. label Oct 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The 240-token cap produces reasoning only and no visible recap.
  • After: The candidate allows up to the configured 8,192 tokens; the recorded recap completes in 384 tokens with visible text.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused shared-owner repair with shipped-entry-point evidence, preserved contracts, successful exact-head CI, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied native Ollama Gateway request/output evidence exercises the changed isolated-completion owner through sessions.create, chat.send, observer publication, Activity recap generation, and sessions.title.prepare; successful candidate answers establish the allowance change while the documented 4B timeout remains separate.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Reasoning utility models can return no visible answer, causing missing observer digests and Activity recaps.
Reason: The supplied runtime evidence establishes token starvation, and the maintainer-authored direction repairs it without configuration or public API expansion; slow-model latency remains explicitly outside scope.

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
Reviewed head: 19c2a83e73def2454c1ea367af909dea9727e381

Before merge

None.

Findings

None.

Agent review details

How this fits together

Utility 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]
Loading

Technical review

Best 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

  • Isolated-completion model clamping and runtime ownership keeps the original intent (ec4ae78: Route titles through their authentication-owning runtime while bounding completion requests by resolved model capacity.)
  • Observer answer allowance changes intended behavior with a stated reason (89fe452: Generate compact, structured trajectory digests through the utility model.)
  • Activity recap answer allowance changes intended behavior with a stated reason (d7f01d3: Generate bounded rolling recaps while retaining cached results and existing session metadata.)
  • Conversation-label visible-output policy keeps the original intent (c1a9dad: Keep reasoning out of generated titles and permit an intentional empty strict-visible outcome.)
  • Progress narration keeps the original intent (8d465d7: Use utility narration for visible long-task progress while preserving lifecycle cancellation and typed preambles.)
  • Transcript summaries keeps the original intent (89ed8f4: Keep summary cleanup and resource settlement with shared owners while preserving stored notes and fallback behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 89fe452 adds src/gateway/session-observer-model.ts:250 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 89fe45299122; files: src/gateway/session-observer-model.ts)

PR surface

Source -11, Tests +114, Docs +7. Total +110 across 12 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 7 34 45 -11
Tests 4 120 6 +114
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 161 51 +110

Review metrics

Metric Value Why it matters
Production versus test LOC Production +34/-45; tests +120/-6 Production shrinks through shared ownership; added coverage protects distinct runtime-dispatch and serialized-request contracts.

Root-cause cluster

Relationship: same_root_cause
Canonical: #153391
Summary: The canonical report covers dropped utility parameters and reasoning-token starvation; the earlier merged PR fixes forwarding, and this PR fixes budget sizing.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Token starvation affects optional background utility results without blocking foreground agent turns.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-11T20:17:15.416Z sha 19c2a83 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T20:28:47.991Z sha 19c2a83 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T20:36:12.616Z sha 19c2a83 :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 4:54 PM ET / 20:54 UTC (Revision 4).

@steipete
steipete marked this pull request as ready for review October 11, 2026 20:22
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 11, 2026
@steipete steipete self-assigned this Oct 11, 2026
@steipete
steipete merged commit 2a64309 into main Oct 11, 2026
237 of 242 checks passed
@steipete
steipete deleted the fix/utility-model-reasoning-params branch October 11, 2026 21:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
)

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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant