Repository navigation
fix: avoid disconnects and delays during hosted tool calls - #146369
Conversation
|
🦞👀 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: blocked before merge. Reviewed September 12, 2026, 5:36 PM ET / 21:36 UTC (Revision 3). ClawSweeper reviewWhat this changesRoutes hosted tool calls, message operations, session cleanup, and Doctor reads through their owning Gateway without opening redundant WebSocket connections. Merge readiness⛔ Blocked before merge - 3 items remain Keep open: current main still has the redundant transport path, and this PR provides a coherent fix. No introduced blocking correctness defect was found; the earlier generic migration warning is unsupported by the diff. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway coordinates agent tools, approvals, messages, and session operations. This change routes requests originating inside it through the existing router while preserving transport for standalone callers and explicit destinations. flowchart TD
A[Hosted tools and cleanup] --> B{Dispatch destination}
C[Standalone or explicit destination] --> B
B -->|Hosted| D[Bound caller and Gateway authority]
B -->|External| E[WebSocket client]
D --> F[Gateway authorization and router]
E --> F
F --> G[Tool results and owned side effects]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +434, Tests +1277, Docs +6, Other -1. Total +1716 across 79 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: 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 one hosted dispatch owner with existing authority and delivery contracts, and establish that Doctor remains usable through the published updater with existing operator state. Do we have a high-confidence way to reproduce the issue? Yes for the redundant connection mechanism: current-main hosted calls still reach the transport client. The historical 1006 failure rate was not reproduced during this read-only review. Is this the best way to solve the issue? Yes: extending the existing bound router removes the redundant hop while retaining authorization, destination selection, and delivery ownership; no separate connection pool is needed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9b59fe4ef7da. LabelsLabel justifications:
EvidenceWhat 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
History |
d8cdf44 to
6506256
Compare
|
Merged via squash.
|
…146369) * fix(gateway): avoid self-connections for hosted operations * fix(doctor): dispatch hosted diagnostic reads directly * test(doctor): preserve the asynchronous findings contract * refactor(gateway): finish the internal transport cutover * fix: preserve inherited Gateway binding during subagent cleanup * test(gateway): avoid ephemeral ports during capability startup
Put back upstream b1c68b9 content that the continuation line had silently reverted in shared files. Every row has a keep/restore disposition recorded in the round journal. Feature hunks are preserved. Production: - announce deps: use callSubagentLifecycleGateway for the wake and cleanup deps (openclaw#146369 inherited Gateway binding). - reply-delivery: clear blockSourceText on superseded deferred replies (openclaw#143722). - stream-rendering: record a block reply as delivered only when it has text (openclaw#135751). - gateway runtime handles: carry hotReloadStatus through the managed reload. - sweep-kill and sweeper: honor retired cancellations (reconcileRetiredSubagentCancellation), and pass the run's Gateway context resolver into sweep session deletes. - registry read: per-child snapshot reads (openclaw#154727), so the Gateway event loop is not blocked. - session delivery queue: read the post-enqueue status inside the SQLite worker instead of on the main thread, restoring the openclaw#147887 invariant. Tests restored to upstream's coverage: - task-registry kernel test: back to upstream's kernel functions. - double-announce: real outbound adapter retry outcomes (openclaw#131419). - side-question: listener-failure hooks case (openclaw#144828). - session-delivery storage: main-thread-SQL idle assertion (openclaw#157458). - media-only: the re-resolved auth selection assertion. - resume persistence: activation uses the real recovery-runtime shape. The resume "steered requester turn" test was adapted for upstream's async task lookup (openclaw#157634). Its stub now settles like the real waker, and the test waits for settle before an exact count, with a no-pending-wake assertion added. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fq5EX9ESA3CG9cuZxVoKAK
…ed test lines [UNAPPROVED] UNAPPROVED PREP CHECKPOINT. Successor to the immutable reviewed C7 a847f88 (upstream parent 401a1de unchanged; no re-pin). Not a cut, not Mode-B accepted, no presentation motion. Gate 3 is not claimed. Input: Frond's exact-C7 static table (openclaw#1271; MinIO frond/shared-media/prince-handoff/2026-11-10/frond-scribe/1271-static-forkonly/ 1271-j14-c7-static-20261110T201419Z.tar.zst, sha256 bdd45ab8...abb0e, verified): 25 fork-only Knip lines (31 symbols) and 44 deadcode:exports entries (41 symbols). Each symbol is dispositioned from its real consumers at C7 (lane receipt table): - DEAD, deleted (10): orphaned rollback rebase helpers (persistence wiring went with merge bdb5ecb's re-home onto upstream's async write queue), migratedEntry* (upstream deleted the feature in openclaw#162100; merge 6c9a459 orphaned the fork copies), an unused disarm reader, an unaccepted-delegate remover, the announce runtime's callGateway re-export (upstream removed it in openclaw#146369), and two unused test-support helpers. - IN-FILE ONLY, export dropped (17). - REDUNDANT RE-EXPORTS removed (5); one test now imports from the owner module. - TEST SEAMS tagged @internal (8): Knip 6.40.0 ignores @internal only in --production, so the full-tree scan still audits each against its test consumers. - DYNAMICALLY CONSUMED (1): custody-boot calls refuseStaleContinuationWorkAtReplay on a namespace bound by Promise.all array destructuring; config/knip-dynamic-consumers.mjs now models that consumer from the live source (AST, binding identity), with a test. No file-level ignoreIssues entry, threshold or baseline is changed. Test lines: C7 was 401 over. Exact attribution: 19 j13 residual (#1563 +20, #1562 -1), 30 upstream slack shift (U13 31 -> U14 1), 352 agent schema 41/42 coverage in 13 files. C8 nets -4. Allocations: continuation-j14-baseline-shift.txt 30 and continuation-j14-coverage.txt 367 (itemized). Ratchet: 6742738 = ceiling, against base 401a and against C7. Recipient-authority behaviour is unchanged (migrateSessionRecipientAuthority gains a JSDoc tag only; refuseStaleContinuationWorkAtReplay is unchanged and now modeled). src/skills/** untouched. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes #100941. Related: #146226.
What Problem This Solves
Fixes an issue where agents running inside the Gateway could stall or receive connection errors while making parallel automation, node, approval, question, message, and session calls. Many of these operations opened a fresh WebSocket back to the same process for each request. Cleanup and memory/session lookups contained the same avoidable round trips.
Why This Change Was Made
Hosted tools use the existing in-process Gateway router with the same validated runtime identity, method scopes, approval correlation, cancellation, deadlines, and current-run/current-Gateway checks. Runtime identity preparation is shared with the transport path without signing and decoding a token for an internal call. Explicit remote destinations and standalone/localEmbedded clients retain transport.
Detached cron and subagent cleanup uses the existing instance-owned recovery principal, with a narrow method allowlist and commit guards. Cleanup can finish after the originating turn ends, but cannot borrow a replacement Gateway. Message delivery still passes through the Gateway's delivery, receipt, and idempotency owners; a timed-out send reattaches once with its original key. Memory visibility, command SecretRef resolution, and hosted Doctor data reads use bound routing as well. Doctor retains actual connection-health probes.
User Impact
Hosted operations avoid repeated connection setup and authentication, especially during parallel tool calls and multi-step node commands. The Gateway-to-node connection remains necessary; the redundant agent-to-own-Gateway hop is removed. Existing caller authority, delivery outcomes, session protections, and remote targeting remain enforced.
Evidence