Skip to content

fix: session announcements fail after successful replies - #147150

Merged
vincentkoc merged 4 commits into
mainfrom
fix/sessions-send-announce-lifetime
Sep 13, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/sessions-send-announce-lifetime

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Related: #145865

What Problem This Solves

Fixes: sessions_send announcements can fail after a successful peer reply, either because the sending turn has finished or because a text announcement omits its known delivery owner in a multi-agent setup.

User Impact

The target conversation receives the delayed announcement and its session finishes healthy. Existing tool restrictions, caller retirement, Gateway affinity, and restart/suspension checks remain enforced.

Why This Change Was Made

Use the detached continuation already landed by @LiuwqGit in #144801, preserving the caller, prepared-generation, and transcript cleanup wrappers. The duplicate helper implementation and descendant test are removed from this PR; distinct admission-fence coverage remains.

Carry the already-resolved target agent into both announcement delivery paths for text, media, and voice. This removes media-only owner rediscovery and leaves Gateway ownership checks and transcript mirroring intact. No config, protocol, or permission model changes.

The automatic-reset caller remains separate in #146350.

Evidence

Final signed candidate: 0a1e6624dcb90a4f0fe64c5f76a226a17b1a956c, composed with landed helper base 48ed702f644974d220de27666d3e25be20ec5249.

  • Before: the baseline Gateway E2E recorded Async work scope is closed after foreground completion. A later helper-composed real Gateway run reached the announcement turn but failed text delivery because the send request omitted its explicit target owner.
  • Behavior proof on bb9d94912cfd05be62eb376647ef704841c80a17: all 502 tests across six owner/sibling files passed; the hot-reload Gateway E2E passed; the private-QA build passed, 52 built modules were verified, and doctor closures were checked. Testbox infrastructure run. These assertions ran in its native remote command, not hosted PR CI.
  • Real Gateway + embedded Pi + scripted OpenAI Responses provider + QA channel + stdio MCP: the original caller's actual receipt was active, then retired before the delayed announcement. Exactly one announcement reached the separately bound target room; the target finished done, without an error, and all root reservations were released. The router's forced MCP call and an excluded peer remained denied; exactly one allowed MCP call executed.
  • The only subsequent source change is a runtime-erased string | undefined annotation on the alternating reply-loop owner. Final-candidate autoreview is scoped-clean with no P0–P2 findings.
  • All 30 selected changed gates passed across two exact-candidate receipts: 23 staged gates passed before the unchanged 900-second aggregate deadline (exit 124); the seven remaining tail checks then passed separately. Both recorded the matching final whole-tracked source fingerprint; both owned leases were stopped and verified completed. These are Testbox infrastructure links; assertions ran in the native commands. The original aggregate timeout remains a timeout, not an exit-0 result.

Behavior verdict on bb9d94912cfd05be62eb376647ef704841c80a17:

{"ok":true,"runtime":"embedded Pi","provider":"scripted OpenAI Responses","channel":"qa-channel","mcpCalls":1,"routerMcpDenied":true,"excludedPeerDenied":true,"callerAuthorityRetirementObserved":true,"targetAnnouncementCount":1,"targetStatus":"done","lastRunError":null,"remainingRoots":0,"flowDiagnostics":[]}

Proof limits: this exercises actual Gateway and channel delivery with mock provider/channel endpoints. The fixture used an explicit two-agent A2A allow set with sandboxing off; sandboxed routing was not exercised. This is not live QQ, external-provider, Codex-native, or requester-channel announcement proof; announcements follow the selected target session's channel. The related issue remains a separate closeout decision.

Identity, scope, and follow-up

Complete final patch SHA-256: e6bce7b28346eaedfe61cf6609dc576479ab35ad9459562289d2ba846ab2eb29; tree f1903f8ed2ff94e6cd2d74cc4d21d53a037d9a38.

Eight files: production +12/-15 (net -3); tests +153/-84. The shared helper is supplied solely by the landed dependency. Admission tests retain the distinct suspension-fence invariant also raised by @sunlit-deng in #144806.

