Repository navigation
fix(exec): avoid truncated verdicts from reasoning reviewers - #150200
Conversation
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]>
|
🦞👀 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 changesThe 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +10, Tests +119, Docs +2. Total +131 across 3 files. Added test files: 1. 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 (7 earlier review cycles)
Reviewed October 10, 2026, 10:36 PM ET / October 11, 2026, 02:36 UTC (Revision 8). |
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]>
✅ Maintainer security changes approvedA 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
left a comment
There was a problem hiding this comment.
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.
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.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
steipete
left a comment
There was a problem hiding this comment.
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.
|
/allow-security-sensitive-change |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…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]>
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.maxTokensoption; 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 realpnpm openclaw ... agentturn invokedexec; 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.qwen3:4b, thinking ondone_reason=length; thinking only, no verdict; headless exec denied after human fallbackallow; command ran and printed the expected sorted values, sum, and medianqwen3:8b, thinking onallow, command ranllama3.2:latestThe reported exhaustion reproduced with Qwen3 4B; Qwen3 8B did not exhaust its budget on the tested inputs. Both versions used the existing
reviewer.timeoutMs: 180000setting 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, thenpnpm openclaw --profile reviewer-budget agent --agent main --session-id <unique-id> --message-file <synthetic-prompt> --thinking off --timeout 240 --json. The main agent usedqwen2.5:7b; only the approval reviewer used the models above. No operator state was used.askinstead of a valid verdict. Reviewer/transport source is identical between reproduction mainea4693e04a70f5a9048a6cd4ac23f97581bf62a9and merged mainf0a64d10805d2e7e21b4fa45235d8074a95e033d.pnpm build: passed, 6m33s. Scoped lint and the agents-root test typecheck passed. Prompt bytes are unchanged: token delta 0.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
80ae610482edeb7f54227dc6cf3608126ed3fc5cmerged with main09d58be4e65092a045a0228ad983513b9fc07d07(CI merge343cd42e97bf4e75d64280334dbe078d8c014382). 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.check-prod-types,check-test-types,check-test-types-core-2,-3,-4,-5envatsrc/plugins/channel-presence-policy.ts:519; all eight failing compiler configurations reproduced the same TS6133 on the CI main parent243b6dbf63d2, merged herecheck-lint-core-2f9940dc8a794, merged herecheck-lint-core-3env; oxlint reproduces on the CI main parent243b6dbf63d2, merged herecheck-lint-core-4sqlite-worker-plugin-comparison.test.ts; oxlint reproduces on the CI main parentf9940dc8a794, merged herecheck-source-contractsresolveChannelDmPolicyexport; the exact export-name guard fails on the CI main parent13296b17cd0f, merged herechecks-node-compact-small-5pnpm plugin-sdk:surface:checkindependently reproduces all five budget violations in 4.96sf9940dc8a794, merged here; candidate suite and registered command passchecks-node-changed-3bash-tools.process.e2e.test.ts: the same five failures / six passes on the CI main parent, 54.86s Vitest / 472.74s including cold E2E preparationopenclaw/ci-gateThe 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
fab68f488caf061cf0d72e3413ee33888a54ef24was merged normally into the contributor branch, preserving ancestry and credit; no rebase, force push, suppression, or test weakening was used.ci:no-fail-fastwas 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 mergeeb70dc12c40779c02ef4f5aef16b748713053c00): 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.