Skip to content

fix 'WebChat image attachments not mapped to media store path - #103254

Closed
DravenZhao-Kilig wants to merge 2 commits into
openclaw:mainfrom
DravenZhao-Kilig:fix-image-branch
Closed

DravenZhao-Kilig wants to merge 2 commits into
openclaw:mainfrom
DravenZhao-Kilig:fix-image-branch

Conversation

@DravenZhao-Kilig

@DravenZhao-Kilig DravenZhao-Kilig commented Jul 10, 2026 •

Copy link
Copy Markdown

Related: #103198

What Problem This Solves

When a user sends an image attachment via WebChat, the assistant's image tool receives the reference image_0 which does not resolve to the actual file path in the media store (~/.openclaw/media/inbound/). The message says [User sent media without caption] but the image data is not accessible to the image tool.

Why This Change Was Made

Added a regex check in src/agents/tools/image-tool.ts (line 944) that detects model-generated image index references
(/^(?:image|img)[_-:]?\d+$/i) before the classifyMediaReferenceSource check. When matched, it returns a helpful
message telling the model that the image is already visible in the prompt and can be described directly —no
filesystem access attempted.

Patterns now caught:

  • image_0, image_1, ... (underscore —the reported bug)
  • image-0, image-1, ... (hyphen)
  • image:0, image:1, ... (colon —already caught by existing check, now gets a better message)
  • image0, image1, ... (no separator)
  • img_0, img-0, etc. (shorthand)

User Impact

When a user sends an image attachment via WebChat without a caption, the assistant receives the image in its prompt
context as inline base64 data. If the LLM then attempts to call the image tool to analyze that image, some models
(notably Gemini) reference the image by a generated index label such as image_0. Because image_0 has no URI scheme and no file extension, it passes through all existing validation gates and is resolved as a relative filesystem path
(/image_0), which does not exist. The tool fails with:

▎ Local media file not found

The only workaround is for the user to manually provide a caption with the image or to avoid using the image tool on
WebChat-attached images —neither of which is obvious to the user.

After the fix, the tool detects these model-generated pseudo-references and returns a clear guidance message telling
the model it can already see the image in the prompt, instead of crashing with a misleading filesystem error.

Evidence

The existing guard in image-tool.ts:942 checks refInfo.hasUnsupportedScheme, which catches image:0 (the image: prefix
is treated as an unrecognized URI scheme). However, image_0 uses an underscore instead of a colon —no scheme, no
colon, so hasUnsupportedScheme returns false. The reference falls through to filesystem path resolution unchanged.

Root cause

// image-tool.ts line 942 (before fix) —only catches schemed patterns like "image:0"
if (refInfo.hasUnsupportedScheme) { ... }

// classifies image_0 →hasScheme: false, hasUnsupportedScheme: false
// →treated as relative file path →/image_0 →ENOENT

… tool receives image_0 instead of real file path'
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 10, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 10, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This PR still needs the requested real-behavior proof, and the branch has been idle since that ask.

Close this external PR as stalled and unproven: it has remained on the same head since July 10, 2026, the dated proof request has not been answered, and the unchanged patch still blocks legitimate relative image-file references. The underlying report remains open at #103198, so closing this branch does not dismiss the user problem.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #103198
Summary: This PR is a candidate fix for the still-open canonical WebChat attachment report, but it is not a safe implementation candidate in its current form.

Members:

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

So I’m closing this for now to keep the review queue honest. Please reopen or open a fresh PR with real-behavior proof (a live run, logs, or a reproducible validation transcript) and it will be reviewed again.

Review details

Best possible solution:

Keep the canonical issue open and land a fresh, narrowly tested fix that distinguishes actual prompt-image tokens from valid relative file paths, with redacted WebChat after-fix proof.

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

No high-confidence live reproduction was established in this review: the reported WebChat sequence is concrete and the fallback path is clear from the supplied diff, but neither the contributor nor the review context provides an observed current-main run.

Is this the best way to solve the issue?

No. The proposed broad regex is not the best fix because it conflates prompt-generated labels with valid relative filenames; a corrected solution must preserve the existing file-reference contract and prove the WebChat outcome.

Security review:

Security review cleared: The one-file reference-classification change adds no dependency, secret, permission, workflow, or supply-chain surface.

AGENTS.md: found and applied where relevant.

What I checked:

  • Unfixed compatibility defect: The PR's new broad label matcher rejects names such as image_0 before the existing relative-path resolution path. The previous completed ClawSweeper review already requested that matching relative image files remain supported; the current supplied diff shows no follow-up change. (src/agents/tools/image-tool.ts:945, 95cd2b7c4627)
  • Proof request expired: The PR received the status: 📣 needs proof label on July 10, 2026, and its body still contains only source reasoning rather than redacted after-fix WebChat behavior proof. (95cd2b7c4627)
  • Inactive external branch: The supplied PR context identifies the same head SHA reviewed on July 10, 2026; no later author commit, real-behavior evidence, reviewer discussion, or maintainer engagement is present before this July 31, 2026 review. The July 25 stale notice confirms the prolonged inactivity. (95cd2b7c4627)
  • Canonical remaining report: The PR explicitly relates to the still-open report describing the same WebChat attachment flow, so that issue remains the canonical place to track a corrected implementation.

Likely related people:

  • marchpure: Recent OpenClaw media-path work is the closest identified current-main ownership signal for the attachment-to-image-tool boundary; direct checkout history inspection was unavailable in this read-only sandbox. (role: adjacent media-path contributor; confidence: low; files: src/agents/tools/image-tool.ts)

Codex review notes: model internal, reasoning high; reviewed against e460fcfb607b.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant