Skip to content

fix: delayed session replies stop after the caller finishes - #155151

Merged
VACInc merged 4 commits into
mainfrom
openclaw/fix-vito-session-continuation-20260921
Sep 21, 2026
Merged

VACInc merged 4 commits into
mainfrom
openclaw/fix-vito-session-continuation-20260921

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: accepted sessions_send replies can fail to wake their requester after the originating invocation or connection ends, logging Gateway 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_send replies 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 a void callback. 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.roles enabled, normal clientless dispatch succeeded but the continuation wrapper rejected the same request as FORBIDDEN. 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-gateway mock missing the new async continuation helper. The full sessions.test.ts reproduced 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 into chat-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 required openclaw/ci-gate passed. 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_spawn and sessions_send tools, 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 done with 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

@clawsweeper

clawsweeper Bot commented Sep 21, 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 gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 21, 2026
OpenClaw-Publication: 0eb57be7-6f58-45a2-8cd8-00eccdeab0cb
Co-authored-by: VACInc <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/fix-vito-session-continuation-20260921 branch from cab71d1 to 7f7c776 Compare September 21, 2026 20:01
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 21, 2026 20:02
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 5:07 PM ET / 21:07 UTC (Revision 4).

ClawSweeper review

What this changes

Preserves 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
Reviewed head: 49a123ec63fef8c96cb7eb005734402006a3deeb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful lifetime and rejection coverage, resolved prior feedback, and no remaining correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The bot-authored PR is exempt from ordinary contributor live-proof requirements. Its reported boundary tests exercise delayed reply admission through the real Gateway facade with mocked turn execution; source tracing and rejection coverage leave no specific unresolved authority violation requiring additional final-effect proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The bot-authored PR is exempt from ordinary contributor live-proof requirements. Its reported boundary tests exercise delayed reply admission through the real Gateway facade with mocked turn execution; source tracing and rejection coverage leave no specific unresolved authority violation requiring additional final-effect proof.
Evidence reviewed 8 items Pinned introduction and review continuity: Reviewed the merge-base-to-head delta at the recorded checkout. The new continuation resolver includes the system-actor hint that addresses the earlier finding. The supplied test merge has stale parents and was not used to infer removal of main-branch behavior.
Current main still needs the repair: Pinned main still starts detached reply work through the cleanup-only context and discards its promise inside that callback. Its cleanup owner preserves request-lifetime state rather than retaining an independent operator-source hold.
Latest release retains the old path: The latest supplied release also calls runWithGatewayToolCleanupContext at the detached reply boundary; this PR's continuation wrapper is not present there.
Findings None None.
Security None None.

How this fits together

The 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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +64, Tests +277. Total +341 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 72 8 +64
Tests 4 369 92 +277
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 441 100 +341

Review metrics

Metric Value Why it matters
Production versus test growth Production +64 net lines; tests +277 net lines Production growth implements the retained authority lifetime; test growth covers admission and revocation while relocating eight existing cases.

Technical review

Best 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.

Labels

Label justifications:

  • P2: Repairs delayed cross-session replies after caller completion with a bounded Gateway authority-lifetime 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 bot-authored PR is exempt from ordinary contributor live-proof requirements. Its reported boundary tests exercise delayed reply admission through the real Gateway facade with mocked turn execution; source tracing and rejection coverage leave no specific unresolved authority violation requiring additional final-effect proof.

Evidence

What I checked:

  • Pinned introduction and review continuity: Reviewed the merge-base-to-head delta at the recorded checkout. The new continuation resolver includes the system-actor hint that addresses the earlier finding. The supplied test merge has stale parents and was not used to infer removal of main-branch behavior. (src/gateway/server-plugin-in-process-dispatch.ts:167, 49a123ec63fe)
  • Current main still needs the repair: Pinned main still starts detached reply work through the cleanup-only context and discards its promise inside that callback. Its cleanup owner preserves request-lifetime state rather than retaining an independent operator-source hold. (src/agents/tools/sessions-send-tool.ts:1078, d3b90d0359c5)
  • Latest release retains the old path: The latest supplied release also calls runWithGatewayToolCleanupContext at the detached reply boundary; this PR's continuation wrapper is not present there. (src/agents/tools/sessions-send-tool.ts:1080, ec9c1a13db89)
  • Authority remains owned and revocable: The wrapper captures authority through the existing dispatch resolver and releases it in finally. The existing authority owner intersects inherited scopes and checks device/source revocation, profile identity, role changes, and Gateway identity. The real turn facade rechecks authority after asynchronous authorization and before entering turn execution. (src/gateway/operator-run-authority.ts:39, 49a123ec63fe)
  • Focused boundary coverage: The added cases exercise the real reply flow and Gateway facade with the turn service mocked: disconnect admits one requester turn, device revocation and Gateway replacement admit none, and scoped unknown callers remain rejected. Registered-tool coverage holds the detached promise open. These are boundary tests, not a live provider run. (src/gateway/server-plugin-in-process-dispatch.continuation.test.ts:112, 49a123ec63fe)
  • Captured discussion and validation: The supplied body and follow-up comments report before/after failures for authority lifetime and clientless roles, repaired explicit mocks, preserved 108 session/text tests, and measured test costs. The captured sourceRevision is 836481c4a72a5b16748e431b064563fb13737bf5f8dc6c45e6ddc3f55f028441. This review executed no repository tests; read-only diff checking passed and the checkout remained clean. (49a123ec63fe)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-21T20:11:26.102Z sha 7f7c776 :: blocked before merge. :: [P1] Preserve the system actor for clientless continuation callers
  • reviewed 2026-09-21T20:48:30.225Z sha 49a123e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T20:56:27.957Z sha 49a123e :: needs maintainer review before merge. :: none

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]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Addressed the clientless-system-caller P1 in 4993ecb6062ffd36b3c553a19a826356e5fe67ef. The continuation resolver now receives the same system-actor hint as ordinary built-in dispatch; the existing resolver still refuses to promote an already-scoped unknown caller. Roles-enabled real Gateway admission reproduced the rejection before the fix and now succeeds, while the scoped-unknown, device-revoked, Gateway-replaced, and authority-hold cases remain covered.

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

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

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]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

The line-cap CI failure is repaired in 49a123ec63fef8c96cb7eb005734402006a3deeb. Two self-contained stored-assistant-text suites moved intact into their sibling test file: all 8 tests and 11 assertions are unchanged. The retained 100 tests and extracted 8 tests pass, as do the pinned-base line-cap ratchet, affected typecheck, formatting, lint, and fresh scoped autoreview. No production behavior, guard, baseline, or suppression changed. The PR body now includes this evidence and measured test costs.

@clawsweeper re-review

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@VACInc
VACInc merged commit 3dc1c64 into main Sep 21, 2026
216 checks passed
@VACInc
VACInc deleted the openclaw/fix-vito-session-continuation-20260921 branch September 21, 2026 21:40
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR 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.

2 participants