Skip to content

fix(exec): avoid truncated verdicts from reasoning reviewers - #150200

Merged
steipete merged 4 commits into
openclaw:mainfrom
leapdragon:feat/exec-reviewer-max-tokens
Oct 11, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
leapdragon:feat/exec-reviewer-max-tokens

Conversation

@leapdragon

@leapdragon leapdragon commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Exec approval reviews can exhaust a reasoning model's 1,024-token completion limit before it emits the JSON verdict, forcing human approval even for an authorized local calculation.

User Impact

Reasoning reviewers receive an automatic, bounded thinking allowance in addition to the verdict budget. Non-reasoning reviewers keep their existing budget, and requests remain clamped to the model's advertised output cap. This replaces the proposed reviewer.maxTokens option; no new configuration or migration is required.

The existing timeout and human-approval fallback remain unchanged. The allowance does not guarantee a verdict from every model or input, and provider-specific thinking-budget handling still applies.

Why This Change Was Made

The exec reviewer now reuses the shared completion thinking-budget calculation, using the configured thinking level or a bounded medium allowance when omitted. Budget selection stays with the reviewer; schemas, labels, help text, and generated config docs retain their main-branch behavior.

Thanks @leapdragon for identifying the failure and the original fix. The contributor commit is preserved, with main merged into the branch rather than rebased. Relative to merged main: production +16/-6 (net +10), tests +119/-0, docs +2/-0. The production growth implements automatic sizing and cap normalization without another policy table or configuration surface.

Evidence

Live requests used native Ollama /api/chat, observed through a transparent loopback capture proxy. A real pnpm openclaw ... agent turn invoked exec; the reviewer then decided whether an authorized synthetic AWK calculation could run. The failing Qwen3 4B case was exercised through both the embedded CLI and a real isolated Gateway. The before/after Gateway runs kept the same configuration and prompt.

Reviewer Main Candidate
qwen3:4b, thinking on Limit 1,024; generated 1,024; done_reason=length; thinking only, no verdict; headless exec denied after human fallback Limit 3,072; generated 2,239; valid low-risk allow; command ran and printed the expected sorted values, sum, and median
qwen3:8b, thinking on Tested input already succeeded: limit 1,024, 265 generated tokens Limit 3,072, 265 generated tokens; valid allow, command ran
llama3.2:latest Limit 1,024; 29-token valid verdict Same limit and identical 29-token verdict; command ran

The reported exhaustion reproduced with Qwen3 4B; Qwen3 8B did not exhaust its budget on the tested inputs. Both versions used the existing reviewer.timeoutMs: 180000 setting to isolate token truncation from latency on the shared local-model host; the default timeout remains 30 seconds.

Reproduction flow: isolated state/config and workspace, Gateway on port 19436, pnpm openclaw --profile reviewer-budget gateway run --port 19436, then pnpm openclaw --profile reviewer-budget agent --agent main --session-id <unique-id> --message-file <synthetic-prompt> --thinking off --timeout 240 --json. The main agent used qwen2.5:7b; only the approval reviewer used the models above. No operator state was used.

  • Regression on main: 9 expected failures, 4 passes, 64.43s wall time; reasoning returned ask instead of a valid verdict. Reviewer/transport source is identical between reproduction main ea4693e04a70f5a9048a6cd4ac23f97581bf62a9 and merged main f0a64d10805d2e7e21b4fa45235d8074a95e033d.
  • Candidate reviewer suites: 38 tests passed, 71.44s wall time (including cold compiler preparation).
  • pnpm build: passed, 6m33s. Scoped lint and the agents-root test typecheck passed. Prompt bytes are unchanged: token delta 0.
  • Max-lines, line-cap, assertion-safety, database-worker, database-dialect, test-timeout, config-docs, and plugin-inventory checks passed.
  • Updated-head validation after merging main: core typechecking, scoped lint on every originally failing file, export-name collision guard, all required ratchets, and the registered SDK surface check passed. Reviewer suites plus SDK surface tests: 43 passed, 1 Linux-only skipped, 55.66s wall time.
  • Codex autoreview of head 0a315cc6f847e2f9230372831c34263726a24e2d: scoped-clean, no actionable P0–P2 findings. The reviewer source, test, docs, shared budget helper, and native Ollama transport are unchanged by this main merge; the live proof above remains applicable.

CI failure classification and refresh

Previous run 38093916507 tested head 80ae610482edeb7f54227dc6cf3608126ed3fc5c merged with main 09d58be4e65092a045a0228ad983513b9fc07d07 (CI merge 343cd42e97bf4e75d64280334dbe078d8c014382). Every failed job was inspected from its retained log. All failures reproduced independently on that exact main parent; none was caused by the reviewer-budget diff.

Failed jobs Inherited cause and independent baseline proof Resolution
check-prod-types, check-test-types, check-test-types-core-2, -3, -4, -5 Unused env at src/plugins/channel-presence-policy.ts:519; all eight failing compiler configurations reproduced the same TS6133 on the CI main parent Main fix 243b6dbf63d2, merged here
check-lint-core-2 Observation-cache name shadowing and unnecessary conversion; same oxlint errors on the CI main parent Main fix f9940dc8a794, merged here
check-lint-core-3 Same unused env; oxlint reproduces on the CI main parent Main fix 243b6dbf63d2, merged here
check-lint-core-4 Unbound Worker method in sqlite-worker-plugin-comparison.test.ts; oxlint reproduces on the CI main parent Main fix f9940dc8a794, merged here
check-source-contracts Duplicate resolveChannelDmPolicy export; the exact export-name guard fails on the CI main parent Main fix 13296b17cd0f, merged here
checks-node-compact-small-5 SDK surface accounting: baseline suite 2 failed / 3 passed / 1 Linux-only skipped, 7.32s; the skipped test's underlying pnpm plugin-sdk:surface:check independently reproduces all five budget violations in 4.96s Main fix f9940dc8a794, merged here; candidate suite and registered command pass
checks-node-changed-3 bash-tools.process.e2e.test.ts: the same five failures / six passes on the CI main parent, 54.86s Vitest / 472.74s including cold E2E preparation Still inherited: fixtures expect passive system events for nonexistent session destinations after completion delivery moved to admitted session events
openclaw/ci-gate Aggregate of the failed job groups above Updated-head CI now fails only for the inherited process shard

The five remaining inherited process cases cover explicit stop/finalizer failure, post-exit finalizer failure, timeout after clean exit, quiet nonzero completion wake, and notification acknowledgement. The PR does not change those tests or their notification owners. Linux process-lifetime behavior was not exercised on macOS; its registered SDK command failure was independently reproduced instead.

Main fab68f488caf061cf0d72e3413ee33888a54ef24 was merged normally into the contributor branch, preserving ancestry and credit; no rebase, force push, suppression, or test weakening was used. ci:no-fail-fast was added before this single refresh push. Updated-head CI run 38102698936 completed with 41 successful jobs, 28 skipped, and only the inherited process shard plus aggregate gate failing. Every earlier type, lint, source-contract, and SDK surface job is now successful. No PR-caused failure remains.

The remaining shard was also reproduced on this new run's exact main parent bb7c69ddd04b01330e60489d1057d6e1e3319ad2 (CI merge eb70dc12c40779c02ef4f5aef16b748713053c00): the same five assertions fail, six pass, 42.73s Vitest / 447.94s including required E2E build preparation. The CI classification is READY-WITH-INHERITED; this is retained failure evidence, not a green rerun or a claim that those fixtures were repaired.

ClawSweeper's exact-head re-review reports no findings, no Before merge items, complete fix scope, and sufficient live proof. The separate security-sensitive review gate still requires a maintainer to approve the current revision. This PR has not been merged.

The exec auto-reviewer's completion budget is a fixed 1,024 tokens clamped to
the reviewer model's advertised maxTokens. Since openclaw#147192 the reviewer can be
asked to think first, and a local reasoning model easily spends the whole
budget on its reasoning before it reaches the JSON verdict, so the review
comes back truncated and falls back to human approval.

Add `tools.exec.reviewer.maxTokens` (also under
`agents.entries.<id>.tools.exec.reviewer`). It replaces the 1,024 default and
keeps the downward clamp to the model's maxTokens; non-positive or fractional
values are ignored. Schema, labels, help text, docs and the generated config
baseline follow.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 16, 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 agents Agent runtime and tooling size: S labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR adds a bounded thinking allowance to reasoning reviewers while retaining model output caps and human-approval fallback.

