Skip to content

fix: return a busy child's steering receipt at once - #202139

Merged
obviyus merged 7 commits into
mainfrom
openclaw/tidy-claw
Nov 20, 2026
Merged

obviyus merged 7 commits into
mainfrom
openclaw/tidy-claw

Conversation

@obviyus

@obviyus obviyus commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

When a parent agent sends a message to its own child while the child is busy in a long tool call, sessions_send waits about 30 s and then reports an error. The message does reach the child, but the parent thinks the send failed and often retries or gives up.

User Impact

User impact: a parent's message to a busy child now returns at once as accepted / steered, and the child still sees the message at its next steering boundary.

Why This Change Was Made

  • Steering returns at acceptance. Once the receiving run accepts a steered message, it owns that message until it commits it or the run ends. sessions_send no longer waits for the transcript commit. The durable-fallback and commit-wait path for sessions_send steering is removed.
  • Admission-only contract: after acceptance, the receiving run owns the steered input until it commits or the run ends; a refused commit is never seen by the model, and custody is released exactly once when the run ends.
  • The tool deadline result now uses the schema's error status instead of a timeout shape the schema did not allow. Models see this change.
  • The steerTargetRunId stamp is written on the committed transcript row as part of the admission write, and confirmation no longer waits for runtime persistence. This also stamps plugin steering, which previously had no stamp.
  • Commit-wait (waitForTranscriptCommit: true) and its timeout status remain for the other callers (announce, chat.send, steer adoption).

Known window: if the receiving run is cancelled or fails, or the Gateway restarts, between acceptance and the next steering boundary, the steered message is withdrawn although the sender holds accepted. Plugin steering on main already has this window. On main's restart model, a restart stops the child and wakes the parent, so the parent learns the child was interrupted and can resend. Making accepted steers survive a restart needs a replay-authority decision and is not part of this PR.

Split from #202111. The restart half of that PR is parked as reference, because main's own restart model now owns that class.

Evidence

Real Gateway journey on a built Gateway (isolated state, real model), current main vs this branch. The parent spawns a child doing a 75 s exec, sends it a MARKER with sessions_send, then waits:

main (416b357c) this branch
sessions_send call → result 30,066 ms, error 74 ms, accepted / steered
Steered MARKER row in the child, and the MARKER in the child's final reply 1 row, stamped; in the final reply 1 row, stamped; in the final reply

Tests:

  • Steering receipt at acceptance (red on main: the steering-provenance test hangs 120 s, and the admission test returns status: "timeout").
  • The commit stamp is written for uncommitted messages.
  • Steering custody is released exactly once when the receiving run ends, including the source-revoked case (the refused commit never reaches the transcript).
  • The plugin steering contract now expects the stamp.
  • Suites: sessions_send 11/13/132, user-turn transcript 89, steering custody 5, all green. tsgo and lint are clean.

Production code: +29 / −47 (net −18).

Merge danger:

  • Two-way door: no schema, config or stored-state change.
  • Blast radius: agents that steer a busy session with sessions_send, and plugin steering stamps.

obviyus and others added 3 commits November 20, 2026 05:32
sessions_send steering into a busy run now returns accepted/steered as soon as the receiving run accepts the message, instead of waiting up to 30 s for the transcript commit and reporting an error. The receiving run owns accepted input until it commits or ends. The durable fallback and commit-wait path for sessions_send are removed; the tool deadline result uses the schema's error status. The steerTargetRunId stamp is written on the committed row, which also covers plugin steering.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: ba2fc1ea-b29e-8da6-863b-ff6d2b963513
@clawsweeper

clawsweeper Bot commented Nov 20, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Nov 20, 2026
@obviyus
obviyus marked this pull request as ready for review November 20, 2026 00:20
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 20, 2026
@clawsweeper

clawsweeper Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR acknowledges accepted child steering immediately and records steering provenance when the transcript commits.

Example: A parent sends MARKER while its child runs a 75-second command.

  • Before: The reported Gateway journey returned an error after 30,066 ms even though the child later received MARKER.
  • After: The reported branch journey returned accepted/steered after 74 ms, and the child received MARKER once.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused repair with a concrete Gateway journey and regression coverage, held by a narrow diff-caused CI violation.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the contributor proof gate and records an isolated built-Gateway journey with a real model, immediate steering acceptance, and exactly one consumed marker.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A parent receives a send error while its busy child still receives the message, encouraging retries or abandoned coordination.
Reason: The reported Gateway journey demonstrates the problem and improvement, and maintainer authorship supplies direction approval for the explicitly documented admission-only tradeoff.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR addresses a concrete false failure when steering a busy child, but a newly added identity comparison blocks the baseline-ratchet check.

Priority: P2
Reviewed head: 57ce4aab4d839c7c2762acc4ee07d770b5d3893d

