Skip to content

fix(gateway): steering a session while its worktree is being created is held until the task finishes - #165462

Merged
steipete merged 2 commits into
mainfrom
codex/stab-steer-prestart
Oct 5, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/stab-steer-prestart

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a message sent with Steer while a new session is still creating its worktree ("Creating worktree…") never reaches the running task; it is silently held until the task finishes and then runs as a separate follow-up turn.

User Impact

User impact: steering during worktree preparation now joins the session's first turn as soon as the runtime is ready, the same as steering any running turn. If the runtime cannot accept it, the message still runs once as a follow-up (unchanged). No config, protocol, or storage change.

Why This Change Was Made

chat.send with queueMode: "steer" pre-labels the input as already rejected for injection. That is right when admission found the active reply to inject into and the attempt failed, but during worktree preparation the first turn has no reply owner yet, so no injection was ever attempted; the reply runner then skipped its normal steering attempt and queued the message. The label is now applied only when admission actually captured an injection target, so the existing reply owner makes its first attempt once preparation finishes.

The queued-follow-up acknowledgement semantics (the returned run id is finalized when the input is queued, and the follow-up executes under its own run id) are intentionally unchanged here; that is existing tested behavior.

Evidence

Live (dev Gateway, OpenAI provider, one agent on the built-in runtime and one on the Codex runtime): five parallel sessions.create {worktree: true, message} calls; while each was "Creating worktree…" (the global allocation lease made this 10–70 s), a chat.send {queueMode: "steer"} returned started after ~6 s. Both steers (one per runtime) were missing from the transcript while the original task ran, then appeared after its final answer and ran as a new turn; the original task never saw them.

Regression through the real sessions.create + chat.send handlers, pending worktree preparation, reply admission, queue custody, and transcript persistence (synthetic backend acceptance; no provider):

TMPDIR=/private/tmp/oc-steer-prestart pnpm test src/gateway/server-methods/chat-send-prestart-steer.test.ts --maxWorkers=1
main (accepted case):  1 failed — steer acknowledged terminal before the initial turn consumed it
branch:                3 passed (accepted / unavailable / rejected), 47.8 s command wall incl. worker prep (~7.6 s test body)

Siblings unchanged and passing: chat-send-message-injection.test.ts, chat-send-steering-custody.test.ts (38 tests). Gateway test types, scoped lint, formatting, ratchets, and git diff --check pass.

Production +1/−1; new regression tests +337 (one new file, three cases); two existing assertion sites updated; docs +3. The test is seconds-long because it crosses sessions.create worktree preparation and chat.send admission, which no cheaper layer composes.

CI follow-through: run 37286694017 (attempt 1) found three outdated chat.directive-tags.test.ts assertions at two sites: targetless admission must leave messageInjectionDisposition absent, rather than pre-label it rejected. Updated those assertions while retaining the dispatch, stale-owner, and transcript checks. No additional production change.

Corrected candidate proof: all four focused files (chat.directive-tags, chat-send-prestart-steer, chat-send-message-injection, and chat-send-steering-custody) pass: 171 tests, 207.69 s command wall on this host. Formatting, scoped lint, and git diff --check pass. Independent Codex autoreview of the complete candidate is scoped-clean through P2.

Only mark explicit steering rejected when admission captured an injection target. A steer admitted before the initial reply owner exists can then use normal steering admission when workspace preparation finishes.

Preserve existing queued follow-up terminal and cancellation semantics. Add real-handler coverage for accepted, unavailable, and rejected backends, including exactly-once transcript persistence. The regression fails on the original condition and passes after the fix; its three cases take 47.77 seconds command wall, with 38 sibling cases passing separately.
@clawsweeper

clawsweeper Bot commented Oct 5, 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.

@steipete
steipete marked this pull request as ready for review October 5, 2026 08:55
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 5:31 AM ET / 09:31 UTC (Revision 2).

ClawSweeper review

What this changes

The PR lets messages sent with Steer during worktree preparation attempt delivery to the initial turn once its runtime becomes ready, with regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. The narrow production change preserves existing steering safeguards and follow-up custody, and the updated assertions match targetless admission. No blocking correctness finding was identified.

Priority: P2
Reviewed head: 005a50ab587b7349d9b0f84c007336a9d16e290e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no blocking finding; the trusted-author proof exemption applies.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary contributor-proof gate is exempt under Repository State's MEMBER classification. The reported live Gateway run demonstrates the original failure; after-fix evidence exercises the changed dispatch condition through real handlers with synthetic runtime acceptance. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary contributor-proof gate is exempt under Repository State's MEMBER classification. The reported live Gateway run demonstrates the original failure; after-fix evidence exercises the changed dispatch condition through real handlers with synthetic runtime acceptance. No stored-data contract changes.
Evidence reviewed 7 items Pinned production change: The introduced condition marks explicit steering rejected only when admission captured an injection target. Workspace preparation and captured-target finalization still precede ordinary reply dispatch.
Current main still needs the fix: Inspection of fetched main and the original merge-base blob found the unconditional explicit-steer rejection condition in both. The central repair is therefore absent from the pinned current-main context; no implementation-close provenance was established.
Existing steering owner and safeguards: The reply runner interprets an absent disposition as a fresh steering attempt. It checks authority compatibility before calling the existing steering owner, which captures the exact active target, revalidates authority, waits for transcript commitment, and retains rejected input in ordered follow-up custody. This patch adds no authority-bearing value or competing implementation.
Findings None None.
Security None None.

