Repository navigation
fix: stop showing raw image markdown beside attachments - #125674
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 18, 2026, 3:00 AM ET / 07:00 UTC. ClawSweeper reviewWhat this changesThis PR strips a Markdown image from reply text when it exactly matches trusted tool media before channel delivery. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked by patch quality or review findings - 6 items remain Keep open: the new allowlist correctly identifies duplicate Markdown, but it also drops trusted structured attachments that are not mentioned in Markdown. Priority: P2 Review scores
Verification
How this fits togetherCLI-backed runs collect trusted tool media and assistant text into a shared reply payload. Channel adapters consume that payload as a caption plus attachments. flowchart LR
A[CLI-backed agent] --> B[Trusted tool media]
A --> C[Assistant reply text]
B --> D[Shared payload merge]
C --> D
D --> E{Exact Markdown match}
E -->|yes| F[Clean caption]
E -->|no| G[Preserve Markdown]
F --> H[Channel attachments]
G --> H
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +37, Tests +98. Total +135 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Use the allowlisted parser only to remove the duplicate Markdown text, while preserving the complete ordered structured-media list for delivery. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: pass two trusted tool URLs and Markdown for only one; line 48 retains only the referenced URL for delivery. Is this the best way to solve the issue? No—the shared merge is the right owner, but the parser result must clean text without becoming an attachment-selection policy. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6afaf82e1ecb. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
ClawSweeper rank-up handling for reviewed head The P1 and its six derived moves are consciously skipped because they conflict with the intended selection contract of this fix. An exact assistant-authored Markdown reference is a positive selection from the already-trusted structured media set; unreferenced alternatives are intentionally not delivered. This is not inferred from arbitrary text and does not promote new media: the allowlist is the complete trusted set, and selection occurs only on an exact normalized match. The two relevant tests jointly define the behavior:
Therefore:
No behavior changed after the review, so a re-review is not requested under the <12h policy. The exact-head focused tests, changed-file gate, autoreview, and CI remain green; final native prepare/Testbox proof will be posted before merge. |
|
Land-ready proof for source/prep head
Known live-proof gap: no live external Discord send was performed because the available visual capture contains private workspace data, and the operator's live Gateway was not modified. No screenshot was uploaded. No release or package publication is part of this landing. |
|
Merged via squash.
|
Closes #125655
AI-assisted: Yes. The implementation and evidence were reviewed and understood; no agent transcript or session log is included.
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where users receiving generated media in Discord or sibling text/media channels could see a raw local Markdown image path beside the same attachment after a CLI-backed structured-media handoff.
The regression became visible after #124910 (
b65879e4b648) extended structured media capture to the CLI runtime. The shared payload owner then combined the assistant's Markdown representation with the same trusted structured tool media. Discord correctly rendered the full text as the caption and uploaded the attachment once.Why This Change Was Made
The shared tool-media payload owner now reconciles assistant presentation with already-trusted structured media. It uses an exact allowlist through the existing bounded Markdown image parser: only destinations that normalize to an already-owned tool media URL are consumed and selected, while surrounding text, metadata, provenance, ordering, and existing source-reply behavior are preserved.
This does not weaken local-path security, promote arbitrary Markdown paths, add channel-specific cleanup, or create a second parser. Discord remains a transport consumer rather than the policy owner.
User Impact
Users receive one clean caption plus one attachment when assistant Markdown exactly references trusted structured tool media. Unmatched local Markdown remains plain visible text and is not promoted to an attachment; unrelated remote Markdown remains unchanged in exact-allowlist mode.
Evidence
Reproduction and observed payload
Before:
{ "text": "Our agent.\n\n", "mediaUrl": "/root/.openclaw/media/tool-image-generation/generated.png" }After:
{ "text": "Our agent.", "mediaUrl": "/root/.openclaw/media/tool-image-generation/generated.png" }The actual Discord outbound adapter with a mock transport produced exactly one send after the fix: caption
Our agent.and one media URL at the generated path. This is deterministic adapter proof, not a live external Discord send.A source-blind behavior validation also varied an unmatched
/tmp/unrelated.pngMarkdown target. The exact structured reference was stripped and delivered once; the unmatched local Markdown remained visible and was not promoted.Focused tests
Result after rebasing onto
origin/main: 3 files, 214 tests passed (124 unit-fast + 90 agents-core) in 98.56s.Changed-file gate
Result: passed all selected core/core-test formatting, typecheck, lint, dead-export, import-cycle, max-lines/assertion ratchet, database/media, and runtime guard lanes.
Result: clean.
Review, size, and dependency contract
86b1123ff6b5confirmed generated image results persistsavedPath, and the model-facing output explicitly says the image is already displayed and need not be repeated as Markdown. No upstream Codex change is needed.Live-proof limitation
No live external Discord send was performed because the only provided visual capture contains private workspace data, and the operator's live Gateway was not modified. The actual Discord adapter with mock transport plus source-blind behavior validation covered the changed path; neither is claimed as live-channel proof.