Skip to content

fix: deliver subagent completions after busy parent turns - #136423

Merged
steipete merged 6 commits into
mainfrom
fix/subagent-parent-turn-admission
Sep 2, 2026
Merged

steipete merged 6 commits into
mainfrom
fix/subagent-parent-turn-admission

Conversation

@steipete

@steipete steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #134186: a busy Claude CLI parent could reject its child's completion with Session … already has an active turn claim after an unavailable wake, including no_active_run. Addresses the turn-claim/completion portion of #135192. Its independent migration, readiness, and ingress observations remain tracked in #136487, #136488, #136489, #136490, and #136491; the broader replay/dead-letter proposal remains #120422.

Thanks @svdwalt007 and @Tony-Clawbot for the reports, and @Isitjustmefromparis for the independent confirmation.

Why This Change Was Made

Direct CLI turns now enter the same per-session admission lane as embedded and Codex turns before acquiring placement ownership. The lane retains queued run context and records capacity wait. Dequeue checks cancellation, runtime lifecycle, the exact placement provider, and the prepared durable session incarnation. Command and reply preparation reload session facts after admission; cron resolves its native binding inside the same boundary.

A newly accepted completion waits for its final result without spending execution timeout while queued. Execution start revalidates its source and arms the execution budget. The completion lifecycle separately owns the existing required-delivery 30-minute deadline and optional-delivery five-minute deadline, so a permanently busy parent cannot strand cleanup forever. Existing manual retry windows remain authoritative.

Claim release stays with exact turn settlement and forced-terminal cleanup. Those owners already release settled claims; a late finalizer must never release a successor's claim. This repair does not add claim-retry loops, another queue, or another store.

No new configuration, environment variables, schema, protocol version, dependencies, or compatibility path. No changelog change.

User Impact

An active requester still gets same-turn steering when supported. Otherwise, its completion waits for a follow-up turn after the parent releases its claim. Cancelled, replaced, or expired queued work cannot later execute through a replacement owner. Deadline expiry retains the existing visible blocked-result outcome.

The separate pre-existing duplicate-RPC replay accounting defect is tracked in #136513: in_flight can receive premature delivery credit. A result-only change would let retries steer an announcement into itself, so that issue needs a canonical same-id join rather than a partial fix here. The companion Discord oversized-message symptom was not reproduced or claimed fixed.

Evidence

  • Before-fix regressions failed for CLI→CLI and embedded→CLI claim contention, accepted queue waits exhausting execution timeout, durable session revision replacement, and permanently queued required/optional delivery deadlines.
  • On 11fd22f91844cec74a82a077b4b9a9d605a1a05e, focused admission/delivery/cleanup/lifecycle coverage passed 441 tests. The split CLI reply suites passed 18 tests with moved test bodies verified byte-identical. Both durable reply revision cases had failed before the production correction.
  • Other completed focused coverage: command CLI 135; CLI dispatch 25; cron override 25 plus cron siblings; internal facade 6; original exact-claim/fallback classification 269. Counts are suite results, not an aggregate unique-test claim.
  • Full branch autoreview is clean at P0/P1. Runtime refresh and UI build passed. The final exact-head changed-file check passed. Exact-head CI is green after retrying a public pre-commit hook fetch failure and its dependent aggregate; the PR head remained unchanged. Current main CI is also green.
  • Production +369/−193 (net +176); tests +643/−155 (net +488, including the test-file move); docs +5/−5. Growth supplies shared admission/context-retention fences, durable-target revalidation, and a separately bounded delivery lifetime. Existing CLI preparation moved inside its owner; no parallel queue/store was introduced. A separate follow-up moves native CLI binding publication into turn settlement and removes late duplicate writers.

Final-head live proof

Inspected Control UI screenshots and event trace verify a real Claude CLI parent and child on 11fd22f91844cec74a82a077b4b9a9d605a1a05e, through an isolated loopback Gateway, synthetic data only:

19:12:48.707Z child assistant final: CHILD_COMPLETION_ADMISSION_136423_11FD
19:15:51.945Z parent assistant final: PARENT_INITIAL_FINISHED_136423_11FD
19:16:05.683Z separate parent announcement final visibly contains CHILD_COMPLETION_ADMISSION_136423_11FD
parent stayed busy after child finished: 183238 ms
active-turn-claim collisions: 0
19:17:09.303Z foreground CLI turn aborted through Control UI
19:17:24.093Z fresh turn in the same session: POST_ABORT_CLAIM_RELEASED_136423_11FD

