Repository navigation
fix(chat): progress images break after task cleanup for runs not started by a chat send - #165275
Conversation
Share chat.send's authored commentary media custody with session-bound agent runs, including restart recovery and internal dispatch, so progress attachments survive cleanup of their original workspace files. Carry transcript preparation through Gateway-only command options and attempt execution. Load custody inside dispatch ownership so startup stays lazy and loader failures settle before the run owner is released. Keep pre-hook delivery intent, sessionless behavior, and final-reply media ownership intact. Cover durable artifact reads after source deletion and custody-loader failure cleanup.
|
🦞👀 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: needs maintainer review before merge. Reviewed October 4, 2026, 10:28 PM ET / October 5, 2026, 02:28 UTC. ClawSweeper reviewWhat this changesThe branch shares progress-attachment preservation between chat sends and session-bound agent runs so attachments survive cleanup of their original files. Merge readiness✅ Ready for maintainer review This PR addresses a source-confirmed gap that remains on current main. The shared custody implementation preserves existing media policy and dispatch cleanup; no concrete introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherGateway agent dispatch runs tasks and records their conversation transcripts. Commentary media custody copies authored progress attachments into managed storage and updates transcript display content for Control UI history. flowchart TD
A[Chat send or agent run] --> B[Admitted session execution]
B --> C[Authored progress attachment]
C --> D[Current run and media policy checks]
D --> E[Managed attachment storage]
E --> F[Transcript display update]
F --> G[Control UI history]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +108, Tests +223, Docs 0. Total +331 across 13 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use one run-bound commentary media owner across Gateway entrypoints while preserving authored transcript bytes and existing attachment access policy. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a clear path: a session-bound agent run records commentary MEDIA references without chat-send custody, then source-file deletion leaves history pointing at missing files. No runtime reproduction was executed in this review. Is this the best way to solve the issue? Yes, sharing the existing custody owner is a narrow repair that avoids parallel media policy and keeps completion within dispatch ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0db00eabfef9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…ted by a chat send (openclaw#165275) * fix(gateway): keep progress attachments durable for agent-run turns Share chat.send's authored commentary media custody with session-bound agent runs, including restart recovery and internal dispatch, so progress attachments survive cleanup of their original workspace files. Carry transcript preparation through Gateway-only command options and attempt execution. Load custody inside dispatch ownership so startup stays lazy and loader failures settle before the run owner is released. Keep pre-hook delivery intent, sessionless behavior, and final-reply media ownership intact. Cover durable artifact reads after source deletion and custody-loader failure cleanup. * refactor(gateway): compact agent-run commentary media wiring
…ted by a chat send (#165275) * fix(gateway): keep progress attachments durable for agent-run turns Share chat.send's authored commentary media custody with session-bound agent runs, including restart recovery and internal dispatch, so progress attachments survive cleanup of their original workspace files. Carry transcript preparation through Gateway-only command options and attempt execution. Load custody inside dispatch ownership so startup stays lazy and loader failures settle before the run owner is released. Keep pre-hook delivery intent, sessionless behavior, and final-reply media ownership intact. Cover durable artifact reads after source deletion and custody-loader failure cleanup. * refactor(gateway): compact agent-run commentary media wiring (cherry picked from commit cd29ad5) (cherry picked from commit f624ae99746b5ae36aa78072070f78fb4165b45b)
What Problem This Solves
Fixes: images an agent shows mid-task in Control UI chat turn into "File not found" cards when the run was not started by a chat send (for example a run resumed by Gateway restart recovery) and the referenced files are later cleaned up.
User Impact
User impact: progress attachments stay visible after reload and after the task deletes its scratch files, no matter which Gateway owner started the run. No change for final replies or message-tool attachments, which were already durable.
Why This Change Was Made
Chat sends already record delivery intent for
MEDIA:references in mid-turn (commentary) text and copy those files into managed outgoing media, rewriting the transcript row's display content (#148795). Runs that enter through theagentmethod had none of that, so a commentary row kept raw workspace paths that the UI fetched live from disk. On the Team Gateway a restart-recovery run posted before/after screenshots from its task worktree; once the task removed.openclaw/tmp, every render failed.The custody (prepare hook plus the observer's lifetime) is now one factory in the commentary media module.
chat.sendconsumes it unchanged, and session-boundagentruns load it inside dispatch ownership and wrap the agent command in it. The prepare hook travels through a Gateway-only command option (stripped from public ingress). Sessionless runs skip custody; loader failures settle through the dispatcher's normal terminal path.Evidence
src/gateway/agent-turn/agent-run-commentary-media.test.ts: anagentrun whose commentary block contains a localMEDIA:PNG persistsopenclawDelivery.mediaUrlsand a managed display attachment (/api/chat/media/outgoing/...+artifactId), rejects hook-added references, and still resolves identical bytes after the source PNG is deleted. It fails on the original dispatcher.agent-run-dispatch.owner.test.tscovers custody-loader failure cleanup (24 passed);agent-command-execution-identity.test.tsasserts the option is excluded from public ingress and stripped by the sanitizer.node scripts/check-changed.mjsand the runtime build green; Codex autoreview scoped-clean.docs/web/control-ui/chat.mdnow states that progress attachments are preserved for runs started by any Gateway owner.