Before merge

  • Delegate the duplicate-stamp check to the transcript update owner (P2) - The new steerTargetRunId comparison adds identity-comparison hits outside the session-store owner while this file's allowance remains nine. scripts/check-session-identity-ratchet.mts matches this expression, and the exact-head baseline-ratchet annotations report session-identity failure. Keep the targetRunId presence guard and let confirmPersistedSteerTargetRunId perform its existing unchanged-stamp check; do not expand the baseline.

Findings

  • [P2] Delegate the duplicate-stamp check to the transcript update owner — src/sessions/user-turn-transcript.ts:667
Agent review details

How this fits together

The sessions_send tool authorizes inter-session communication, submits guidance through the session controller, and returns a receipt while the receiving runtime owns consumption and transcript persistence.

flowchart TD
  A[Parent agent] --> B[sessions_send]
  B --> C[Communication admission]
  C --> D[Session controller]
  D --> E[Child input queue]
  D --> A
  E --> F[Transcript recorder]
  F --> G[Child model turn]
Loading

Technical review

Best possible solution:

Keep the admission-only receipt and existing persistence owners, removing the redundant caller-side stamp comparison before merge.

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

Current main waits for steering transcript commitment under a 30-second admission ceiling, matching the reported long-tool-call failure; the PR records a real Gateway comparison, and no target code was executed during this review.

Is this the best way to solve the issue?

Returning the existing runtime admission receipt directly addresses the false failure, and the stamp changes preserve provenance without another delivery owner; the duplicate identity check should remain solely in the existing transcript update operation.

Full review comments:

  • [P2] Delegate the duplicate-stamp check to the transcript update owner — src/sessions/user-turn-transcript.ts:667
    The new steerTargetRunId comparison adds identity-comparison hits outside the session-store owner while this file's allowance remains nine. scripts/check-session-identity-ratchet.mts matches this expression, and the exact-head baseline-ratchet annotations report session-identity failure. Keep the targetRunId presence guard and let confirmPersistedSteerTargetRunId perform its existing unchanged-stamp check; do not expand the baseline.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0b4d5d08b689.

Provenance checked

  • Steering acknowledgment and durable fallback changes intended behavior with a stated reason (2d9033c: Require transcript persistence before acknowledgment and queue unsupported durable steering to avoid losing acknowledged guidance.)
  • Steering transcript provenance keeps the original intent (08622cd: Record the exact consumed steering run on committed transcript rows to preserve causal reply ordering.)
  • Plugin steering idempotency keeps the original intent (815a0bd: Deduplicate guidance across current and successor runs and replay the original run receipt when stored metadata is available.)
  • sessions_send admission deadline keeps the original intent (da8fd16: Bound admission independently of reply waiting and stop an unbounded send from holding the caller's turn.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm check:session-identity-ratchet
  • pnpm test src/sessions/user-turn-transcript.test.ts src/plugins/contracts/active-run-steering.contract.test.ts
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 08622cd adds src/sessions/user-turn-transcript.ts:609 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 08622cd76694; files: src/sessions/user-turn-transcript.ts)
  • Ayaan Zaidi: Raw commit 815a0bd adds src/plugins/contracts/active-run-steering.contract.test.ts:76 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 815a0bd3b7ee; files: src/plugins/contracts/active-run-steering.contract.test.ts)
  • Paul Bohm: Raw commit f83b7ad adds src/agents/tools/sessions-send-tool.delivery.ts:243 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f83b7ade15f3; files: src/agents/tools/sessions-send-tool.delivery.ts)

PR surface

Source -18, Tests -13, Docs -4. Total -35 across 16 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 33 51 -18
Tests 7 109 122 -13
Docs 1 7 11 -4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 149 184 -35

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Busy-child coordination can return a false failure and prompt retries, with a bounded affected workflow.
  • add merge-risk: 🚨 session-state: An acknowledged steer can be withdrawn before commitment on cancellation, failure, or restart; the maintainer-authored PR explicitly accepts this window.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Busy-child coordination can return a false failure and prompt retries, with a bounded affected workflow.
  • merge-risk: 🚨 session-state: An acknowledged steer can be withdrawn before commitment on cancellation, failure, or restart; the maintainer-authored PR explicitly accepts this window.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 19, 2026, 7:35 PM ET / November 20, 2026, 00:35 UTC.

@obviyus

