Skip to content

fix: follow-up messages miss steering while a reply prepares - #162476

Closed
roboclaw-bot wants to merge 2 commits into
mainfrom
openclaw/investigating-message-steering-regression
Closed

roboclaw-bot wants to merge 2 commits into
mainfrom
openclaw/investigating-message-steering-regression

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #161045. Complements #161046's downstream preflight path; this fixes explicit Gateway chat.send admission.

What Problem This Solves

Fixes follow-up messages waiting for separate answers when Send arrives while an existing reply is preparing its backend.

User Impact

The follow-up is acknowledged promptly and can join the same reply once its backend is ready. Queue modes, cancellation, permissions, media checks, and genuine-rejection fallback remain intact. No configuration or schema migration is required.

Only an existing reply owner is eligible. Requests arriving before any reply owner exists retain their current behavior; the fix never discovers an arbitrary future owner or redirects steering to a replacement.

Why This Change Was Made

The Gateway previously recorded explicit steering as rejected even when preparation prevented any injection attempt. The existing reply-operation owner now publishes its first running backend (or retirement), and Gateway admission can retain that exact owner across readiness. Waiting happens after the ACK; injection reuses the existing authority, transcript-custody, and terminal-receipt checks. A changed owner, key, or ready backend cannot inherit the input. Legitimate same-owner compaction lineage remains supported.

Evidence

371 unique tests passed across 24 files, covering actual send-handler admission, three-message ordering, both phase/backend readiness orders, ACK-boundary readiness, cancellation, idempotency, profile/grant changes, compaction, replacement, hidden questions, media, transcript custody, and Codex exact-turn submission/batching/settlement.

Proof Passed
New actual handleChatSend regressions 19
New registry readiness/lifecycle cases 13
Real AgentSession custody/steering suite, including delayed backend attachment 17
Existing Gateway, admission, registry, and queue siblings 267
Codex adapter steering suites 55
  • Original production code fails the handler regression: the send is acknowledged, but the backend receives zero injections. The fix passes it.
  • Independent review found the attached-before-running case. It was reproduced red and fixed, then verified through both registry and actual-handler tests.
  • A later review's asserted post-ACK reply-context reorder was rejected after source inspection: injectable targets await that same reply-context promise before ACK. Pending workspace setup also prevents reply-operation admission. This does not claim universal receive-order FIFO across independently prepared requests.
  • The focused suites, real-runtime custody suite, and affected Gateway siblings were rerun after the final changes; unchanged sibling proof was reused.
  • node scripts/check-changed.mjs passed in full: core production types, all 27 shared test/type graphs, changed-file lint/formatting, all three Knip scans, schema/ownership guards, and runtime import-cycle checks. git diff --check also passed.

Measured changed-test cost

Each row used pnpm test <file> --maxWorkers=1. Wall time includes runner setup/compiler overhead, not just test execution. Hosted CI seconds are not yet available.

File Cases Command wall
chat-send-preparing-steer.test.ts 19 79.21 s
reply-run-registry.preparing-injection.test.ts 13 2.67 s
chat-send-steering-custody.test.ts 17 37.55 s

Verification limits

Three additional agent-runner.runreplyagent.e2e.test.ts no-replay/CLI-fallback cases could not start: runtime preparation's managed-Gateway artifact-separation check refused both the host and the supported network-isolated runner. The isolated runner's Node, pinned pnpm, and Chromium preflight passed; containers were removed, and no safeguard was bypassed. This is setup failure, not passing E2E evidence.

The passing proof includes authenticated loopback Gateway transport and the real AgentSession queue with synthetic model output. Codex proof uses its adapter fixtures, not a live provider. No production Gateway was modified; no full-repository suite or live-provider run is claimed.

Worked on by

Work sessions


View the OpenClaw team session

roboclaw-bot and others added 2 commits October 1, 2026 06:30
Capture the existing reply owner before backend readiness and wait after the
Gateway acknowledgment. Preserve first-backend identity, cancellation, input
custody, and genuine-rejection fallback without steering a successor.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: a7e88a6a-0bc5-40ed-b42a-b99ed2590f17
@clawsweeper

clawsweeper Bot commented Oct 1, 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 size: L labels Oct 1, 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 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 2:39 AM ET / 06:39 UTC.

ClawSweeper review

What this changes

The PR lets explicit Gateway follow-up messages wait for their captured reply’s backend after acknowledgment, with cancellation, permission checks, and normal follow-up fallback preserved.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still misses this Gateway admission case, and the related preflight PR addresses a different entry point. No concrete introduced defect was found.

