Repository navigation
fix(auto-reply): bind tool-authority snapshot before queued followup execution - #139925
gaoanze888 wants to merge 5 commits into
Conversation
…execution Queued followup execution bypassed the foreground runner's bindToolAuthoritySnapshot call (agent-runner-run.ts:543), so the CLI/embedded candidate's bindToolAuthorityRoute threw "Reply operation has no active tool authority snapshot" and dropped the queued message (openclaw#139847). The fix binds the snapshot via prepareReplyToolAuthority(turn.queued) before dispatching to executeAgentTurn, matching the foreground runner pattern. Regression test verifies bindToolAuthoritySnapshot is called before executeAgentTurn dispatch. Closes openclaw#139847
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs real behavior proof before merge. Reviewed September 6, 2026, 4:52 AM ET / 08:52 UTC. ClawSweeper reviewWhat this changesThe PR binds each queued reply’s tool-permission snapshot before agent execution and adds a focused regression test. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful fix for a source-confirmed failure on current main. The prior max-lines suppression is resolved; the remaining blocker is real behavior proof. The overlapping PR is not yet a proven replacement. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw queues follow-up messages while a session is busy. Once admitted, the queued reply passes its operation and permission facts to agent execution, where model-route binding requires an active authority snapshot. flowchart TD
A[Incoming follow-up] --> B[Session queue]
B --> C[Admit queued operation]
C --> D[Bind permission snapshot]
D --> E[Validate active model route]
E --> F[Execute agent turn]
F --> G[Deliver reply]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +7, Tests +130. Total +137 across 3 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Queued replies should carry their own admitted permission snapshot into the existing guarded execution path, with regression coverage that exercises real registry route binding. Do we have a high-confidence way to reproduce the issue? Yes, from source: queued admission produces an operation without a snapshot, and CLI candidate route binding rejects it before execution. The linked report supplies the active-turn/second-message sequence; this review did not execute it. Is this the best way to solve the issue? Yes, the production change narrowly restores the existing snapshot contract without relaxing guards. The test should exercise real route binding during dispatch instead of checking only a mocked call count. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 208aab3aa6f0. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…tchet Move the openclaw#139847 regression test from followup-turn-execution.test.ts to a dedicated followup-turn-execution.tool-authority.test.ts file. The original test file was at 1022 non-blank lines after adding the regression test, exceeding the 1000-line max-lines budget. The max-lines ratchet forbids adding new baseline entries, so the oxlint-disable directive triggered checks-fast-baseline-ratchets. Also fix a tsgo TS2352 error by casting the mock operation through 'unknown' (as unknown as) instead of a direct 'as' cast, since Mock<Procedure> does not overlap with ReplyOperation's method signature.
…rity snapshot Adds a proof test using the REAL replyRunRegistry singleton and REAL prepareReplyToolAuthority function (no mocks) to demonstrate: 1. WITHOUT fix: bindToolAuthorityRoute throws 'no active tool authority snapshot' 2. WITH fix: bindToolAuthoritySnapshot + bindToolAuthorityRoute succeeds 3. Snapshot is bound exactly once (re-binding throws)
This comment was marked as spam.
This comment was marked as spam.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
The real-behavior proof is captured in the PR body Evidence section. The proof test file triggers the preflight job output >1MB GitHub Actions limit. All preflight steps pass — the failure is an infrastructure limit.
What Problem This Solves
Issue #139847 (P1, impact:message-loss, bot-approved queueable-fix + fix-shape-clear + source-repro).
Queued followup execution drops the message with the error "Reply operation has no active tool authority snapshot" when the CLI/embedded candidate calls
bindToolAuthorityRoute. The root cause is that the queued followup path (followup-turn-execution.ts) dispatches viaexecuteAgentTurndirectly, bypassing theagent-runner-run.ts:543call tobindToolAuthoritySnapshot(prepareReplyToolAuthority(...))that the foreground runner makes. Without the bound snapshot,reply-run-registry.operation.tsthrows because!toolAuthoritySnapshotis true.Root Cause
Three-step chain:
followup-turn-admission.ts:164— admission returns the admitted turn but does not bind the tool-authority snapshot.followup-turn-execution.ts:331— queued execution passesturn.operationtoexecuteAgentTurn, bypassing the snapshot binding.agent-runner-cli-candidate.ts:141— CLI candidate callsbindToolAuthorityRoute, registry throws because!toolAuthoritySnapshot.Fix
In
followup-turn-execution.ts, before callingexecuteAgentTurn, bind the tool-authority snapshot:This mirrors the foreground runner's approach at
agent-runner-run.ts:543.Evidence
Real behavior proof (real registry, no mocks)
Added
queued-followup-tool-authority-real-registry-proof.test.ts— uses the REALreplyRunRegistrysingleton and REALprepareReplyToolAuthorityfunction (no mocked dispatch, no mocked operation). Demonstrates the fix end-to-end through the production registry guard:operation.bindToolAuthorityRoute({ provider, model })without first callingbindToolAuthoritySnapshot→ throws"Reply operation has no active tool authority snapshot". This is the exact failure a queued follow-up hits on main.operation.bindToolAuthoritySnapshot(prepareReplyToolAuthority(followupRun))(the exact line added atfollowup-turn-execution.ts:331), thenbindToolAuthorityRoutesucceeds and returns a valid fingerprint string."Reply operation cannot change tool authority after admission"— confirming the fix binds exactly once, matching the foreground runner pattern.Regression test (mock-based)
followup-turn-execution.tool-authority.test.ts— testbinds the tool-authority snapshot before dispatching the queued turnverifiesbindToolAuthoritySnapshotis called once beforeexecuteAgentTurn. This test FAILS without the fix (1 failed) and PASSES with the fix.followup-turn-execution.test.ts+followup-turn-execution.tool-authority.test.ts, 106/106 across 4 test files.followup-turn-execution.test.tsat 994 non-blank lines (under the 1000 budget).Closes #139847