The original combined command passed behavior proof but stopped at a moving-main assertion-baseline comparison. Correct staged qualification then exposed the reply-loop type inference error; the final annotation fixes that compile-time mismatch without changing execution.

Named follow-up outside this repair: sessions-send-tool.ts performs an eager requester route lookup with peer.kind: "direct" before its later direct-message guard. In an otherwise valid peer-only channel binding configuration this can demand an account-wide owner. The QA setup declares an explicit research account owner while retaining both stronger peer bindings; no Gateway ownership fallback or permission widening was added.

@vincentkoc vincentkoc self-assigned this Sep 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 3:57 PM ET / 19:57 UTC (Revision 3).

ClawSweeper review

What this changes

Gives delayed session announcements an independent cleanup lifetime and carries the selected agent into text, media, and voice delivery, with regression coverage.

Merge readiness

✅ Ready for maintainer review

The repair remains necessary on current main. No actionable introduced defect was found, and the recorded qualification addresses the previous review’s outstanding request.

Priority: P1
Reviewed head: 0a1e6624dcb90a4f0fe64c5f76a226a17b1a956c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused repair with useful production-path evidence, meaningful regressions, and no actionable introduced findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Recorded production Gateway/Pi/QA-channel/MCP execution demonstrates one target announcement after caller retirement, healthy completion, released reservations, and denied forbidden calls. The final commit changes only a type annotation; sandboxed, live QQ, and requester-channel delivery remain outside this proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded production Gateway/Pi/QA-channel/MCP execution demonstrates one target announcement after caller retirement, healthy completion, released reservations, and denied forbidden calls. The final commit changes only a type annotation; sandboxed, live QQ, and requester-channel delivery remain outside this proof.
Evidence reviewed 8 items Current main still needs both repairs: Fetched main retains the independent continuation and supplies an agent only for media announcements. The branch’s resource-lifetime and text-owner repairs are therefore still distinct work.
Existing ownership and cleanup boundaries retained: The caller changes only the continuation selection and preserves Gateway cleanup, prepared-generation exit, transcript cleanup, and the exclusion of exact-incarnation grants from detached work. Both announcement paths pass the already-resolved target agent.
Canonical helper and prior caller work: History identifies the merged helper in #144801 and earlier caller cleanup work in #146799. GitHub commit patches and raw parent records were inspected; local blame could not complete because historical blobs were unavailable.
Findings None None.
Security None None.

How this fits together

OpenClaw’s session-send tool starts work in another conversation and can announce its completed reply. Gateway admission tracks that background work, while the delivery layer sends the announcement to the target conversation’s channel.

flowchart TD
  A[Session send request] --> B[Resolve and authorize target]
  B --> C[Target agent reply]
  C --> D[Detached announcement work]
  D --> E[Resolve target channel]
  E --> F[Gateway send with selected agent]
  F --> G[Channel delivery and transcript]
  D --> H[Release work reservations]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -3, Tests +69. Total +66 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 2 12 15 -3
Tests 6 153 84 +69
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 165 99 +66

Review metrics

None.

Technical review

Best possible solution:

Keep announcement work on the shared detached-lifetime owner and preserve explicit target ownership through Gateway delivery.

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

Yes: current source retains the inherited resource scope and omits the owner on text sends; the recorded baseline and after-fix Gateway scenarios exercise those failures. This review did not execute them.

Is this the best way to solve the issue?

Yes: the patch reuses the landed lifetime owner and carries an already-resolved agent instead of adding another helper, routing fallback, or permission model.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 03c70bad04ef.

Labels

Label justifications:

  • P1: Successful cross-session replies can still lose their delayed channel announcement on current main.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded production Gateway/Pi/QA-channel/MCP execution demonstrates one target announcement after caller retirement, healthy completion, released reservations, and denied forbidden calls. The final commit changes only a type annotation; sandboxed, live QQ, and requester-channel delivery remain outside this proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded production Gateway/Pi/QA-channel/MCP execution demonstrates one target announcement after caller retirement, healthy completion, released reservations, and denied forbidden calls. The final commit changes only a type annotation; sandboxed, live QQ, and requester-channel delivery remain outside this proof.