Received WebSocket chat events with state=final, assistant role, distinct initial/announcement run IDs, and the same requester session establish delivery and order. Prompt text alone was not counted. The rejected active wake used requester-agent handoff successfully. The exact no_active_run case is regression-covered, not claimed as the observed live wake reason (runtime_rejected).

Review follow-through

ClawSweeper's accepted queue-deadline finding is addressed: lifecycle-owned cancellation bounds permanently queued delivery by its existing required or optional deadline, with failing-before/passing-after tests. The production-growth explanation, exact-head real behavior trace, and focused suites address the latest rank-up requests. The unrelated main lint failure from #133381 was repaired in aef65cc57490; exact-head validation and CI are now green. The final ClawSweeper review reports no actionable code findings and accepts the real behavior proof.

Admit direct CLI turns through the shared session lane before placement claims. Preserve accepted completion execution budgets while queued, and revalidate run, source, and session owners before execution.

Fixes #134186. Addresses turn admission in #135192. Reported by @svdwalt007 and @Tony-Clawbot; confirmed by @Isitjustmefromparis.
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added 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. 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 Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 3:39 PM ET / 19:39 UTC.

ClawSweeper review

What this changes

The branch queues local CLI, fallback, and cron turns through the requester session lane, fences queued work against lifecycle changes, and separates completion queue wait from execution timeout.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. The branch uses the correct shared session-admission boundary for busy-parent completion delivery, but exact-head validation remains necessary before merge and the review environment could not fully materialize current-main objects from its offline partial clone.

Priority: P1
Reviewed head: 11fd22f91844cec74a82a077b4b9a9d605a1a05e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a coherent owner-boundary repair with focused lifecycle evidence; exact-head cross-runtime validation remains the material merge gate.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR discussion supplies a real Claude CLI parent/child loopback-Gateway trace showing a busy parent, later distinct completion delivery, no claim collisions, and recovery after abort; the attached media could not be independently retrieved from this offline environment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR discussion supplies a real Claude CLI parent/child loopback-Gateway trace showing a busy parent, later distinct completion delivery, no claim collisions, and recovery after abort; the attached media could not be independently retrieved from this offline environment.
Evidence reviewed 6 items Shared admission repair: The PR adds a session-lane wrapper around local CLI placement admission and revalidates abort state, lifecycle generation, and provider ownership before queued work executes.
Caller preserves session identity: Direct CLI attempts enter the shared admission boundary, reload the durable session after admission, and abort if its ID or lifecycle revision changed while queued.
Delivery deadline remains bounded: Cleanup gives accepted handoffs an independent lifecycle deadline, allowing a busy-parent queue wait without consuming the execution timeout.
Findings None None.
Security None None.

How this fits together

Subagent completion delivery asks the Gateway to notify the requester session when delegated work finishes. Session admission serializes local CLI and embedded work for that requester so placement ownership and completion delivery cannot race an already-active turn.

flowchart LR
  A[Subagent completes] --> B[Completion announcement]
  B --> C[Gateway turn request]
  C --> D[Shared session lane]
  D --> E[Placement and local CLI turn]
  E --> F[Requester receives completion]
Loading

Before merge

  • Resolve merge risk (P2) - This changes serialization, cancellation fencing, and durable-session revision behavior for multiple turn sources; exact-head checks should cover direct CLI, fallback, cron, embedded, and completion-delivery lifecycle interactions before landing.
Agent review details

Security

None.

PR surface

Source +176, Tests +488, Docs 0. Total +664 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 8 369 193 +176
Tests 7 643 155 +488
Docs 2 5 5 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 1017 353 +664

Review metrics

Metric Value Why it matters
Production vs test LOC production +369/-193; tests +643/-155; docs +5/-5 Production growth consolidates session-lane admission, lifecycle fencing, and deadline ownership; its shared scheduling scope merits exact-head validation.

Merge-risk options

Maintainer options:

  1. Validate the shared admission boundary (recommended)
    Require exact-head coverage for local CLI admission, fallback and cron siblings, and completion-delivery cancellation/deadline behavior before merging.
  2. Pause for a broader runtime audit
    Pause the PR if the affected cross-runtime session-lane interactions cannot be validated on the current head.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Require exact-head checks covering local CLI admission, fallback and cron sibling paths, and completion-delivery cancellation and deadline behavior.

Technical review

Best possible solution:

Keep one shared session-admission flow with lifecycle fencing and independently bounded delivery deadlines, then validate the affected turn sources on the exact PR head.

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

Yes, source-reproducible: the branch supplies focused busy-parent and lifecycle-boundary coverage, though this read-only review did not execute those tests.