Priority: P2
Reviewed head: 3b653947819b93c0884be156111384bd29b78bb6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership-preserving repair with meaningful regression coverage and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary external-contributor proof gate does not apply to this bot-authored PR. Inspected coverage connects Gateway admission and delayed readiness to the real AgentSession queue with synthetic model output, including final-commit revocation checks; it does not independently establish a live provider or real loopback transport run. The added readiness promises change runtime state only, with no stored-data contract change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor proof gate does not apply to this bot-authored PR. Inspected coverage connects Gateway admission and delayed readiness to the real AgentSession queue with synthetic model output, including final-commit revocation checks; it does not independently establish a live provider or real loopback transport run. The added readiness promises change runtime state only, with no stored-data contract change.
Evidence reviewed 10 items Pinned introduction and merge result: Reviewed the merge-base-to-head introduction. The test merge’s raw parents are the pinned base followed by the exact PR head; its registry and dispatch changes match the introduced behavior.
Still necessary on current main: Current main only captures an injectable running backend or an existing direct embedded target. It has no preparing-owner reservation or readiness wait.
Latest release comparison: The v2026.9.7 registry likewise lacks preparing capture and backend readiness. GitHub contents supplied the release source after the local historical blob read failed.
Findings None None.
Security None None.

How this fits together

Gateway chat admission accepts messages from OpenClaw clients and directs them to an existing reply or a later turn. The reply registry tracks the current execution owner and exposes its backend readiness.

flowchart TD
  A[Client follow-up] --> B[Gateway admission]
  B --> C[Capture existing reply owner]
  C --> D[Acknowledge message]
  D --> E[Wait for backend or retirement]
  E --> F[Recheck owner and permissions]
  F --> G[Steer existing reply]
  F --> H[Normal follow-up fallback]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +81, Tests +729, Docs +6. Total +816 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 7 89 8 +81
Tests 5 749 20 +729
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 844 28 +816

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +81 lines; tests and test support net +729 lines Production growth implements readiness in the existing owner; the larger test delta covers lifecycle and admission races.

Technical review

Best possible solution:

Keep readiness with the existing reply owner and reuse the established injection, cancellation, and custody boundaries.

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

Yes, from source: send an explicit steer while an existing reply operation has no running backend. Current main captures no target and later dispatch marks steering rejected; the PR reports a failing original-code handler regression.

Is this the best way to solve the issue?

Yes. Publishing readiness from the existing operation and delaying injection until after acknowledgment preserves ownership without adding another queue or policy owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5cf24affb0c1.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs delayed follow-up steering during reply preparation with a bounded Gateway admission change.
  • 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 external-contributor proof gate does not apply to this bot-authored PR. Inspected coverage connects Gateway admission and delayed readiness to the real AgentSession queue with synthetic model output, including final-commit revocation checks; it does not independently establish a live provider or real loopback transport run. The added readiness promises change runtime state only, with no stored-data contract change.

Evidence

What I checked:

  • Pinned introduction and merge result: Reviewed the merge-base-to-head introduction. The test merge’s raw parents are the pinned base followed by the exact PR head; its registry and dispatch changes match the introduced behavior. (67b3aca80f46)
  • Still necessary on current main: Current main only captures an injectable running backend or an existing direct embedded target. It has no preparing-owner reservation or readiness wait. (src/auto-reply/reply/reply-run-registry.registry.ts:179, 5cf24affb0c1)
  • Latest release comparison: The v2026.9.7 registry likewise lacks preparing capture and backend readiness. GitHub contents supplied the release source after the local historical blob read failed. (src/auto-reply/reply/reply-run-registry.registry.ts:145, c074824a27c9)
  • Readiness and exact-owner lifecycle: The operation publishes readiness only with a running attached backend and settles waiting captures on retirement or rekey. Preparing targets retain the captured operation, key, and first ready backend rather than rediscovering a successor. (src/auto-reply/reply/reply-run-registry.registry.ts:214, 3b653947819b)
  • Post-ack injection safeguards: Detached dispatch waits with the source abort signal, then invokes the existing injection starter. That starter checks current source/operator authority and terminal receipts; the existing V2 sink composes source authority with live execution ownership. (src/gateway/server-methods/chat-send-agent-dispatch.ts:292, 3b653947819b)
  • Meaningful regression coverage: Read all added handler and registry tests and the changed custody suite. They cover both readiness orders, acknowledgment-boundary readiness, burst ordering, cancellation, reassignment, owner replacement, rejection, and transcript custody. The custody suite exercises the real AgentSession queue with synthetic model output; its authenticated dispatch fixture uses a synthetic socket/send boundary, so source inspection alone does not verify the body’s separate loopback-transport claim. No tests were executed during this review. (src/gateway/server-methods/chat-send-preparing-steer.test.ts:119, 3b653947819b)

Likely related people:

  • steipete: 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.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Closing as superseded.

Superseded by #165537 and the later session-controller implementation (#175837). Backend-readiness waiting and input custody now belong to the current session owner; this older implementation is no longer the path forward.

This closes the PR without deleting its branch.

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: L 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