Skip to content

fix: pass image file path to Claude Code model#28

Merged
gabrielMalonso merged 2 commits intomainfrom
image-attachment-path
Mar 16, 2026
Merged

fix: pass image file path to Claude Code model#28
gabrielMalonso merged 2 commits intomainfrom
image-attachment-path

Conversation

@gabrielMalonso
Copy link
Owner

What Changed

Pass file path to Claude Code model when processing image attachments, enabling the model to read actual image content instead of generating hallucinated descriptions.

Why

When users uploaded images as attachments, the ClaudeCodeAdapter sent only metadata (filename, MIME type, size) to the model, causing hallucinations. PDFs and text files already worked correctly by passing the disk file path. Images now follow the same pattern.

How It Works

  • Images are now included in the attachmentPaths map resolution (previously skipped)
  • Model receives instruction to read the image file from disk path
  • Maintains fallback to metadata description if file becomes unavailable

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Tests pass (typecheck)

…ding

Images uploaded as attachments were previously sent to the model with only metadata
(filename, MIME type, size) causing hallucination of image content. This change aligns
image handling with PDFs and text files by passing the file path so the model can use
the Read tool to access the actual image data saved to disk.

Changes:
- Include images in attachmentPaths map resolution (previously skipped)
- Pass file path to model with 'Read the image file at:' instruction
- Maintain fallback metadata for cases where file is unavailable
@github-actions github-actions bot added size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Mar 16, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

if (filePath) {
attachmentPaths.set(attachment.id, filePath);

P2 Badge Verify image path exists before adding read instruction

This loop now adds image attachments to attachmentPaths whenever resolveAttachmentPath returns a non-null string, but that helper only computes a normalized path and does not check filesystem existence (see apps/server/src/attachmentStore.ts), so deleted/missing images still look "resolvable" here. In that case buildUserMessage emits Read the image file at: ... and never falls back to metadata, which makes Claude try to read a nonexistent file during replay/retry/cleanup scenarios and hurts turn reliability.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gabrielMalonso gabrielMalonso merged commit 7b0257d into main Mar 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant