Skip to content

fix(message): preserve attachments without exposing stripped captions - #150694

Merged
obviyus merged 10 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/message-buffer-sanitized-caption
Sep 19, 2026
Merged

obviyus merged 10 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/message-buffer-sanitized-caption

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #150701

What Problem This Solves

Fixes attachments disappearing when their caption is entirely sanitized, and stripped caption text reappearing in assistant replies or collapsed Control UI message cards.

User Impact

Base64 attachments survive caption sanitization, while assistant replies show the published caption and attachment rather than the original tool arguments. Ordinary captions, mixed public/private captions, and literal quoted markers retain their intended public content. Expanded diagnostic input remains available.

Older message-tool history without a recorded publication no longer produces a reconstructed assistant reply. The original tool input is still inspectable; stored arguments, media validation, permissions, and retention are unchanged.

Why This Change Was Made

Count a nonblank buffer as remaining content before the existing outbound media handler validates and stages it. Use recorded publications for message-tool assistant replies instead of a second argument-based reconstruction path. Collapsed message cards show existing action/target metadata, not unverified caption arguments.

The earlier catalog and watchdog test-race repairs are now on main and have no remaining diff in this PR. Contributor commits are preserved.

Evidence

Inspected before/after screenshots and real-browser observations.

  • Real registered chat.send regressions cover sanitized buffers, invalid and oversized buffers, explicit-source precedence, denied media, exact authorized downloads, canonical history and paging, live history SSE, capped diagnostic details, dry runs, cancellation, and same-key replay.
  • Actual Gateway-served Control UI proof covers internal-only, delivery-metadata-only, mixed, ordinary, and quoted-marker captions. Opening the attachment and following its rendered signed link returned HTTP 200, text/plain, and the exact 33-byte fixture. Expanding the tool card retained the original synthetic caption.
  • Both registered Gateway regressions and 80 focused UI tests passed again after the required main-conflict integration and dependency refresh. Supporting owner/sibling coverage passed 437 tests; runtime-prerequisite routing passed 97 cases, with unrelated cases filtered out.
  • Scoped source/fixture types, changed-file type-aware lint, formatting, and size/whitespace checks passed before the final base update. The affected Gateway/UI behavior and the UI build were rechecked afterward; no performance threshold was changed.

The provider responses are synthetic, but Gateway admission, message execution, persistence, history, browser rendering, and artifact authorization/download are real. Live model generation, external channel delivery, and native-app rendering were not exercised.

@clawsweeper

clawsweeper Bot commented Sep 17, 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 agents Agent runtime and tooling size: S labels Sep 17, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 19, 2026, 12:53 AM ET / 04:53 UTC (Revision 10).

ClawSweeper review

What this changes

Preserves attachments when captions are stripped and makes chat replies use recorded publications instead of reconstructing captions from tool arguments.

Merge readiness

⛔ Blocked before merge - 3 items remain

Current main still contains the reported buffer-loss path. This PR provides a coherent repair with convincing Gateway and browser proof; no actionable correctness finding was identified.

Priority: P2
Reviewed head: 86ab17e6fdced2456df25f5e362b5278170d531e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with strong real-browser proof and meaningful production-boundary coverage.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after screenshots show the real Gateway-served Control UI retaining attachments and public captions while omitting stripped text; accompanying browser observations verify exact downloaded bytes and expanded diagnostics. The latest commit changes only tests, preserving the exercised production code.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Inspected before/after screenshots show the real Gateway-served Control UI retaining attachments and public captions while omitting stripped text; accompanying browser observations verify exact downloaded bytes and expanded diagnostics. The latest commit changes only tests, preserving the exercised production code.
Evidence reviewed 9 items Current main still needs the buffer repair: The fetched main content check recognizes text, media references, presentation, interactive content, and locations, but not buffers. The execution caller suppresses a fully stripped caption when this check returns false.
Repair preserves the existing validation owner: The new buffer presence check allows execution to reach existing base64 validation, size limits, explicit-source precedence, media staging, and publication. It does not grant new authority or replace those checks.
Shipped history compatibility boundary: The v2026.9.5 implementation reconstructs a reply from pending tool-argument text when recorded display content is absent. Removing this fallback changes older-conversation rendering, independently of any current-main drift.
Findings None None.
Security None None.

How this fits together

The message tool sanitizes outgoing captions before validating and staging attachments. Gateway history and the Control UI display the resulting publications while retaining tool inputs in expanded diagnostics.

flowchart LR
  A[Message tool input] --> B[Caption sanitization]
  B --> C[Media validation and staging]
  C --> D[Recorded publication]
  D --> E[Chat history]
  E --> F[Control UI reply]
  A --> G[Expanded tool diagnostics]
Loading

Decision needed

Question Recommendation
Should older successful message-tool calls without recorded publications stop producing reconstructed assistant reply bubbles? Accept publication-only replies: Accept the documented historical visibility change while retaining original tool diagnostics and preventing stripped captions from resurfacing.

Why: The fallback exists in the latest release, and the PR intentionally removes it; tests establish the outcome but cannot establish acceptance of the upgrade tradeoff.