obviyus commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: Ayaan approved landing this PR over one unrelated red check.

  • Failing job: checks-node-changed-compact-large-7, run 44648988097, head 89851f8. The openclaw/ci-gate check fails only because it aggregates this job.
  • Failing test: src/gateway/server.plugin-reload-send-revocation.product.test.ts, scenario "revoked". It times out after 120 s.
  • The same test fails the same way on main 416b357. The main CI run does not include this test. The changed-files lane runs it here because this PR touches files that the test imports.
  • Cause on main: after the device token is revoked, the retained sessions_send replay is still accepted. So the "could not continue" notice never comes, and the test waits until it times out. The PR head fails at the same step, with the same timings.
  • Bisect over 04cb817 (good) .. 1c1e803 (bad): the first bad commit is ad550e9 (refactor(cron): keep occurrence authority fixed after admission #201377). It removed the device-revocation abort in captureGatewayOperatorContinuation (src/gateway/operator-run-recovery.ts). The fix will be tracked separately.
  • Every other required check is green. The local ClawSweeper review on 89851f8 found the patch correct, with 0 findings.

@obviyus
obviyus merged commit c3d6582 into main Nov 20, 2026
118 of 121 checks passed
@obviyus
obviyus deleted the openclaw/tidy-claw branch November 20, 2026 03:14
@obviyus

obviyus commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as c3d6582, from head 89851f8.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
## What Problem This Solves

When a parent agent sends a message to its own child while the child is busy in a long tool call, `sessions_send` waits about 30 s and then reports an error. The message does reach the child, but the parent thinks the send failed and often retries or gives up.

## User Impact

User impact: a parent's message to a busy child now returns at once as `accepted` / `steered`, and the child still sees the message at its next steering boundary.

## Why This Change Was Made

- Steering returns at acceptance. Once the receiving run accepts a steered message, it owns that message until it commits it or the run ends. `sessions_send` no longer waits for the transcript commit. The durable-fallback and commit-wait path for `sessions_send` steering is removed.
- Admission-only contract: after acceptance, the receiving run owns the steered input until it commits or the run ends; a refused commit is never seen by the model, and custody is released exactly once when the run ends.
- The tool deadline result now uses the schema's `error` status instead of a `timeout` shape the schema did not allow. Models see this change.
- The `steerTargetRunId` stamp is written on the committed transcript row as part of the admission write, and confirmation no longer waits for runtime persistence. This also stamps plugin steering, which previously had no stamp.
- Commit-wait (`waitForTranscriptCommit: true`) and its `timeout` status remain for the other callers (announce, `chat.send`, steer adoption).

Known window: if the receiving run is cancelled or fails, or the Gateway restarts, between acceptance and the next steering boundary, the steered message is withdrawn although the sender holds `accepted`. Plugin steering on main already has this window. On main's restart model, a restart stops the child and wakes the parent, so the parent learns the child was interrupted and can resend. Making accepted steers survive a restart needs a replay-authority decision and is not part of this PR.

Split from openclaw#202111. The restart half of that PR is parked as reference, because main's own restart model now owns that class.

## Evidence

Real Gateway journey on a built Gateway (isolated state, real model), current main vs this branch. The parent spawns a child doing a 75 s exec, sends it a MARKER with `sessions_send`, then waits:

| | main (`e9b9f42d`) | this branch |
|---|---|---|
| `sessions_send` call → result | 30,066 ms, `error` | 74 ms, `accepted` / `steered` |
| Steered MARKER row in the child, and the MARKER in the child's final reply | 1 row, stamped; in the final reply | 1 row, stamped; in the final reply |

Tests:
- Steering receipt at acceptance (red on main: the steering-provenance test hangs 120 s, and the admission test returns `status: "timeout"`).
- The commit stamp is written for uncommitted messages.
- Steering custody is released exactly once when the receiving run ends, including the source-revoked case (the refused commit never reaches the transcript).
- The plugin steering contract now expects the stamp.
- Suites: sessions_send 11/13/132, user-turn transcript 89, steering custody 5, all green. tsgo and lint are clean.

Production code: +32 / −48 (net −16). The stamp now joins the admission write without an extra run-id comparison (session-identity ratchet). One drive-by lint fix: `agent-step.ts` drops a default `callGateway` type argument that the changed-lint lane flagged.

**Merge danger:**
- Two-way door: no schema, config or stored-state change.
- Blast radius: agents that steer a busy session with `sessions_send`, and plugin steering stamps.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…201373)

Baseline adaptation: Bound admission and inline reply observation in the shipped sessions_send owner without importing the upstream executor split, self-held replay, or steering changes. Handoff retains accepted replies with the existing continuation or registry owner. Preserve receipts on caller revocation and use the existing error schema for uncertain admission timeout, matching the targeted fixes in #203901 and #202139.

(cherry picked from commit da8fd16)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c6c889760104d608842b9e97e308aad201f1ca30)
daniel-lxs added a commit to daniel-lxs/openclaw that referenced this pull request Nov 29, 2026
Backport the steering contract from upstream c3d6582 (openclaw#202139). A busy recipient owns admitted guidance until transcript commit or run termination. Preserve the fork’s existing requester checks and selection of separate turns.
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 merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant