Repository navigation
fix(gateway): give prepared chat.send media one abandonment-discard owner - #124100
Merged
Merged
Conversation
…wner #123983 fixed two of six pre-persistence exits that orphan staged inbound media (~/.openclaw/media/inbound has no transcript reference until the user turn persists, and the inbound sweep is off by default). Four sibling exits still leaked: the post-reply-context abort and routing-change checks, the pre-ACK injection settle (onAborted/onActiveLeafChanged), and any setup throw routed to handleChatSendSetupError. Instead of adding four more inline discards, the custody moves to the admission cleanup owner: every abandonment exit already funnels through cleanupAdmittedRun, which now fires an armed discard gated on the user-turn recorder's persisted fact (the restart-safe path persists durably before its exits; steer injections carry the same recorder). The ACK disarms it because dispatch's error lifecycle persists the referencing transcript on every post-ACK path. The two inline discards #123983 added are deleted. Regression test drives the setup-error exit with an offloaded attachment and fails pre-fix; the original #123983 abort test still passes through the new owner.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
August 15, 2026 08:01
Contributor
Author
|
Merged via squash.
|
steipete
added a commit
that referenced
this pull request
Aug 16, 2026
…4353) #124100's disarm-at-ACK custody rests on dispatch persisting the referencing transcript on every post-ACK path. The blocked-turn path breaks that: a before_agent_run block persists only the redacted block reason — no media markers, no media facts — so the offloaded inbound refs stay unreferenced forever (the inbound sweep is off unless attachments.ttlHours is set). Dispatch settle now discards the prepared refs when the recorder ended blocked, applying the same custody rule as the pre-ACK owner. Regression test drives a blocked dispatch with an offloaded attachment and asserts the inbound dir returns to baseline; fails pre-fix.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 16, 2026
…wner (openclaw#124100) openclaw#123983 fixed two of six pre-persistence exits that orphan staged inbound media (~/.openclaw/media/inbound has no transcript reference until the user turn persists, and the inbound sweep is off by default). Four sibling exits still leaked: the post-reply-context abort and routing-change checks, the pre-ACK injection settle (onAborted/onActiveLeafChanged), and any setup throw routed to handleChatSendSetupError. Instead of adding four more inline discards, the custody moves to the admission cleanup owner: every abandonment exit already funnels through cleanupAdmittedRun, which now fires an armed discard gated on the user-turn recorder's persisted fact (the restart-safe path persists durably before its exits; steer injections carry the same recorder). The ACK disarms it because dispatch's error lifecycle persists the referencing transcript on every post-ACK path. The two inline discards openclaw#123983 added are deleted. Regression test drives the setup-error exit with an offloaded attachment and fails pre-fix; the original openclaw#123983 abort test still passes through the new owner.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 16, 2026
…nclaw#124353) openclaw#124100's disarm-at-ACK custody rests on dispatch persisting the referencing transcript on every post-ACK path. The blocked-turn path breaks that: a before_agent_run block persists only the redacted block reason — no media markers, no media facts — so the offloaded inbound refs stay unreferenced forever (the inbound sweep is off unless attachments.ttlHours is set). Dispatch settle now discards the prepared refs when the recorder ended blocked, applying the same custody rule as the pre-ACK owner. Regression test drives a blocked dispatch with an offloaded attachment and asserts the inbound dir returns to baseline; fails pre-fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
#123983 fixed two of six pre-persistence exits in chat.send that orphan staged inbound media. Prepared attachments live in
~/.openclaw/media/inboundwith no transcript reference until the user turn persists, and the inbound sweep is disabled unlessattachments.ttlHoursis set — so on default installs every leaked file is orphaned permanently. Four sibling exits still leaked:chat-send-handler.tssteer window),onAborted/onActiveLeafChangedoutcomes,handleChatSendSetupError(e.g. restart-safe admission failing"chat turn was not durably admitted"— by construction the media is unreferenced at that moment).Why This Change Was Made
Instead of adding four more inline discards (and leaving the next new exit to leak again), custody moves to the lifecycle owner: every abandonment exit already funnels through
cleanupAdmittedRun, which now fires an armed discard gated on the user-turn recorder's persisted fact. The restart-safe path persists durably before its abort/routing exits, and steer injections carry the same recorder, so thehasPersisted()gate is correct on every path. The ACK disarms the owner because dispatch's error lifecycle persists the referencing transcript on all post-ACK paths. The two inline discards #123983 added are deleted — one owner instead of six call sites, and future exits are covered by construction.User Impact
Default-install operators no longer accumulate permanently orphaned media files when a send with attachments is aborted, steered into a changed leaf, hit by a hot config reload, or killed by a setup error.
Evidence
addChatRunthrows pre-ACK) and asserts the inbound dir returns to baseline — fails pre-fix (verified via stash), passes post-fix.node scripts/run-vitest.mjs run src/gateway/server.chat.gateway-server-chat-b.test.ts— 101/101;src/gateway/server-chat.agent-events.test.ts— 145/145.pnpm tsgo,pnpm check:test-types, oxfmt/oxlint clean; autoreview clean (0.93).Production LOC +27/−2 (≈+11 code, remainder custody-invariant comments required by repo comment policy); tests +62.