Is this the best way to solve the issue?

Yes: a common session-admission boundary repairs the owner-level race across direct CLI, fallback, and cron paths; a timer-retry-only change would retain the collision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1e37a56c7528.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR discussion supplies a real Claude CLI parent/child loopback-Gateway trace showing a busy parent, later distinct completion delivery, no claim collisions, and recovery after abort; the attached media could not be independently retrieved from this offline environment.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The repair targets delayed or potentially lost delegated-work completion delivery when a requester session is busy.
  • merge-risk: 🚨 session-state: Merging changes how concurrent turns sharing one requester session are serialized, cancelled, and revalidated.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR discussion supplies a real Claude CLI parent/child loopback-Gateway trace showing a busy parent, later distinct completion delivery, no claim collisions, and recovery after abort; the attached media could not be independently retrieved from this offline environment.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR discussion supplies a real Claude CLI parent/child loopback-Gateway trace showing a busy parent, later distinct completion delivery, no claim collisions, and recovery after abort; the attached media could not be independently retrieved from this offline environment.

Evidence

What I checked:

  • Shared admission repair: The PR adds a session-lane wrapper around local CLI placement admission and revalidates abort state, lifecycle generation, and provider ownership before queued work executes. (src/agents/session-placement-admission.ts:118, c7b8c719d639)
  • Caller preserves session identity: Direct CLI attempts enter the shared admission boundary, reload the durable session after admission, and abort if its ID or lifecycle revision changed while queued. (src/agents/command/attempt-execution.ts:870, 11fd22f91844)
  • Delivery deadline remains bounded: Cleanup gives accepted handoffs an independent lifecycle deadline, allowing a busy-parent queue wait without consuming the execution timeout. (src/agents/subagents/registry/subagent-registry-lifecycle-announce-cleanup.ts:653, 11fd22f91844)
  • Execution-start signal is correctly placed: The Gateway emits the added execution-start callback only after the run’s abort owner marks the execution as started. (src/gateway/agent-turn/agent-run-execution-phase.ts:452, 11fd22f91844)
  • Current-main check limitation: Reading the local current-main version of the central admission file required a missing promisor object; the partial clone attempted a network fetch, but DNS was unavailable. This prevents a full current-main equivalence claim, not review of the introduced branch diff. (src/agents/session-placement-admission.ts, 1e37a56c7528)
  • Codex contract directly inspected: The local Codex source documents FIFO queued turns that start when idle and steering limited to an active regular turn; its checkout origin is a local cache, so repository ownership is not independently verified here. (codex-rs/app-server/README.md:860, 5adb68a49933ae446bf11935662c83dba55a0804)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Complete exact-head required CI before merge.

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 (5 earlier review cycles)
  • reviewed 2026-09-02T16:33:14.617Z sha c7b8c71 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T17:27:56.202Z sha b6177c6 :: found issues before merge. :: [P1] Bound accepted queue waits by the required-completion deadline
  • reviewed 2026-09-02T18:26:17.899Z sha e372644 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T18:52:19.069Z sha e6695d9 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T19:08:36.065Z sha 11fd22f :: needs maintainer review before merge. :: none

Keep the lazy asynchronous CLI runtime contract when resolving native continuity inside the session lane. The existing delayed-binding regression catches model execution starting before lookup settlement.
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Sep 2, 2026
Keep admission wait outside the execution budget while the cleanup owner enforces the existing delivery window. Honor explicit retries and retained optional announcements; cancel stale queued work before it can execute.
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
Reload the durable reply target after session admission and reject session ID or lifecycle revision changes before starting the CLI. Internal turns without a store target retain their in-memory path. Seed the existing durable-session fixture and type rejection callbacks explicitly.

Both lifecycle replacement regressions fail before this fix. Reply routing, CLI dispatch, and admission coverage pass: 62 tests. Refs #134186, #135192.
@steipete
steipete marked this pull request as ready for review September 2, 2026 18:44
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Final-head live proof

Verified 11fd22f91844cec74a82a077b4b9a9d605a1a05e with a real Claude CLI parent and child through an isolated loopback Gateway and Control UI, synthetic data only. Runtime and UI shared build identity 2026.8.1-11fd22f91844-2026-09-02T19-09-06.259Z. No operator state or default Gateway port was used.

2026-09-02 19:12:40Z  parent calls sessions_spawn; real child accepted
2026-09-02 19:12:48.707Z  child assistant final: CHILD_COMPLETION_ADMISSION_136423_11FD
2026-09-02 19:15:51.945Z  parent assistant final: PARENT_INITIAL_FINISHED_136423_11FD
2026-09-02 19:16:05.683Z  separate announcement final visibly contains CHILD_COMPLETION_ADMISSION_136423_11FD
parent stayed active after child completion: 183238 ms
active-turn-claim collisions in received Control UI frames: 0

