Repository navigation
fix(agents): sessions_send to a busy child waits behind its run and can fail - #160842
Conversation
A parent's nonblocking send waited 216 seconds behind its own running child. Followup access facts prepared before the wait became stale during ordinary session-row updates, so admission failed and the guidance was lost. Decide active-run delivery before preparing followup completion custody. Default zero-wait sends to the requester's own spawned child steer into that exact active incarnation, with the existing transcript and queue options. Successful steering starts no run and creates no followup request. A gone, stale, or non-streaming run falls through to a new turn on the same child key. Explicit modes, positive waits, ordinary active targets, and stranded Cron-parent fallback keep their existing behavior. Document the default, steered disposition, and existing completion owner. Production line count is neutral. Add eight table-driven boundary cases; the five regression cases fail before the fix. The ordinary-target and Cron fallback tests, peer live assertion, and custody owners are unchanged. Validation (wall times include repository wrappers): - node scripts/run-vitest.mjs src/agents/openclaw-tools.sessions.test.ts --maxWorkers=1 48 passed, 162.06s; the eight new cases total 140ms. - node scripts/run-vitest.mjs src/agents/tools/sessions-send-tool.a2a.test.ts src/agents/tools/sessions-send-tool.admission.test.ts src/agents/tools/sessions-send-followup.test.ts src/agents/tools/sessions-send-owner-continuation.test.ts src/agents/tools/sessions.test.ts --maxWorkers=1 5 files, 142 tests passed, 197.55s. - pnpm changed:lanes --json core, coreTests, docs; 3.51s. - node_modules/.bin/oxfmt --check --threads=1 src/agents/tools/sessions-send-tool.ts src/agents/tools/sessions-send-tool.delivery.ts src/agents/openclaw-tools.sessions.test.ts docs/concepts/session-tool.md Passed, 0.78s. - node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/openclaw-tools.sessions.test.ts src/agents/tools/sessions-send-tool.delivery.ts src/agents/tools/sessions-send-tool.ts Passed, 26.72s. - node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo Passed, 21.18s. - node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json '["src/agents/openclaw-tools.sessions.test.ts"]' Selected agents-root graph passed, 81.98s wall (9.2s compiler). - git diff --check Passed, 5.39s. No full check-changed, live stress run, or CI dispatch. Queued followups to an idle child can still hold custody facts across a later lane wait; that separate issue is outside this change. Review: one isolated Codex autoreview round, local diff against the merge base, P0-P2 scope; scoped-clean with no accepted/actionable findings (220.11s wall).
Default steering introduced for the 216-second child lane-wait failure is an optimization over the previous new-turn path. Routine compaction and other steering rejections must not turn a previously accepted send into an error. For a default zero-wait send to the requester's own spawned child, let every non-queued outcome fall through to normal Gateway admission for the same child key. Prepare followup custody only after the steering attempt. Keep explicit steer errors and Cron's narrow fallback reasons unchanged. The existing unsupported-transcript-wait retry still runs first, and an accepted or unconfirmed queued outcome never also starts a new turn. Update the runtime-rejection case and add compaction fallback and explicit steer rejection cases. Assert one same-key Gateway call and steering before followup preparation. Extend the existing documentation clause. Production line count remains neutral; no schema, config, or custody-owner changes. Validation: - Before the fix, the compaction regression failed with status=error instead of accepted (49.84s wall; one selected test, 49 skipped). - node scripts/run-vitest.mjs src/agents/openclaw-tools.sessions.test.ts --maxWorkers=1 50 tests passed, 101.55s wall. The three affected cases totaled 29ms. - node_modules/.bin/oxfmt --check --threads=1 src/agents/tools/sessions-send-tool.delivery.ts src/agents/openclaw-tools.sessions.test.ts docs/concepts/session-tool.md Passed, 0.45s wall. - node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/openclaw-tools.sessions.test.ts src/agents/tools/sessions-send-tool.delivery.ts Passed, 23.80s wall. - node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo Passed, 4.07s wall. - node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json '["src/agents/openclaw-tools.sessions.test.ts"]' agents-root passed, 63.25s wall (2.3s compiler). An initial selector also included the production path and expanded to all graphs; stopped that invocation after 136.58s and corrected the scope, without source changes. - pnpm changed:lanes --json core, coreTests, docs; 3.02s wall. - git diff --check Passed, 0.78s wall. Review: two isolated Codex autoreview rounds at P0-P2. Round one flagged only the old INDEX snapshot's narrow fallback (96.99s); staging this fix resolved it without source changes. Round two was scoped-clean with no accepted/actionable findings (82.28s).
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 10:38 PM ET / September 29, 2026, 02:38 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch steers a parent’s zero-wait Merge readiness✅ Ready for maintainer review Current main still has the reported busy-child wait. Earlier review findings are addressed, and the repository admin who authored the PR explicitly accepted the documented change in default completion behavior. No discrete patch defect remains in this review. Priority: P1 Review scores
Verification
How this fits togetherThe flowchart LR
A[Parent agent message] --> B[Session access check]
B --> C{Own running child with zero wait?}
C -->|Yes| D[Active run steering]
C -->|No| E[Gateway new turn]
D -->|Rejected| E
D -->|Accepted| F[Admission result]
E --> F
E --> G[Follow-up completion]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +120, Docs +5. Total +125 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep active-child guidance with the child’s current run and retain Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main sends an ordinary zero-wait message to a busy child through the new-turn path, matching the reported Gateway wait. I did not run a live current-main replay. Is this the best way to solve the issue? Yes. Reusing active-run steering before follow-up custody addresses the reported wait within the existing owner, while explicit follow-up preserves separate-turn completion. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8bf062101532. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
Maintainer decisions on the review items. P1 (accepted-steer deadline) — accepted and fixed. The default own-child path inherited the 30 s transcript-commit wait, so a child busy inside a long tool call past the deadline would have had its accepted guidance cancelled and a replacement turn started behind the same run. The new head acknowledges on queue admission, exactly like explicit Decision needed (changed default) — adopting default steering. A parent's zero-wait send to its own running child steers into that run and no longer produces a separate completion turn. Callers that need a separate child turn with its own completion use Landing on that basis. |
|
Merged via squash auto-merge.
|
…an fail (openclaw#160842) * fix(agents): steer sessions_send into a running child by default A parent's nonblocking send waited 216 seconds behind its own running child. Followup access facts prepared before the wait became stale during ordinary session-row updates, so admission failed and the guidance was lost. Decide active-run delivery before preparing followup completion custody. Default zero-wait sends to the requester's own spawned child steer into that exact active incarnation, with the existing transcript and queue options. Successful steering starts no run and creates no followup request. A gone, stale, or non-streaming run falls through to a new turn on the same child key. Explicit modes, positive waits, ordinary active targets, and stranded Cron-parent fallback keep their existing behavior. Document the default, steered disposition, and existing completion owner. Production line count is neutral. Add eight table-driven boundary cases; the five regression cases fail before the fix. The ordinary-target and Cron fallback tests, peer live assertion, and custody owners are unchanged. Validation (wall times include repository wrappers): - node scripts/run-vitest.mjs src/agents/openclaw-tools.sessions.test.ts --maxWorkers=1 48 passed, 162.06s; the eight new cases total 140ms. - node scripts/run-vitest.mjs src/agents/tools/sessions-send-tool.a2a.test.ts src/agents/tools/sessions-send-tool.admission.test.ts src/agents/tools/sessions-send-followup.test.ts src/agents/tools/sessions-send-owner-continuation.test.ts src/agents/tools/sessions.test.ts --maxWorkers=1 5 files, 142 tests passed, 197.55s. - pnpm changed:lanes --json core, coreTests, docs; 3.51s. - node_modules/.bin/oxfmt --check --threads=1 src/agents/tools/sessions-send-tool.ts src/agents/tools/sessions-send-tool.delivery.ts src/agents/openclaw-tools.sessions.test.ts docs/concepts/session-tool.md Passed, 0.78s. - node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/openclaw-tools.sessions.test.ts src/agents/tools/sessions-send-tool.delivery.ts src/agents/tools/sessions-send-tool.ts Passed, 26.72s. - node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo Passed, 21.18s. - node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json '["src/agents/openclaw-tools.sessions.test.ts"]' Selected agents-root graph passed, 81.98s wall (9.2s compiler). - git diff --check Passed, 5.39s. No full check-changed, live stress run, or CI dispatch. Queued followups to an idle child can still hold custody facts across a later lane wait; that separate issue is outside this change. Review: one isolated Codex autoreview round, local diff against the merge base, P0-P2 scope; scoped-clean with no accepted/actionable findings (220.11s wall). * fix(agents): fall back to a new turn when an own-child steer is rejected Default steering introduced for the 216-second child lane-wait failure is an optimization over the previous new-turn path. Routine compaction and other steering rejections must not turn a previously accepted send into an error. For a default zero-wait send to the requester's own spawned child, let every non-queued outcome fall through to normal Gateway admission for the same child key. Prepare followup custody only after the steering attempt. Keep explicit steer errors and Cron's narrow fallback reasons unchanged. The existing unsupported-transcript-wait retry still runs first, and an accepted or unconfirmed queued outcome never also starts a new turn. Update the runtime-rejection case and add compaction fallback and explicit steer rejection cases. Assert one same-key Gateway call and steering before followup preparation. Extend the existing documentation clause. Production line count remains neutral; no schema, config, or custody-owner changes. Validation: - Before the fix, the compaction regression failed with status=error instead of accepted (49.84s wall; one selected test, 49 skipped). - node scripts/run-vitest.mjs src/agents/openclaw-tools.sessions.test.ts --maxWorkers=1 50 tests passed, 101.55s wall. The three affected cases totaled 29ms. - node_modules/.bin/oxfmt --check --threads=1 src/agents/tools/sessions-send-tool.delivery.ts src/agents/openclaw-tools.sessions.test.ts docs/concepts/session-tool.md Passed, 0.45s wall. - node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/openclaw-tools.sessions.test.ts src/agents/tools/sessions-send-tool.delivery.ts Passed, 23.80s wall. - node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo Passed, 4.07s wall. - node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json '["src/agents/openclaw-tools.sessions.test.ts"]' agents-root passed, 63.25s wall (2.3s compiler). An initial selector also included the production path and expanded to all graphs; stopped that invocation after 136.58s and corrected the scope, without source changes. - pnpm changed:lanes --json core, coreTests, docs; 3.02s wall. - git diff --check Passed, 0.78s wall. Review: two isolated Codex autoreview rounds at P0-P2. Round one flagged only the old INDEX snapshot's narrow fallback (96.99s); staging this fix resolved it without source changes. Round two was scoped-clean with no accepted/actionable findings (82.28s). * fix(agents): acknowledge own-child steering on admission * fix(agents): describe own-child steering in the sessions_send tool text * test(agents): refresh prompt snapshots for the sessions_send description
What Problem This Solves
Fixes: when a parent agent uses
sessions_sendto guide a child it spawned while that child is still working, the message starts a new turn that waits behind the child's active run. The note arrives only after the child finishes (216 s in the observed case), and the deferred turn can then fail admission because its follow-up access facts went stale during the wait, which marks the child failed and walks the whole model fallback chain.User Impact
User impact: guidance a parent sends to its own running child (default mode,
timeoutSeconds: 0) now steers into the child's active run and is seen on its next turn, reported astargetDisposition: "steered". An idle child, or one whose run does not accept the steer (for example during compaction), still gets a new turn as before. Explicitmodevalues, waited sends, ordinary non-child targets, and cron run-scoped delivery are unchanged.A zero-wait send to your own running child no longer produces a separate completion turn; use
mode: "followup"for that. Like explicitmode: "steer", acceptance confirms queue admission, not transcript persistence or model consumption, and is not restart-durable.Why This Change Was Made
sessions_sendalready knew how to steer (mode: "steer"), but the default path resolved an active run only for run-scoped cron keys; #91420 narrowed it to stop rerouting through other sessions, and steering into the exact own-child target does not reroute. The steer decision now happens before follow-up completion custody is prepared, so a steered send creates no follow-up request and no queued turn, and any steer rejection falls through to the same-key new turn with the existing follow-up contract. Production line count is neutral; no schema, config, or custody-owner changes.Evidence
5bd03c942da2287aa032aa437083196c8f519999(134 successful jobs, 19 skipped); ClawSweeper round 5 completed on that exact head with no actionable findings. Native landing verified merge commit9b5b439dcb6e11b929c982d9b40e8ddcb4c9b2e5.5bd03c942da2287aa032aa437083196c8f519999):pnpm prompt:snapshots:genchanged only four prompt fixtures for the approved description sentence and its derived counts/hashes;pnpm prompt:snapshots:checkpassed (7 current files, 22.41 s wall),git diff --checkpassed, sessions rerun passed 51 tests (29.45 s wall), and fresh isolated Codex autoreview at P2 was scoped-clean. This repairs the prompt-snapshot drift reported by CI run 36511154592.d95015ef60ed3e87484894c6773687d8ead9f840): the model-facing sessions_send text now states the approved own-child admission-only default and mode:followup for a separate completion turn; description/guidance tests 24 passed (86.48 s wall), sessions rerun 51 passed (18.61 s wall), targeted formatting/lint, core tsgo, diff check passed, and fresh isolated Codex autoreview at P2 scoped-clean.lane wait exceeded … waitedMs=216633 taskKind=spawn, thenSession access facts are unavailable; retry after session storage is ready.twelve times across three models, and the child marked failed.node scripts/run-vitest.mjs src/agents/openclaw-tools.sessions.test.ts --maxWorkers=1: 51 passed (144.43 s command wall time). Eleven table-driven cases cover steering, run-gone/runtime/compaction rejection, explicit modes, waited sends, idle children, and a child busy beyond the delivery deadline. The new no-timer mock regression failed before this repair withqueued/pendinginstead ofsteered/skipped; after the repair, admission returns without a transcript commit, a Gatewayagentcall, or follow-up custody preparation. This is tool-boundary mock proof, not a live 30-second run. The existing file exercises the actual session tool and storage boundary, including custody ordering; its full-file startup/import cost is retained rather than duplicating that contract in a helper test.sessions-send-tool.a2a,sessions-send-tool.admission,sessions-send-followup,sessions-send-owner-continuation, andsessions): 142 passed (54.83 s command wall time).oxfmt --check, oxlint, core tsgo and the narrowedagents-roottest shard (16.4 s),git diff --check: passed.