Repository navigation
fix(gateway): bind channel completion dispatch - #126113
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 10:33 PM ET / August 19, 2026, 02:33 UTC. ClawSweeper reviewWhat this changesThe PR preserves the owning Gateway resolver from routed channel ingress through agent admission and delayed native-harness completion delivery. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessThe prior completion-scope finding is addressed: the current head carries the lifecycle-fenced resolver through channel dispatch, admission, and harness completion. No blocking patch defect found; rebase and rerun the real QA scenario after the independent catalog-startup repair. Likely related people: @steipete (high confidence). Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherChannel plugins convert inbound messages into agent runs, which can later send a completed child result back through the Gateway. This patch keeps that delayed delivery attached to the Gateway instance that admitted the original channel turn. flowchart LR
A[Inbound channel event] --> B[Plugin channel runtime]
B --> C[Gateway-bound reply dispatch]
C --> D[Agent run admission]
D --> E[Native child completion]
E --> F[Lifecycle-fenced resolver]
F --> G[Completion message delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +63, Tests +70. Total +133 across 17 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single lifecycle-fenced resolver chain and validate it on a rebased head with the real completion QA scenario once the independent startup regression is fixed. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main lacks the routed dispatcher and harness resolver propagation, matching the supplied QA scenario failure. I did not execute it because this is a read-only review and the PR reports the current-main catalog startup blocker prevents the latest rerun. Is this the best way to solve the issue? Yes. Carrying the existing lifecycle-fenced resolver from its owning Gateway runtime avoids restoring an ambient global fallback and repairs the producer boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 23da04ba8af4. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Land-ready evidence for head
ClawSweeper's requested scope repair, actual dispatch regression, focused suites, and QA rerun are all applied; no rank-up move was skipped. |
|
Merged via squash.
|
The vi.mock of resolveGatewayModelSupportsImages in server.chat.gateway-server-chat.test.ts was added by #123847 as an isolation workaround while the gateway shard's chat failures were unexplained. The producers are fixed on main (#126183 for the root-work drain race; #126062/#125946/#126113 for detached completion binding), and the exact #126030 shard invocation is green with the mask removed (5/5 on 95ac5b2, 2/2 on this head), so the mask now only hides the real capability-resolution path from the suite.
* test(gateway): drop the chat image-capability mask The vi.mock of resolveGatewayModelSupportsImages in server.chat.gateway-server-chat.test.ts was added by #123847 as an isolation workaround while the gateway shard's chat failures were unexplained. The producers are fixed on main (#126183 for the root-work drain race; #126062/#125946/#126113 for detached completion binding), and the exact #126030 shard invocation is green with the mask removed (5/5 on 95ac5b2, 2/2 on this head), so the mask now only hides the real capability-resolution path from the suite. * test(gateway): assert inline-image dispatch after mask removal ClawSweeper P2 on #126217: the two image sends only asserted RPC success and drain, so a silent false from the real capability resolver would offload the images and the suite would stay green without proving the discovered model's image capability. Capture the dispatch args and assert both runs deliver exactly one inline image. Teeth check: with the discovered model narrowed to text-only input, the assertion fails with images undefined (offloaded).
* fix(gateway): bind channel completion dispatch * fix(plugin-sdk): scope harness completion dispatch * test(agents): cover scoped completion dispatch
* test(gateway): drop the chat image-capability mask The vi.mock of resolveGatewayModelSupportsImages in server.chat.gateway-server-chat.test.ts was added by openclaw#123847 as an isolation workaround while the gateway shard's chat failures were unexplained. The producers are fixed on main (openclaw#126183 for the root-work drain race; openclaw#126062/openclaw#125946/openclaw#126113 for detached completion binding), and the exact openclaw#126030 shard invocation is green with the mask removed (5/5 on 534f1cb, 2/2 on this head), so the mask now only hides the real capability-resolution path from the suite. * test(gateway): assert inline-image dispatch after mask removal ClawSweeper P2 on openclaw#126217: the two image sends only asserted RPC success and drain, so a silent false from the real capability resolver would offload the images and the suite would stay green without proving the discovered model's image capability. Capture the dispatch args and assert both runs deliver exactly one inline image. Teeth check: with the discovered model narrowed to text-only input, the assertion fails with images undefined (offloaded).
What Problem This Solves
QA Smoke profile 3 repeatedly times out
subagent-completion-direct-fallbackbefore its restart step because detached native completion reaches in-processagentdispatch without an owning Gateway instance binding.PR #126062 added the correct resolver custody for subagent rows, but routed channel turns still bypassed the instance-bound runtime that produces that resolver. QA Channel used its global runtime instead of the exact account runtime, and native harness task completion omitted the admitted run's resolver scope.
Closes #126112.
Why This Change Was Made
This change fixes the producer boundary instead of restoring an ambient fallback:
dispatchReplyFromConfiginto the normal channel dispatcher;channelRuntimesupplied by its Gateway account context;A closed, retired, mixed-owner, restored, or absent binding still fails closed. There is no global singleton inference, retry, sleep, timeout extension, or QA-scenario bypass.
The separate generated-media recovery caller remains owned by #126001 and is intentionally excluded.
Production LOC: +104/-41 (net +63). Tests: +71/-1 (net +70). The production growth is the explicit owner-custody chain across channel runtime composition, admission, and native harness completion.
User Impact
Native subagent completions from channel-originated turns are delivered exactly once instead of silently remaining pending until QA or task timeout. Visible, silent, fallback, restart-recovered, and intentionally empty completion behavior remains intact.
Evidence
Repeated pre-fix failures on fresh PR #125954 merge refs:
Local pre-fix real scenario:
pnpm openclaw qa suite --provider-mode mock-openai --scenario subagent-completion-direct-fallbackIn-process gateway dispatch requires a gateway request scope or instance binding (method: agent)three times.Local post-fix real scenario on the initial implementation head:
pnpm dev qa suite --provider-mode mock-openai --scenario subagent-completion-direct-fallbackThe final-head rerun first exposed the independent current-main frozen-catalog startup regression tracked in #126123 before the scenario began. With only #126123's reviewed one-line clone boundary applied temporarily, the exact scenario passed all five visible, silent, fallback, restart, and empty cases on this final code. The temporary line was then removed and the worktree returned clean; no unrelated change is included here.
Sibling QA on the initial implementation head:
model-switch-tool-continuityandlobster-invaders-build: PASS through qa-channel.telegram-queue-invalid-mode: PASS through the Crabline Telegram driver.Focused regression proof:
dispatchReplyFromConfigis absent from the routed turn;agentdispatcher consumes a lifecycle-fenced scoped resolver and retains the explicit resolver path used by existing owners;.artifacts/qa-e2e/suite-mszhkm2d-1f53b78f/(1 passed, 0 failed; all five cases delivered exactly once; restart replay count 0);node scripts/check-changed.mjs: PASS;git diff --check: PASS;pnpm devwrapper: PASS;Direct Codex source check confirmed terminal child completion is emitted only for final
Completed/Erroredstates and forwarded to the direct parent without triggering a new turn (codex-rs/core/src/session/mod.rs,codex-rs/protocol/src/protocol.rs). This patch changes only OpenClaw's delivery binding for that already-final completion.