How this fits together

Gateway chat admission accepts session messages before workspace preparation finishes. The reply owner then either steers the message into the active turn or retains it for a follow-up.

flowchart TD
  A[Steer message] --> B[Gateway admission]
  B --> C[Workspace preparation]
  C --> D[Reply owner]
  D --> E{Runtime accepts steering?}
  E -->|Yes| F[Initial turn and transcript]
  E -->|No| G[Follow-up queue]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +337, Docs +3. Total +340 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 2 339 2 +337
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 343 3 +340

Review metrics

None.

Technical review

Best possible solution:

Let the existing reply owner make the first steering attempt after preparation, preserving exact-target authorization and exactly-once follow-up delivery when injection is unavailable.

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

Yes, source establishes the failure path: send an explicit steer while initial worktree preparation has no reply owner; current main pre-labels it rejected and the reply runner skips late injection. No runtime reproduction was executed in this review.

Is this the best way to solve the issue?

Yes, the condition repairs the incorrect disposition at its producer and reuses the established steering owner without changing queue, protocol, configuration, or storage contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded steering failure during new-session worktree preparation while preserving eventual follow-up delivery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary contributor-proof gate is exempt under Repository State's MEMBER classification. The reported live Gateway run demonstrates the original failure; after-fix evidence exercises the changed dispatch condition through real handlers with synthetic runtime acceptance. No stored-data contract changes.

Evidence

What I checked:

  • Pinned production change: The introduced condition marks explicit steering rejected only when admission captured an injection target. Workspace preparation and captured-target finalization still precede ordinary reply dispatch. (src/gateway/server-methods/chat-send-agent-dispatch.ts:391, 005a50ab587b)
  • Current main still needs the fix: Inspection of fetched main and the original merge-base blob found the unconditional explicit-steer rejection condition in both. The central repair is therefore absent from the pinned current-main context; no implementation-close provenance was established. (src/gateway/server-methods/chat-send-agent-dispatch.ts, 10080eaf91bc)
  • Existing steering owner and safeguards: The reply runner interprets an absent disposition as a fresh steering attempt. It checks authority compatibility before calling the existing steering owner, which captures the exact active target, revalidates authority, waits for transcript commitment, and retains rejected input in ordered follow-up custody. This patch adds no authority-bearing value or competing implementation. (src/auto-reply/reply/agent-runner-run.ts:340, 005a50ab587b)
  • Regression coverage and proof scope: The new test exercises sessions.create and chat.send handlers while real worktree preparation is gated, then checks accepted, unavailable, and rejected synthetic backends, terminal ordering, follow-up custody, and exactly-once transcript persistence. Dispatch and backend execution are synthesized, so this is supplemental boundary coverage rather than after-fix live-provider proof. The captured PR body reports a failing baseline and 171 passing focused tests after correction; those executions were not repeated in this read-only review. (src/gateway/server-methods/chat-send-prestart-steer.test.ts:48, 005a50ab587b)
  • Re-review continuity: The prior completed review had no findings. Comparison with its recorded head confirms the new commit changes only two assertion sites to expect an absent disposition for targetless admission; dispatch, stale-owner rejection, and transcript assertions remain. (src/gateway/server-methods/chat.directive-tags.test.ts:1477, 005a50ab587b)
  • Area history and routing: Current-main file history identifies Peter Steinberger's steering restoration and cross-profile steering work, and Vincent Koc's queued-source cancellation maintenance. These support routing suggestions, not causal introduction claims. A deeper blame attempt could not retrieve missing historical objects. (src/auto-reply/reply/agent-runner-steer-adoption.ts, 13747e05516a)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (1 earlier review cycle)
  • reviewed 2026-10-05T09:00:55.297Z sha dcca86f :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 99cade5 into main Oct 5, 2026
119 checks passed
@steipete
steipete deleted the codex/stab-steer-prestart branch October 5, 2026 09:37
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Post-merge live verification on main 500c95a showed this did not fix the common live ordering: a steer sent ~2 s after sessions.create (while "Creating worktree…") still ran as a follow-up on both runtimes, because the first turn's reply operation exists but its backend is not ready yet. Follow-up with live before/after proof on both runtimes: #165537.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…is held until the task finishes (openclaw#165462)

* fix(gateway): attempt pre-start steering after workspace preparation

Only mark explicit steering rejected when admission captured an injection target. A steer admitted before the initial reply owner exists can then use normal steering admission when workspace preparation finishes.

Preserve existing queued follow-up terminal and cancellation semantics. Add real-handler coverage for accepted, unavailable, and rejected backends, including exactly-once transcript persistence. The regression fails on the original condition and passes after the fix; its three cases take 47.77 seconds command wall, with 38 sibling cases passing separately.

* test(gateway): align targetless steering admission expectations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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