Before merge

  • Resolve merge risk (P1) - Upgrading from v2026.9.5 can remove reconstructed reply bubbles from older conversations with successful message-tool calls but no recorded publication. Original tool diagnostics remain stored, but maintainer acceptance of this loss of historical visibility is not established.
  • Complete next step (P2) - Obtain explicit maintainer acceptance that older successful message-tool calls without recorded publications will no longer produce reconstructed reply bubbles.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source -485, Tests -14, Other +2. Total -497 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 6 29 514 -485
Tests 16 1053 1067 -14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 23 1084 1581 -497

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #150701
Summary: This PR is the explicit candidate fix for the linked buffer-suppression report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the documented history tradeoff (recommended)
    Explicitly approve omitting reconstructed replies from older transcripts while preserving publications and expanded diagnostics.
  2. Separate the history cutover
    Keep the attachment repair focused and pause removal of the shipped reconstruction fallback until its upgrade behavior is agreed.

Technical review

Best possible solution:

Keep recorded publications as the single reply-display source, with explicit maintainer acceptance of the documented older-history visibility change.

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

Yes: current-main source suppresses a fully stripped caption before staging its buffer, matching the linked report’s concrete production-tool reproduction. This review inspected source and supplied proof without executing target code.

Is this the best way to solve the issue?

Yes for attachment preservation and canonical display ownership: the patch reuses existing validation and publication paths. Acceptance of its historical-display tradeoff remains a human compatibility decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 929bafb35f56.

Labels

Label justifications:

  • P2: The demonstrated defect loses attachments for fully sanitized captions, with a bounded message-tool and chat-display scope.
  • merge-risk: 🚨 compatibility: Removing a fallback shipped in v2026.9.5 changes how existing conversations display successful sends without recorded publications.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Inspected before/after screenshots show the real Gateway-served Control UI retaining attachments and public captions while omitting stripped text; accompanying browser observations verify exact downloaded bytes and expanded diagnostics. The latest commit changes only tests, preserving the exercised production code.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected before/after screenshots show the real Gateway-served Control UI retaining attachments and public captions while omitting stripped text; accompanying browser observations verify exact downloaded bytes and expanded diagnostics. The latest commit changes only tests, preserving the exercised production code.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected before/after screenshots show the real Gateway-served Control UI retaining attachments and public captions while omitting stripped text; accompanying browser observations verify exact downloaded bytes and expanded diagnostics. The latest commit changes only tests, preserving the exercised production code.

Evidence

What I checked:

  • Current main still needs the buffer repair: The fetched main content check recognizes text, media references, presentation, interactive content, and locations, but not buffers. The execution caller suppresses a fully stripped caption when this check returns false. (src/agents/tools/message-tool-visible-content.ts:296, 929bafb35f56)
  • Repair preserves the existing validation owner: The new buffer presence check allows execution to reach existing base64 validation, size limits, explicit-source precedence, media staging, and publication. It does not grant new authority or replace those checks. (src/agents/tools/message-tool-visible-content.ts:317, 86ab17e6fdce)
  • Shipped history compatibility boundary: The v2026.9.5 implementation reconstructs a reply from pending tool-argument text when recorded display content is absent. Removing this fallback changes older-conversation rendering, independently of any current-main drift. (src/gateway/chat-display-projection.message-tool.ts:309, ec9c1a13db89)
  • Explicit historical-display behavior: Replacement history tests retain original calls and results while omitting argument-derived assistant replies, including legacy success records. Separate cases retain canonical publications before or after tool results and preserve forwarded messages. (src/gateway/server.chat.gateway-server-chat.test.ts:1658, 86ab17e6fdce)
  • Inspected real browser proof: Inspected all four downloaded images linked from fix(message): preserve attachments without exposing stripped captions #150694 (comment). They directly show internal-only and mixed captions before and after: attachments remain, public text survives, and stripped text disappears from replies and collapsed cards. The accompanying observations report an actual rendered attachment download returning HTTP 200, text/plain, and the exact 33-byte fixture. Captures identify after revision 73bb20a and a runtime recheck at c47bc4c. (73bb20a412c3)
  • Re-review continuity: Since the preceding reviewed revision, only the paging fixture and message-card E2E expectations changed. Production behavior is unchanged, so existing runtime proof remains relevant. The prior compatibility question remains supported by the shipped fallback; live comments and reviews contain no acceptance of that tradeoff. (86ab17e6fdce)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record maintainer acceptance of the documented visibility outcome for older transcripts without recorded publications.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-17T07:20:24.165Z sha 0787d38fd049db150f850663a6bf97661e387a63 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-17T07:37:34.864Z sha b94121c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-17T08:01:17.116Z sha b94121c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-17T08:33:55.398Z sha a2965bd :: needs maintainer review before merge. :: none
  • reviewed 2026-09-17T08:56:00.330Z sha a2965bd :: blocked before merge. :: none
  • reviewed 2026-09-17T09:06:01.842Z sha a2965bd :: blocked before merge. :: none
  • reviewed 2026-09-19T03:48:34.855Z sha 73bb20a :: blocked before merge. :: none
  • reviewed 2026-09-19T04:09:21.444Z sha c47bc4c :: blocked before merge. :: none

@zhangguiping-xydt
zhangguiping-xydt force-pushed the fix/message-buffer-sanitized-caption branch from 0787d38 to b94121c Compare September 17, 2026 07:26
@zhangguiping-xydt
zhangguiping-xydt requested a review from a team as a code owner September 17, 2026 08:26
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Sep 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts size: XL and removed size: S labels Sep 19, 2026
@obviyus

obviyus commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Sanitized-caption display proof

Actual Gateway and Gateway-served Control UI, using synthetic captions and identical proof.txt contents. The before reproduction uses a file attachment; the after reproduction additionally exercises the repaired base64-buffer path. No page content was edited for these captures.

Internal-only caption

Before: private argument copied into the reply and compact preview After: attachment retained, private caption omitted
Before: internal caption appears in the assistant reply and compact message row After: only the canonical attachment and Message row remain

Mixed public and private caption

Before: private text appears beside the published caption After: only the public caption and attachment remain
Before: mixed caption exposes private internal context After: Attached proof and the attachment remain without private context

The candidate also preserved ordinary captions and literal quoted markers, omitted delivery-metadata-only captions, and kept the original caption available in expanded diagnostic input. The actual rendered attachment link returned HTTP 200, text/plain, and the exact 33-byte fixture, including its final newline, after opening the attachment in the UI.

Before source: 146c4147a869. Published after captures: 73bb20a412c3. The final conflict-resolved head c47bc4c2ba50 was rechecked with refreshed dependencies, a rebuilt UI, and a fresh Gateway. Its internal-only after capture is byte-identical to the published image; mixed captions, controls, expanded diagnostics, and exact download bytes also passed again.

…50694

# Conflicts:
#	test/vitest/vitest.gateway-server-paths.mjs
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 19, 2026
@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Sep 19, 2026
@obviyus obviyus changed the title fix(message): preserve buffer attachments when captions are sanitized fix(message): preserve attachments without exposing stripped captions Sep 19, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 19, 2026
@obviyus
obviyus merged commit c7bf1ab into openclaw:main Sep 19, 2026
227 of 228 checks passed
@obviyus

obviyus commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Merged as c7bf1ab23032.

Buffer attachments now survive caption sanitization, and assistant replies/compact message cards no longer reconstruct stripped captions from tool arguments. Expanded diagnostic input remains available.

Verified with registered Gateway regressions, actual browser before/after proof and exact-byte downloads, focused contract checks, a clean exact-head ClawSweeper review, and successful required CI.

Thanks @zhangguiping-xydt for the original fix.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
…openclaw#150694)

Closes openclaw#150701

## What Problem This Solves

Fixes attachments disappearing when their caption is entirely sanitized, and stripped caption text reappearing in assistant replies or collapsed Control UI message cards.

## User Impact

Base64 attachments survive caption sanitization, while assistant replies show the published caption and attachment rather than the original tool arguments. Ordinary captions, mixed public/private captions, and literal quoted markers retain their intended public content. Expanded diagnostic input remains available.

Older message-tool history without a recorded publication no longer produces a reconstructed assistant reply. The original tool input is still inspectable; stored arguments, media validation, permissions, and retention are unchanged.

## Why This Change Was Made

Count a nonblank buffer as remaining content before the existing outbound media handler validates and stages it. Use recorded publications for message-tool assistant replies instead of a second argument-based reconstruction path. Collapsed message cards show existing action/target metadata, not unverified caption arguments.

The earlier catalog and watchdog test-race repairs are now on main and have no remaining diff in this PR. Contributor commits are preserved.

## Evidence

[Inspected before/after screenshots and real-browser observations](openclaw#150694 (comment)).

- Real registered `chat.send` regressions cover sanitized buffers, invalid and oversized buffers, explicit-source precedence, denied media, exact authorized downloads, canonical history and paging, live history SSE, capped diagnostic details, dry runs, cancellation, and same-key replay.
- Actual Gateway-served Control UI proof covers internal-only, delivery-metadata-only, mixed, ordinary, and quoted-marker captions. Opening the attachment and following its rendered signed link returned HTTP 200, `text/plain`, and the exact 33-byte fixture. Expanding the tool card retained the original synthetic caption.
- Both registered Gateway regressions and 80 focused UI tests passed again after the required main-conflict integration and dependency refresh. Supporting owner/sibling coverage passed 437 tests; runtime-prerequisite routing passed 97 cases, with unrelated cases filtered out.
- Scoped source/fixture types, changed-file type-aware lint, formatting, and size/whitespace checks passed before the final base update. The affected Gateway/UI behavior and the UI build were rechecked afterward; no performance threshold was changed.

The provider responses are synthetic, but Gateway admission, message execution, persistence, history, browser rendering, and artifact authorization/download are real. Live model generation, external channel delivery, and native-app rendering were not exercised.

Co-authored-by: Ayaan Zaidi <[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 app: web-ui App: web-ui gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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.

Bug: message tool drops buffer attachments when the caption is sanitized away

2 participants