Example: An isolated Gateway uses Qwen3 4B to review an authorized AWK calculation.

  • Before: The reviewer exhausts 1,024 tokens without a verdict, and headless execution is denied after human-approval fallback.
  • After: With a 3,072-token limit, the reviewer completes a valid verdict after 2,239 tokens and the calculation runs.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, owner-approved repair with shipped-entry-point proof, meaningful regression coverage, and no actionable correctness findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied native Ollama CLI and isolated Gateway observations exercise the changed reviewer budget: Qwen3 4B completes its verdict and the authorized calculation runs, with reasoning and non-reasoning controls; the extended existing timeout isolates token truncation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Authorized commands unexpectedly require human approval because the reasoning reviewer reaches its completion limit before emitting a verdict.
Reason: The failure is demonstrated through native execution, and explicit owner approval settles the automatic sizing direction.

Merge readiness

✅ Ready for maintainer review

This PR fixes a demonstrated reasoning-reviewer truncation problem that remains on current main; no actionable patch defects were found, and the maintainer has approved the current revision.

Priority: P2
Reviewed head: 0a315cc6f847e2f9230372831c34263726a24e2d

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway exec, node execution, and model-backed widget reviews share the reviewer, which converts prepared model completions into allow-once, deny, or human-review decisions.

flowchart TD
  A[Pending action] --> B[Review eligibility]
  B --> C[Prepared reviewer model]
  C --> D[Bounded completion budget]
  D --> E[Provider completion]
  E --> F[Verdict validation]
  F --> G[One shot execution or human approval]
Loading

Technical review

Best possible solution:

Land the approved automatic allowance through the native inherited-failure workflow while preserving output caps and incomplete-verdict fallback.

Do we have a high-confidence way to reproduce the issue?

Current-main source retains the responsible ceiling, and supplied native Gateway evidence reproduces Qwen3 4B exhaustion; no target code was executed during this review.

Is this the best way to solve the issue?

The approved shared-budget solution addresses the request-sizing cause without adding a config surface, changing reasoning effort, or weakening verdict validation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against aec34bbde0f5.

Provenance checked

  • Reviewer completion ceiling changes intended behavior with a stated reason (9296e68: The earlier repair established a bounded 1,024-token default and model-cap clamp while rejecting incomplete responses.)
  • Reviewer thinking configuration keeps the original intent (0e4b4d1: Operators can select reviewer reasoning independently; omitted effort preserves provider defaults.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced change: The pinned introduction replaces fixed reviewer sizing with the existing shared thinking-budget calculation; it adds no config key and leaves verdict parsing and fallback unchanged. (src/agents/exec-auto-reviewer.ts:281, 0a315cc6f847)
  • Current main still affected: Current main retains the 1,024-token ceiling regardless of reasoning capability, with a downward model-cap clamp. (src/agents/exec-auto-reviewer.ts:279, aec34bbde0f5)
  • Shared budget and real transport: The shared helper supplies bounded thinking allowances, and native Ollama maps completion maxTokens to num_predict; this is the transport exercised by the supplied Gateway proof. (packages/ai/src/providers/simple-options.ts:77, 0a315cc6f847)
  • Supplied live behavior: The complete PR body records native Ollama requests through an isolated CLI and Gateway: Qwen3 4B changes from length-stopped reasoning-only output to a completed verdict and executed calculation; Qwen3 8B and non-reasoning Llama controls retain successful behavior. The existing timeout was increased to isolate token exhaustion. (0a315cc6f847)
  • Recorded owner approval: steipete explicitly re-approved the current revision and its automatic allowance, model-cap retention, unchanged fallback, and removal of the proposed config option; the security approval comment also covers this head. (0a315cc6f847)
  • Inherited CI classification: GitHub confirms only the process shard and aggregate gate fail in https://github.com/openclaw/openclaw/actions/runs/38102698936. The maintainer-updated body records the same five process assertions failing on its exact main parent. Retained-log retrieval was blocked by the network allowlist, so baseline classification relies on that recorded evidence. (src/agents/bash-tools.process.e2e.test.ts, 0a315cc6f847)

Likely related people:

  • joshavant: Raw commit 8022700 adds src/agents/exec-auto-reviewer.ts:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 80227005a016; files: src/agents/exec-auto-reviewer.ts)

PR surface

Source +10, Tests +119, Docs +2. Total +131 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 16 6 +10
Tests 1 119 0 +119
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 137 6 +131

Review metrics