Evidence

What I checked:

  • Current main still needs both repairs: Fetched main retains the independent continuation and supplies an agent only for media announcements. The branch’s resource-lifetime and text-owner repairs are therefore still distinct work. (src/agents/tools/sessions-send-tool.a2a.ts:68, 03c70bad04ef)
  • Existing ownership and cleanup boundaries retained: The caller changes only the continuation selection and preserves Gateway cleanup, prepared-generation exit, transcript cleanup, and the exclusion of exact-incarnation grants from detached work. Both announcement paths pass the already-resolved target agent. (src/agents/tools/sessions-send-tool.ts:1075, 0a1e6624dcb9)
  • Canonical helper and prior caller work: History identifies the merged helper in fix(gateway): post-ack webhook work fails with "Async work scope is closed" #144801 and earlier caller cleanup work in fix(sessions): preserve cross-agent replies after reload #146799. GitHub commit patches and raw parent records were inspected; local blame could not complete because historical blobs were unavailable. (src/process/gateway-work-admission.ts:512, 48ed702f6449)
  • Recorded production-path proof: The supplied body snapshot records Gateway, embedded Pi, scripted Responses provider, QA channel, and stdio MCP execution on bb9d949: caller retirement preceded exactly one target-room announcement, target status was done, no run error remained, roots reached zero, and excluded-peer and router-MCP attempts remained denied. This is bounded production-path evidence with simulated endpoints, not live QQ or requester-channel proof. (bb9d94912cfd)
  • Final commit preserves exercised runtime behavior: GitHub’s exact commit response confirms the sole change after the behavior-proof revision is the string-or-undefined annotation on the alternating reply owner. The body records 30 selected gates across two final-candidate receipts, resolving the previous reduced-branch qualification request. The linked Actions runs are cancelled infrastructure leases, not passing hosted test results; the body explicitly distinguishes native assertions and the aggregate timeout. (src/agents/tools/sessions-send-tool.a2a.ts:197, 0a1e6624dcb9)
  • Regression coverage protects completion and admission: The hot-reload scenario now requires an announcement turn, healthy target status, and released reservations. Parameterized admission tests retain independent-continuation coverage and add detached-continuation suspension and restart cases. Announcement delivery tests cover explicit ownership and duplicate suppression. (src/gateway/gateway.sessions-send-hot-reload.e2e.test.ts:418, 0a1e6624dcb9)

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 (2 earlier review cycles)
  • reviewed 2026-09-13T15:46:49.979Z sha e462786 :: blocked before merge. :: none
  • reviewed 2026-09-13T15:55:35.372Z sha e462786 :: blocked before merge. :: none

Integrate the landed detached-continuation owner from #144801. Keep the sessions_send caller repair, post-foreground announcement regression, and nonduplicate admission-fence coverage. Preserve the canonical helper and descendant tests.
@vincentkoc vincentkoc changed the title fix: sessions_send announcements fail after the sending turn finishes fix: session announcements fail after successful replies Sep 13, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 0a1e6624dcb90a4f0fe64c5f76a226a17b1a956c. The canonical helper from #144801 is landed; this diff now covers announcement lifetime, explicit target delivery ownership, and their regressions. The body records current proof and the seven pending tail checks. This PR remains a draft while those checks complete.

@clawsweeper

clawsweeper Bot commented Sep 13, 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:

@vincentkoc
vincentkoc marked this pull request as ready for review September 13, 2026 19:51
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc
vincentkoc merged commit bfb0806 into main Sep 13, 2026
258 of 260 checks passed
@vincentkoc
vincentkoc deleted the fix/sessions-send-announce-lifetime branch September 13, 2026 20:25
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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