Repository navigation
fix: delayed session replies stop after the caller finishes - #155151
Conversation
Co-authored-by: VACInc <[email protected]>
|
🦞👀 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. |
OpenClaw-Publication: 0eb57be7-6f58-45a2-8cd8-00eccdeab0cb Co-authored-by: VACInc <[email protected]>
cab71d1 to
7f7c776
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 5:07 PM ET / 21:07 UTC (Revision 4). ClawSweeper reviewWhat this changesPreserves caller authority while delayed cross-session replies finish, adds lifetime and authorization coverage, and moves existing text-extraction tests into a separate file. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main. The earlier clientless-caller blocker is resolved, and this review found no remaining actionable defects. Priority: P2 Review scores
Verification
How this fits togetherThe sessions_send tool starts work in another session and can return before its reply arrives. The Gateway dispatch owner carries the original operator’s permissions into the later reply admission. flowchart TD
A[Caller sends session message] --> B[Target work accepted]
B --> C[Retain original operator authority]
C --> D[Wait for target reply]
D --> E{Authority still valid?}
E -->|Yes| F[Resume requesting session]
E -->|No| G[Reject reply admission]
F --> H[Release authority hold]
G --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +64, Tests +277. Total +341 across 7 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep accepted reply work bound to its original operator’s live permissions through settlement, with ordinary cleanup and delivery ownership preserved. Do we have a high-confidence way to reproduce the issue? Yes, from source: an accepted reply outlives its request, then main's cleanup-only scope attempts admission with expired caller authority. The supplied regression reports this failure; this read-only review did not execute it. Is this the best way to solve the issue? Yes. Retaining the existing authority owner for the actual detached promise repairs the lifetime mismatch without duplicating authorization or changing public configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d3b90d0359c5. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Preserve the existing clientless system actor through deferred reply admission without promoting scoped unknown callers. Cover roles-enabled dispatch and update the explicit sessions tool mock. Co-authored-by: VACInc <[email protected]>
|
Addressed the clientless-system-caller P1 in Also fixed the explicit mock behind the exact-head CI failure: the full sessions test file reproduced 58 failures before repair and now passes all 108 tests. The combined follow-up suite passes 165 tests; core/affected test typechecks, formatting, lint, and fresh scoped autoreview pass. The PR body contains the updated proof and timings. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Move the eight pure text-extraction cases intact into their owner sibling so the sessions_send continuation mock does not grow the grandfathered oversized suite. Preserve every assertion and the existing ratchet policy. Co-authored-by: VACInc <[email protected]>
|
The line-cap CI failure is repaired in @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
…#155151) * fix: preserve delayed session replies after caller completion Co-authored-by: VACInc <[email protected]> * fix: delayed session replies stop after the caller finishes OpenClaw-Publication: 0eb57be7-6f58-45a2-8cd8-00eccdeab0cb Co-authored-by: VACInc <[email protected]> * fix: preserve system-owned session reply continuations Preserve the existing clientless system actor through deferred reply admission without promoting scoped unknown callers. Cover roles-enabled dispatch and update the explicit sessions tool mock. Co-authored-by: VACInc <[email protected]> * test: isolate stored assistant text coverage from session tools Move the eight pure text-extraction cases intact into their owner sibling so the sessions_send continuation mock does not grow the grandfathered oversized suite. Preserve every assertion and the existing ratchet policy. Co-authored-by: VACInc <[email protected]> --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: VACInc <[email protected]>
What Problem This Solves
Fixes: accepted
sessions_sendreplies can fail to wake their requester after the originating invocation or connection ends, loggingGateway caller authority is no longer active.even though the target finished its work.User Impact
Delayed cross-session replies can continue the requesting session without a manual nudge. The original operator identity, permission ceiling, device/profile/role revocation checks, and Gateway-instance boundary remain enforced.
This fixes a process-local reply handoff. It does not make pending
sessions_sendreplies survive Gateway restarts or claim that every idle session is stalled. No configuration or storage migration is required.Why This Change Was Made
The detached reply flow shed its tool-call context but retained a request-lifetime authority callback. Its later reply admission tried to capture authority from that expired request.
Retain the existing operator source through the reply flow using the normal dispatch/authority owner, then release it in
finally. The registered tool passes the actual detached promise to that owner instead of returning immediately from avoidcallback. Ordinary cleanup keeps its existing contract.Evidence
Original RED: the real A2A reply flow and in-process Gateway facade captured the target result, then failed with the expired-authority error and admitted zero requester turns. GREEN admits one turn; device revocation and Gateway replacement still refuse it, and holds release after settlement.
Review follow-up RED: with
gateway.rolesenabled, normal clientless dispatch succeeded but the continuation wrapper rejected the same request asFORBIDDEN. The existing resolver now receives the same system-actor hint as ordinary built-in dispatch. GREEN proves real clientless admission and keeps already-scoped unknown callers rejected.The original exact-head CI failure was a stale explicit
in-process-gatewaymock missing the new async continuation helper. The fullsessions.test.tsreproduced 58 failures / 50 passes before the mock repair and passed all 108 tests after repair, before the extraction below. No broad partial mock or weakened assertion was added.Roles/mocks follow-up before extraction: 165 tests passed across the continuation, authorization, full sessions, and registered-tool admission files. This includes the original hold-lifetime and revocation cases.
Fresh scoped autoreview: no actionable P0–P2 findings. Core and affected test-graph typechecks, formatting, and lint passed; unchanged guard receipts from the initial fix remain applicable.
Single-worker wall (
pnpm test <file> --maxWorkers=1): continuation 12.29 s (13 tests), pre-extraction sessions 9.76 s (108 tests). The unchanged admission file previously measured 18.24 s (5 tests). Compiler/import work dominates; no sleeps or real-time polling were added.CI ratchet follow-up: reproduced
sessions.test.ts: 1934 -> 1935 counted lines (cap 1000)locally. Moved the two self-contained stored-assistant-text suites intact intochat-history-text.test.ts; all 8 tests / 11 assertions are byte-for-byte preserved. The retained sessions suite passes 100 tests and the extracted suite passes 8, preserving the original 108 total. No production code, guard, baseline, or suppression changed.The pinned-base line-cap ratchet now passes. The affected test type graph, formatting, lint, and fresh scoped autoreview also pass. Latest one-worker wall cost is 21.50 s for the retained sessions suite (including compiler preparation) and 1.77 s for the extracted text suite; no additional runtime setup or timers were added.
Exact-head CI: run 35652561961 passed on
49a123ec63fef8c96cb7eb005734402006a3deeb; the requiredopenclaw/ci-gatepassed. ClawSweeper reviewed the same head with no remaining actionable findings or before-merge items.Isolated Gateway runtime proof passed on that same head: the real registered
sessions_spawnandsessions_sendtools, HTTP authorization/request lifetime, detached reply admission, agent execution, and generated history were exercised in a rootless, network-isolated container. The originating HTTP response and Gateway-side socket ended before the delayed child result was released; the requester automatically resumed exactly once, with no manual continuation, pending inputs, caller-authority error, or announce-flow failure.Proof boundary: model responses and the isolated operator identity were synthetic. The earlier host attempt was refused by protected egress; that restriction was not bypassed. The subsequent live-provider proof below used the configured CI-hydrated Testbox route. No matching pre-fix runtime run was performed; the RED unit/boundary proof above remains separate. Public history omits the internal inbound result, so the actual outbound requester model request independently confirmed exactly one child result with matching provenance. The owned Gateway and container exited successfully, and the container was removed.
Live-provider follow-up passed: the same product-source revision was tested on the configured Blacksmith Testbox workflow, using real OpenAI Responses (
gpt-5.4-mini) and an isolated real Gateway. All five provider requests returned HTTP 200 and completed; none of the model responses were synthesized. The operator identity remained an isolated test identity.At 22:01:46.673 UTC, the originating Gateway socket closed. The delayed child request was released 159 ms later. Its result reached the requester automatically, which produced exactly one new assistant turn. Both sessions settled as
donewith zero pending inputs, no manual continuation, and no authority/announce errors. Actual streamed provider responses, adjacent child-result provenance, and public histories were independently audited.Source identity was checked against the complete product-file inventory of
49a123ec63fef8c96cb7eb005734402006a3deeb, separately from Testbox's source-snapshot commit and temporary harness files. The verified existing build was reused after checksum checks. Gateway/provider/proxy cleanup passed. This is process-local continuation proof, not a restart-durability claim or a pre-fix live comparison.No production Gateway restart or mutation was used for proof.
Worked on by
Work sessions
View the OpenClaw team session