Metric Value Why it matters
Production versus tests Production +16/-6; tests +119/-0 The small production increase reuses the shared budget owner; the tests cover reasoning levels, model caps, non-reasoning preservation, and exhaustion fallback.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Reasoning reviewers can unnecessarily defer authorized commands to humans; the failure is limited to model-backed review and preserves fail-closed safety.
  • 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-16T17:50:38.343Z sha 384d2df :: needs real behavior proof before merge. :: none
  • reviewed September 24, 2026, 8:36 AM ET / 12:36 UTC (Revision 2) sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-06T03:10:54.071Z sha 384d2df :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T23:17:20.690Z sha 80ae610 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T23:33:00.509Z sha 80ae610 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T01:26:55.646Z sha 80ae610 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T01:49:19.315Z sha 0a315cc :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 10:36 PM ET / October 11, 2026, 02:36 UTC (Revision 8).

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 24, 2026
steipete and others added 2 commits October 10, 2026 15:57
Merge current main into the contributor branch and replace the proposed
reviewer.maxTokens setting with an automatic bounded thinking allowance.
Reuse the completion owner's thinking budgets and retain the model output
cap and the existing non-reasoning budget.

Native Ollama Qwen3 can otherwise consume all 1,024 tokens before emitting
its JSON verdict, forcing a human approval fallback. Cover the completion
boundary and document the automatic behavior without a new config option.

Co-authored-by: Aron Hsiao <[email protected]>
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Maintainer security changes approved

A maintainer approved this revision with an explicit security approval comment.

A later push requires a fresh approval comment for an external contributor's PR.

@steipete steipete changed the title feat(exec): configure the approval reviewer completion budget fix(exec): avoid truncated verdicts from reasoning reviewers Oct 10, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 10, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 10, 2026

@steipete steipete left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving revision 80ae610 (security-sensitive exec reviewer path).

Reviewed the production change: when the reviewer model is a reasoning model, the 1,024-token verdict budget gets the shared adjustMaxTokensForThinking allowance (thinking defaults to medium) and stays within the model's advertised output cap; non-reasoning reviewers keep exactly 1,024. The proposed reviewer.maxTokens config was removed per the maintainer decision. Approval semantics are unchanged: verdict parsing is untouched and an exhausted or failed review still falls back to human approval.

Proof: live exec through native Ollama, Qwen3 4B exhausted main's 1,024-token budget without a verdict; with this change it produced a valid verdict after 2,239 of 3,072 tokens and the command ran. Qwen3 8B passed on both; Llama 3.2 kept its 1,024-token budget and 29-token verdict. 38 tests pass (9 regressions fail on main), autoreview clean, ClawSweeper no findings.

@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
Integrate main fixes for inherited type, plugin-state lint, duplicate export,
and SDK surface failures seen in the previous PR CI run. Preserve the
reviewer budget change and contributor ancestry without rebasing.

The five process-notification E2E failures also reproduce on CI's main
parent and remain documented as inherited failures.
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete steipete left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving revision 0a315cc. Its only difference from the approved 80ae610 is a merge of main (picking up upstream type/lint/SDK fixes); the PR's own diff (docs/tools/exec.md, src/agents/exec-auto-reviewer.ts, its max-tokens test) is unchanged: reasoning reviewers get the shared thinking allowance on top of the 1,024-token verdict budget within the model's output cap, non-reasoning reviewers keep 1,024, and a failed review still falls back to human approval.

@steipete

Copy link
Copy Markdown
Contributor

/allow-security-sensitive-change

@steipete steipete self-assigned this Oct 11, 2026
@steipete
steipete merged commit 294b2e3 into openclaw:main Oct 11, 2026
135 of 138 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…w#150200)

* feat(exec): configure the approval reviewer completion budget

The exec auto-reviewer's completion budget is a fixed 1,024 tokens clamped to
the reviewer model's advertised maxTokens. Since openclaw#147192 the reviewer can be
asked to think first, and a local reasoning model easily spends the whole
budget on its reasoning before it reaches the JSON verdict, so the review
comes back truncated and falls back to human approval.

Add `tools.exec.reviewer.maxTokens` (also under
`agents.entries.<id>.tools.exec.reviewer`). It replaces the 1,024 default and
keeps the downward clamp to the model's maxTokens; non-positive or fractional
values are ignored. Schema, labels, help text, docs and the generated config
baseline follow.

* test(exec): document reviewer completion isolation

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Aron Hsiao <[email protected]>
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 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. security-sensitive-changed size: S 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.

2 participants