2026-09-02 19:17:09.303Z  Control UI chat aborted event for a foreground CLI turn
2026-09-02 19:17:24.093Z  fresh turn in the same session returns POST_ABORT_CLAIM_RELEASED_136423_11FD

The parent remained busy in a foreground 160-second Python wait. Claude's native hook rejected the initial shell sleep; the trace records that refusal and the subsequent foreground call rather than hiding it. The active wake reported runtime_rejected; requester-agent handoff then waited through shared admission and delivered after settlement. The exact no_active_run variant is unit-covered, not claimed as the live wake reason.

Delivery assertions used received chat events with state=final, assistant role, the same requester session, and distinct initial/announcement run IDs. A user prompt containing the marker was not counted. Cancellation proof used the actual aborted event followed by a different successful run. Both attached captures were inspected in full and contain only this synthetic scenario.

Exact-head focused admission/delivery/cleanup/lifecycle suites: 441 passed. The reply suite split preserved test bodies byte-for-byte and passed 18 tests. Full branch autoreview is clean at P0/P1. Runtime refresh and UI build passed. The final changed-file check is still running; CI is not yet green because main's unrelated gateway-backed-exit.process.test.ts exceeds its line limit, introduced by #133381. Our reply-test line-limit failure is fixed and absent from the new CI log.

This addresses the latest ClawSweeper request for current-head behavior evidence and focused results. Landing remains gated on completed validation and green CI.

Queued-child-completion-visible-in-parent

Fresh-turn-after-cancellation

@steipete
steipete marked this pull request as draft September 2, 2026 19:26
@steipete steipete closed this Sep 2, 2026
@steipete steipete reopened this Sep 2, 2026
@steipete
steipete marked this pull request as ready for review September 2, 2026 19:29
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 2, 2026
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Ready to land at 11fd22f91844cec74a82a077b4b9a9d605a1a05e after the native prepare/merge gates. Exact-head CI and current-main CI are verified green.

The repaired owner is src/agents/session-placement-admission.ts:118: direct CLI turns now join the existing per-session lane before taking placement ownership. Command, reply, and cron callers use that same boundary; embedded and Codex runtimes already share the lane. Queued announcements retain their execution budget while the registry's existing delivery deadline bounds their lifetime. Prepared session identity/revision is revalidated after admission. No competing-claim retry or stale-claim stealing was added.

Exact-head validation: node scripts/check-changed.mjs --base 296b2ef4a28d0fd9767ba3b8f5c40eafab6033ae --head 11fd22f91844cec74a82a077b4b9a9d605a1a05e passed; the focused admission/delivery/cleanup/lifecycle wrapper run passed 441 tests, and the split reply suites passed 18. Full branch autoreview had no accepted findings. The real isolated Gateway/Control UI proof shows child completion while the parent stayed busy another 183 seconds, distinct completion delivery after parent settlement, no claim error, and a successful same-session turn after an actual abort. Temporary credentials/runtime state were removed after shutdown.

Exact-head CI is green after retrying the failed security bootstrap and its aggregate gate. The first attempt's code/test jobs passed; pre-commit failed fetching a public hook before scanning. Main CI is also green. The latest ClawSweeper review found no actionable code findings; its remaining exact-head CI rank-up move is satisfied.

Production: +369/-193 (+176). Tests: +643/-155 (+488, including moved tests). Docs: +5/-5. Production growth provides missing lifecycle/capacity retention, durable-target fencing, and independent delivery lifetime; it does not add a second queue/store. The separate late CLI-binding settlement refactor remains in progress. Pending-replay accounting stays tracked in #136513, and the other #135192 observations remain split into #136487–#136491. Discord oversized-message behavior was not claimed fixed.

Reporter credit: @svdwalt007, @Tony-Clawbot, and @Isitjustmefromparis. No changelog, config/env option, schema/version, protocol bump, or dependency override was added.

@steipete
steipete merged commit 8b0cc70 into main Sep 2, 2026
765 of 820 checks passed
@steipete
steipete deleted the fix/subagent-parent-turn-admission branch September 2, 2026 20:10
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
…36423)

* fix: queue subagent completions behind busy parent turns

Admit direct CLI turns through the shared session lane before placement claims. Preserve accepted completion execution budgets while queued, and revalidate run, source, and session owners before execution.

