Skip to content

fix(agent): apply steering before unstarted tools - #120470

Merged
steipete merged 8 commits into
mainfrom
steipete/steering-before-tool-calls-e3da1b
Aug 8, 2026
Merged

steipete merged 8 commits into
mainfrom
steipete/steering-before-tool-calls-e3da1b

Conversation

@steipete

@steipete steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

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 interrupt remains 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, and chat.send; trace was exactly gate-start, gate-end, the tail tool did not execute, and the next provider request contained the real result, synthetic skip, then the steer.
  • Root/core/core-test typechecks passed; path-scoped oxlint passed for every changed TypeScript file; formatting and git diff --check passed.
  • Full changed gate passed all policy, format, API, boundary, dead-code, declaration, and type lanes. Its broad core lint shard is currently blocked by unrelated existing failures in src/auto-reply/reply/* and src/cli/*; no touched file has a lint finding.
  • Final Codex-backed autoreview: clean, no accepted/actionable findings.
  • Remote proof infrastructure was unavailable before execution: Testbox CLI missing; managed Crabbox broker not authenticated. Trusted-source fallback ran locally per repository policy.

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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling labels Aug 8, 2026
@steipete
steipete marked this pull request as ready for review August 8, 2026 04:47
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 8, 2026
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 11:38 AM ET / 15:38 UTC.

ClawSweeper review

What this changes

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

⚠️ Ready for maintainer review - 4 items remain

Keep 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
Reviewed head: cda77f5116f144a591589d7ee64f5ebebe2299a2
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong boundary-level proof and focused coverage support the implementation; compatibility direction remains a maintainer decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body reports an isolated real Gateway scenario with a fixture plugin, provider trace, and observed tail-tool suppression, which meets the repository’s channel-boundary proof policy.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports an isolated real Gateway scenario with a fixture plugin, provider trace, and observed tail-tool suppression, which meets the repository’s channel-boundary proof policy.
Evidence reviewed 5 items Current behavior is intentionally whole-batch: Current main awaits the complete tool batch and only then drains steering; its agent and concept documentation state that remaining calls are not skipped.
Exact-head callback compatibility repair: The PR invokes public steering callbacks with the AgentLoopConfig receiver, and the regression test uses a method-style callback that drains config-owned state.
Launch-boundary ownership: The exact head prepares wrapper-owned work before rechecking steering, then either disposes it or commits and launches it; skipped calls receive paired synthetic results.
Findings None None.
Security None None.

How this fits together

Agent 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
Loading

Decision needed

Question Recommendation
Should OpenClaw replace its documented whole-batch steering default with launch-boundary suppression of unstarted OpenClaw tools? Adopt launch-boundary steering: Accept the new default after verifying the native Codex wording and preserve /queue interrupt as the explicit running-tool abort path.

Why: Current main documents the existing behavior as intentional; correctness of the implementation cannot decide the compatibility and operator-experience tradeoff.

Before merge

  • Resolve merge risk (P1) - This deliberately changes the documented default from whole-batch delivery, so existing operators or extensions may rely on tool calls that will now be skipped.
  • Resolve merge risk (P1) - Synthetic skip results change transcript ordering and tool-loop accounting before the steering message is injected.
  • Resolve merge risk (P1) - The required sibling Codex source checkout is absent and the read-only sandbox cannot clone it, so this review could not independently verify the native Codex scheduling statement in the updated docs.
Agent review details

Security

None.

PR surface

Source +892, Tests +1660, Docs +3. Total +2555 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 18 1261 369 +892
Tests 9 1694 34 +1660
Docs 3 24 21 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 30 2979 424 +2555

Review metrics

Metric Value Why it matters
Production versus test delta production +1309/-370; tests +1646/-33; docs +24/-21 The substantial production growth is tied to the new execution-preparation and lifecycle ownership boundary rather than incidental churn.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/embedded-agent-runner/run/code-mode-repair.test.ts, migration/backfill/repair: src/agents/embedded-agent-runner/run/code-mode-repair.ts, serialized state: test/gateway-steer-fifo.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm and document the new default (recommended)
    Accept the compatibility change after direct upstream Codex verification and retain the explicit running-tool interrupt path.
  2. Keep the existing batch contract
    Do not merge the semantic change if whole-batch tool execution remains the intended compatibility contract.

Technical review

Best possible solution:

Confirm launch-boundary steering as the desired default, retain /queue interrupt for aborting running work, and verify the native Codex wording against the required upstream source before landing.

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.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports an isolated real Gateway scenario with a fixture plugin, provider trace, and observed tail-tool suppression, which meets the repository’s channel-boundary proof policy.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 other: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 session-state.

Label justifications:

  • P1: Queued steering affects active agent runs and whether user-redirection prevents later tool side effects.
  • merge-risk: 🚨 compatibility: The patch replaces a documented whole-batch default with suppression of unstarted tools.
  • merge-risk: 🚨 session-state: It inserts synthetic tool results and steering messages into active-run transcripts and loop-admission state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports an isolated real Gateway scenario with a fixture plugin, provider trace, and observed tail-tool suppression, which meets the repository’s channel-boundary proof policy.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports an isolated real Gateway scenario with a fixture plugin, provider trace, and observed tail-tool suppression, which meets the repository’s channel-boundary proof policy.

Evidence

What I checked:

  • Current behavior is intentionally whole-batch: Current main awaits the complete tool batch and only then drains steering; its agent and concept documentation state that remaining calls are not skipped. (packages/agent-core/src/agent-loop.ts:386, 7ecdef6e2ed4)
  • Exact-head callback compatibility repair: The PR invokes public steering callbacks with the AgentLoopConfig receiver, and the regression test uses a method-style callback that drains config-owned state. (packages/agent-core/src/agent-loop.ts:73, cda77f5116f1)
  • Launch-boundary ownership: The exact head prepares wrapper-owned work before rechecking steering, then either disposes it or commits and launches it; skipped calls receive paired synthetic results. (packages/agent-core/src/agent-loop.ts:837, cda77f5116f1)
  • Unshipped PR head: The PR head is not an ancestor of the latest release tag, so it is neither merged nor released. (cda77f5116f1)
  • Feature-history provenance: The exact repair series includes the wrapper-preflight boundary commit followed by the callback-receiver compatibility correction. (packages/agent-core/src/agent-loop.ts:73, 5671e5363f48)

Likely related people:

  • steipete: Authored the complete steering repair series, including the wrapper-preflight boundary and the final public-callback compatibility correction. (role: current feature and repair owner; confidence: high; commits: 5671e5363f48, cda77f5116f1; files: packages/agent-core/src/agent-loop.ts, src/agents/agent-tools.before-tool-call.wrapper.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Verify the native Codex scheduler statement directly against the required upstream source before landing.
  • Confirm that changing the documented whole-batch default is acceptable for existing operators and extensions.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-08T05:45:35.304Z sha c78723a :: found issues before merge. :: [P1] Do not record steering-skipped calls as admitted attempts | [P2] Update the central steering description | [P3] Update the embedded-session steering contract
  • reviewed 2026-08-08T08:38:02.124Z sha 803a157f2044d888627cfef90739f6a10a9f6bf8 :: found issues before merge. :: [P1] Recheck steering after adapter-owned preflight
  • reviewed 2026-08-08T08:43:55.888Z sha 803a157f2044d888627cfef90739f6a10a9f6bf8 :: needs changes before merge. :: [P1] Recheck steering after adapter-owned preflight
  • reviewed 2026-08-08T09:43:03.095Z sha 3542046 :: found issues before merge. :: [P1] Recheck steering after wrapper-owned preflight
  • reviewed 2026-08-08T10:43:27.874Z sha 3542046 :: found issues before merge. :: [P1] Recheck steering after wrapper-owned preflight
  • reviewed 2026-08-08T13:38:35.756Z sha 5671e53 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-08T13:48:21.752Z sha 5671e53 :: found issues before merge. :: [P1] Preserve the steering callback receiver

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed all exact-head findings in commit 4517df1.

  • P1 loop-admission accounting: successful whole-batch admission now installs markers only. Agent Core commits diagnostic history in assistant order only for prepared calls crossing the final launch checkpoint; steering-skipped calls release their exact markers without ever entering bounded history. Loop-veto evidence still commits immediately. Repeated identical admit/release cycles now have focused coverage, followed by a real identical call that admits and commits once.
  • P2 central docs: docs/concepts/agent.md now describes running-tool completion, unstarted sequential skips, the parallel launch checkpoint, and paired synthetic results.
  • P3 session contract: AgentSession.steer now documents delivery before unstarted tool launches or the next model call.
  • Native Codex contract verified directly: inspected openai/codex@c2bcb9a26b5bdbdc66c48cf3bc3bb382568e800c. steer_input queues pending turn input in session/mod.rs, and the turn loop drains pending input before the next sampling request in session/turn.rs. OpenClaw does not claim per-tool parity for the native Codex runtime.

Focused proof after the repair:

  • Agent Core: 59 passed.
  • Tool-loop admission: 6 passed, including bounded-history and repeated-identical-steer coverage.
  • Tool-loop recovery: 1 passed.
  • Code Mode: 19 passed.
  • Exact real Gateway steering scenario: passed.
  • Core/core-test/root typechecks and all touched-file oxlint passed.
  • Codex-backed autoreview: clean, no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Exact-head CI follow-up is fixed in commit 88ba3e5.

The delayed-admission callbacks had accidentally widened exported InternalBeforeToolBatchResult, causing Plugin SDK API and bundled protocol drift. The public result shape is restored. Launch lifecycle state now uses a private, one-shot WeakMap in packages/agent-core/src/internal-hooks.ts, accessed only through the existing OpenClaw internal runtime façade; no baseline or generated manifest changed.

Reproduced and verified the exact CI jobs locally:

  • pnpm plugin-sdk:api:check — baseline hash OK.
  • pnpm test:bundled — 205/205 passed.
  • pnpm protocol:check — registry, schema generation diff, Swift, Kotlin, and since guard passed with no generated diff.
  • Agent Core — 60 passed.
  • Tool-loop admission — 6 passed.
  • Tool-loop recovery — 1 passed.
  • Final Codex-backed autoreview — clean, no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@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 errorKind union. Both are restored exactly.

  • Built-in Agent steering keeps the synchronous no-yield checkpoint via a private function-keyed WeakMap; external/public callbacks remain Promise-based and awaited.
  • Steering-skipped outcomes use structured result details { status: "skipped", deniedReason: "steering" }; Code Mode consumes that detail without public enum/protocol changes.
  • Delayed loop-admission lifecycle remains behind the private internal-hooks WeakMap.
  • No API baseline, protocol output, or generated manifest changed.

Exact CI-equivalent proof:

  • pnpm plugin-sdk:api:check — hash OK.
  • pnpm test:bundled — 205/205.
  • pnpm protocol:check — registry/schema/Swift/Kotlin/since/diff all passed.
  • Agent Core — 61 passed; loop admission — 6; recovery/Code Mode — 20.
  • Core/core-test types, touched-file lint/format, and final Codex-backed autoreview passed.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete force-pushed the steipete/steering-before-tool-calls-e3da1b branch from bd944ba to 803a157 Compare August 8, 2026 08:32
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Final rebased head: 803a157f2044d888627cfef90739f6a10a9f6bf8.

The stack was rebased conflict-free onto current origin/main (a4b4c58e87cee2d3d818f49d4520fa2e548c75fc). This retains main's current generated GatewayModels.swift and newer compatible Agent Core changes, resolving the Linux protocol-generation drift without generated edits in this PR.

Post-rebase proof:

  • pnpm plugin-sdk:api:check — hash OK.
  • pnpm test:bundled — 205/205.
  • pnpm protocol:check — registry/schema/Swift/Kotlin/since/diff passed.
  • Agent Core 61; loop admission 6; recovery/Code Mode 20.
  • Core/core-test/root type and touched-file lint/format passed.
  • Gateway fixture now uses current canonical agents.entries; the behavioral scenario has prior clean real-gateway passes. The currently loaded local host later timed out before gateway startup with empty logs, so Linux exact-head CI remains the final gateway-start proof.
  • Final autoreview after each follow-up: clean, no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 8, 2026
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Exact-head static CI repairs are in 2be456902a6c982c9a8b302b70e6f138ece08e66.

  • Removed the unused InternalToolBatchLifecycle runtime-facade type re-export that caused deadcode dependency/export failures.
  • Extracted QA Lab CLI subprocess ownership into suite-runtime-cli-process.ts; QA production LOC is net -2 and the original module is below max-lines.
  • Split the oversized AgentSession loop test into compaction-recovery and loop-lifecycle suites with one shared fixture module; no suppressions/baseline changes.

Proof:

  • Session split tests: 25/25.
  • QA process tests: 38/38.
  • Max-lines ratchet passed.
  • Full deadcode dependency and export scans passed with zero findings.
  • Core/core-test/extension types and targeted lint passed.
  • Full pnpm build passed, including public Plugin SDK declaration verification and Control UI build.
  • Codex-backed autoreview: clean, no accepted/actionable findings.

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.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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.
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed 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. labels Aug 8, 2026
Invoke public steering callbacks with their AgentLoopConfig receiver and cover method-style implementations that read config-owned queue state.
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the exact-head callback compatibility finding in cda77f5.

getSteeringAtCheckpoint now invokes the public Promise callback as callback.call(config), preserving the historical AgentLoopConfig receiver for method-style implementations. The private synchronous Agent getter path remains unchanged.

Regression proof adds a method-style callback that drains this.queuedSteering; Agent Core now passes 66/66, with core/core-test types, targeted lint/format, diff check, and Codex-backed autoreview clean.

Maintainer intent is explicit: this PR adopts launch-boundary steering for unstarted OpenClaw tools while retaining /queue interrupt for aborting already-running work. Native Codex remains model-boundary-only, verified directly against openai/codex@c2bcb9a26b5bdbdc66c48cf3bc3bb382568e800c.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 8, 2026
@steipete steipete self-assigned this Aug 8, 2026
@steipete
steipete merged commit 7fd723b into main Aug 8, 2026
130 checks passed
@steipete
steipete deleted the steipete/steering-before-tool-calls-e3da1b branch August 8, 2026 16:52
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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