Repository navigation
fix 'WebChat image attachments not mapped to media store path - #103254
DravenZhao-Kilig wants to merge 2 commits into
Conversation
… tool receives image_0 instead of real file path'
|
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 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 detailsBest 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:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against e460fcfb607b. |
|
This pull request has been automatically marked as stale due to inactivity. |
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:
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