Fixes openclaw#134186. Addresses turn admission in openclaw#135192. Reported by @svdwalt007 and @Tony-Clawbot; confirmed by @Isitjustmefromparis.

* fix: await cron CLI binding after turn admission

Keep the lazy asynchronous CLI runtime contract when resolving native continuity inside the session lane. The existing delayed-binding regression catches model execution starting before lookup settlement.

* fix: fence queued CLI turns by their prepared lifecycle revision

* fix: bound queued completions by their delivery deadline

Keep admission wait outside the execution budget while the cleanup owner enforces the existing delivery window. Honor explicit retries and retained optional announcements; cancel stale queued work before it can execute.

* fix: fence queued CLI replies by their prepared session lifecycle

Reload the durable reply target after session admission and reject session ID or lifecycle revision changes before starting the CLI. Internal turns without a store target retain their in-memory path. Seed the existing durable-session fixture and type rejection callbacks explicitly.

Both lifecycle replacement regressions fail before this fix. Reply routing, CLI dispatch, and admission coverage pass: 62 tests. Refs openclaw#134186, openclaw#135192.

* test: split CLI admission coverage from session routing
zeroaltitude added a commit to zeroaltitude/openclaw that referenced this pull request Sep 18, 2026
…ne scenario (review feedback)

The scenario claimed to prove deferred completion admission but did not
establish the precondition that selects it. Holding the requester inside a
foreground `exec` keeps its run ACTIVE, and an active embedded requester run
always accepts an announce steer:
`subagent-announce-direct-delivery.ts:280-322` attempts the wake first, with
`steeringMode: "all"`, and returns `path: "steered"` on success;
`subagent-announce-active-wake.ts:113-124` deletes `sourceReplyDeliveryMode`
and retries when the queue refuses with `source_reply_delivery_mode_mismatch`,
which is exactly the `message_tool_only` gate a direct-message completion sets.
`supportsTranscriptCommitWait` is hardcoded `true` on the embedded handle
(`run/attempt-stream-prepare.ts:668`) and `acceptingSteerMessages` stays true
through tool execution, so no scenario-controllable state makes an embedded
requester refuse. The completion could therefore be consumed by the original
run, leaving step 5 without the later turn it requires.

Deferred admission is the non-embedded requester case: when the wake is
refused, delivery falls through to the gateway `agent` call keyed on the
requester session, which serializes on `session:<requesterSessionKey>` through
`session-placement-admission.ts` — the behavior merged in openclaw#136423 ("Admit
direct CLI turns through the shared session lane before placement claims").

Establish that precondition instead of assuming it, and verify the distinct
run rather than inferring it from tool ordering:

- `execution.runtime: codex` pins the requester to the CLI harness whose
  in-flight turn is not an embedded steer target. The field is supported
  (`scenario-module-flow.ts:37`) and forces a dedicated isolated worker
  (`suite-planning.ts:333`, `suite-launch.runtime.ts:1336`), matching the
  existing runtime-pinned scenarios.
- `runtimePairLane: core` is dropped. The scenario is runtime-pinned, so it is
  not runtime-pair coverage, and it should not be declared release coverage
  before it has run. This reverts the catalog count file to `origin/main`.
- At the boundary where the requester's own reply reaches Telegram, the
  requester session must still show exactly one user message. An accepted steer
  commits its trigger as a user message while the held exec is still running,
  so this fails with a message naming the steered path instead of timing out on
  the missing later turn.
- After that cursor, the requester must record exactly one user message, one
  message-tool send, and no spawn or exec — a distinct completion turn, not a
  continuation of the original run.
- Prompt step 5 no longer conditions the send on "a later turn"; the obligation
  is unconditional and explicitly ordered after the requester's own reply.

No production file is touched and production steering behavior is unchanged.

Validation, in the topic worktree: `scenario-catalog*.test.ts` +
`scenario-lane.test.ts` + `suite-planning*.test.ts` -> 23 files requested / 23
executed, 299 passed, EXIT 0; pack consumers (`coverage-report*`,
`cli-scenario-selection`, `live-scenario-timeouts`, `agentic-parity-report*`,
`evidence-summary*`, `confidence-report*`, `ci-smoke-plan`) -> 11 files
requested / 11 executed, 323 passed, EXIT 0; `pnpm format:check` EXIT 0;
`git diff --check` clean. The branch's TypeScript tree is now byte-identical to
`origin/main`, so the diff is a single YAML file.

Beads: openclaw-cy3n

Co-Authored-By: Claude Opus 5 <[email protected]>
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 gateway Gateway runtime maintainer Maintainer-authored PR 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: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant