Repository navigation
fix(agent): apply steering before unstarted tools - #120470
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 11:38 AM ET / 15:38 UTC. ClawSweeper reviewWhat this changesThis PR changes active-run steering so queued user input suppresses unstarted OpenClaw tool calls at a final launch checkpoint while keeping paired synthetic tool results. Merge readinessKeep open for maintainer product direction: current main intentionally waits for the whole tool-call batch, while this PR changes the default to skip unstarted tools. The exact-head repair is internally coherent and clears the prior callback finding, but the semantic change and its native Codex documentation claim need explicit owner confirmation. Priority: P1 Review scores
Verification
How this fits togetherAgent Core executes model-requested tool batches and appends their results before the next model turn. Session steering supplies queued user input; tool wrappers handle policy and preparation before Agent Core authorizes the actual side effect. flowchart LR
A[Queued user steering] --> B[Session steering queue]
C[Model tool-call batch] --> D[Tool preparation and policy]
D --> E[Final launch checkpoint]
B --> E
E -->|No queued steer| F[Tool side effect]
E -->|Queued steer| G[Synthetic skipped result]
F --> H[Next model turn]
G --> H
Decision needed
Why: Current main documents the existing behavior as intentional; correctness of the implementation cannot decide the compatibility and operator-experience tradeoff. Before merge
Agent review detailsSecurityNone. PR surfaceSource +892, Tests +1660, Docs +3. Total +2555 across 30 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Confirm launch-boundary steering as the desired default, retain Do we have a high-confidence way to reproduce the issue? Yes, source establishes the current whole-batch path, and the PR provides a focused Gateway scenario that queues steering while a tool is held before launch; this read-only review did not execute that scenario. Is this the best way to solve the issue? Unclear: the implementation is a coherent owner-boundary solution, but changing a deliberately documented default requires maintainer confirmation and direct upstream Codex verification for its runtime-specific wording. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7ecdef6e2ed4. LabelsLabel changes:
Label 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 (7 earlier review cycles)
|
|
@clawsweeper re-review Addressed all exact-head findings in commit 4517df1.
Focused proof after the repair:
|
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review Exact-head CI follow-up is fixed in commit 88ba3e5. The delayed-admission callbacks had accidentally widened exported Reproduced and verified the exact CI jobs locally:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Final exact-head compatibility correction: bd944ba Clean Linux CI had exposed two remaining public changes from the original patch: the Promise-only steering callback signature and the public pre-execution
Exact CI-equivalent proof:
|
|
🦞👀 Command router queued. I will update this comment with the next step. |
bd944ba to
803a157
Compare
|
@clawsweeper re-review Final rebased head: The stack was rebased conflict-free onto current Post-rebase proof:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Exact-head static CI repairs are in
Proof:
The remaining prior CI failures were unrelated context/session-state test shards; this fresh run will show whether they persist after deterministic static blockers are clean. |
|
🦞👀 Command router queued. I will update this comment with the next step. |
Restore steering checkpoints before sequential tool launches and before parallel batch launch. Preserve paired synthetic tool results, async callback compatibility, and Code Mode outcome handling.
Commit loop-detection history only for calls crossing the final launch checkpoint. Release steering-skipped markers, add repeated-steer coverage, and align remaining steering contract text.
Invoke public steering callbacks with their AgentLoopConfig receiver and cover method-style implementations that read config-owned queue state.
|
@clawsweeper re-review Addressed the exact-head callback compatibility finding in cda77f5.
Regression proof adds a method-style callback that drains Maintainer intent is explicit: this PR adopts launch-boundary steering for unstarted OpenClaw tools while retaining |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
Merged via squash.
|
* fix(agent): apply steering before unstarted tools Restore steering checkpoints before sequential tool launches and before parallel batch launch. Preserve paired synthetic tool results, async callback compatibility, and Code Mode outcome handling. * fix(agent): delay tool loop admission commits Commit loop-detection history only for calls crossing the final launch checkpoint. Release steering-skipped markers, add repeated-steer coverage, and align remaining steering contract text. * fix(agent): keep tool admission lifecycle internal Attach delayed admission callbacks through the private internal-hooks seam so steering history remains correct without widening the public Agent Core or Plugin SDK contract. * fix(agent): preserve steering API contracts Keep public steering callbacks Promise-based and protocol error kinds unchanged. Use private synchronous draining and structured skip details to retain launch-boundary behavior without API or generated protocol drift. * test(gateway): use canonical steering fixture config Use keyed agent entries in the real gateway steering harness so current main does not migrate the fixture during startup. * fix(agent): remove unused lifecycle re-export * fix(agent): gate tool launch after wrapper preflight Split OpenClaw tool execution into private prepare and launch phases so steering is checked after policy, approval, validation, and reconciliation but before the original side effect. Preserve final arguments, voice grants, loop admission, context wrappers, and direct tool execution. * fix(agent): preserve steering callback receiver Invoke public steering callbacks with their AgentLoopConfig receiver and cover method-style implementations that read config-owned queue state.
What Problem This Solves
Queued steering was accepted during active runs but agent-core waited for the entire assistant tool-call batch to finish. In a multi-call batch, tools that had not started could still run after the operator had redirected the agent.
Why This Change Was Made
Restore the earlier per-tool steering invariant at the owner boundary in packages/agent-core. Sequential execution now checks before each launch (and again after async preparation); parallel batches check once immediately before launch. Already-running tools continue. Every suppressed call receives a paired synthetic tool result so provider transcripts, prompt caches, lifecycle subscribers, and audit hooks remain structurally valid. Async steering providers remain compatible, while the built-in queue has a synchronous no-yield checkpoint. Code Mode recognizes steering skips as intentional non-execution rather than repairable failures. Native Codex remains upstream-owned model-boundary steering.
Context: #10960 documented the earlier whole-batch decision; this PR revisits the narrower unstarted-tool case after a concrete reproduction.
User Impact
A steering message now takes effect before the next unstarted OpenClaw tool. The current running tool finishes; remaining sequential calls are skipped and the model immediately reconsiders with the steering message. A parallel batch continues only after it has crossed its single launch checkpoint.
/queue interruptremains the option for aborting already-running work.Evidence
node scripts/run-vitest.mjs packages/agent-core/src/agent-loop.test.ts— 56 passed.node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/code-mode-repair.test.ts— 19 passed.OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs --config test/vitest/vitest.e2e.config.ts test/gateway-steer-fifo.e2e.test.ts -t "skips an unstarted sequential tool after a Gateway steer"— passed through a real isolated Gateway, fixture plugin, mock Responses provider, andchat.send; trace was exactlygate-start,gate-end, the tail tool did not execute, and the next provider request contained the real result, synthetic skip, then the steer.git diff --checkpassed.src/auto-reply/reply/*andsrc/cli/*; no touched file has a lint finding.Production TypeScript delta: +194/-81 (net +113), justified by the new scheduling/ownership boundary. Tests: +584/-7 before the final gateway lint cleanup; docs: net +2. Do not mention internal/private model identifiers.