Conversation
…dImage alias
Add a unified readMedia tool that handles both images (png, jpg, jpeg, webp, bmp, svg)
and documents (pdf) via the Vercel AI SDK file content part. PDFs are supported natively
by Claude (32MB), Gemini (50MB), and OpenAI (50MB).
- readImage kept as backward-compatible alias pointing to the same execute function
- Documents stored as { type: 'document', mimeType, data, filename } objects
- Images stored as data URL strings (unchanged)
- getCurrentMedia() returns Vercel AI SDK content parts for both types
- getCurrentImages() filters to images only (backward compat)
- loadMediaIfValid() replaces loadImageIfValid() (alias preserved)
- New mediaConfig.js centralizes format/MIME config for images + documents
- Updated tools-reference.md docs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Overview: Add readMedia Tool with PDF SupportSummaryThis PR introduces a unified Files Changed Analysis8 files changed with +375/-111 lines: New Files
Modified Files
Architecture & Impact AssessmentWhat This PR Accomplishes
Key Technical Changes1. Media Storage Format // Images stored as data URLs (backward compatible)
pendingImages.set('path/to/image.png', 'data:image/png;base64,iVBORw0KG...')
// PDFs stored as objects with metadata
pendingImages.set('path/to/doc.pdf', {
type: 'document',
mimeType: 'application/pdf',
data: 'base64encodedcontent',
filename: 'doc.pdf'
})2. Content Part Generation // getCurrentMedia() returns Vercel AI SDK compatible parts
[
{ type: 'image', image: 'data:image/png;base64,...' },
{ type: 'file', mediaType: 'application/pdf', data: 'base64...', filename: 'doc.pdf' }
]3. Size Limits
Affected System Componentsgraph TD
A[AI Agent] -->|calls| B[readMedia tool]
A -->|calls| C[readImage tool alias]
B --> D[readMediaExecute]
C --> D
D --> E[loadMediaIfValid]
E --> F{Extension Check}
F -->|image| G[Store as data URL]
F -->|pdf| H[Store as document object]
G --> I[pendingImages Map]
H --> I
I --> J[getCurrentMedia]
J --> K[prepareMessagesWithImages]
K --> L[Vercel AI SDK]
L --> M[AI Provider]
N[getCurrentImages] -.->|backward compat| I
N -->|filters| O[Only data URLs]
Component Impact:
Scope Discovery & Context ExpansionDirect Impact
Related Files (Not Modified)Based on codebase analysis, these files interact with the media loading system: Configuration & Validation:
Message Flow:
Test Files:
MCP Integration:
Potential Follow-up Areas
Backward Compatibility Guarantees✅ Fully backward compatible - all existing code continues to work:
Test Coverage
ReferencesModified Files:
Related Files (Context):
Metadata
Powered by Visor from Probelabs Last updated: 2026-03-20T19:17:11.693Z | Triggered by: pr_opened | Commit: 40d489d 💡 TIP: You can chat with Visor using |
\n\n
Architecture Issues (8)
Performance Issues (5)
Quality Issues (1)
Powered by Visor from Probelabs Last updated: 2026-03-20T19:16:53.074Z | Triggered by: pr_opened | Commit: 40d489d 💡 TIP: You can chat with Visor using |
Summary
readMediatool that handles both images (png, jpg, jpeg, webp, bmp, svg) and documents (pdf)filecontent part, natively supported by Claude (32MB), OpenAI (50MB), and Gemini (50MB)readImagepreserved as backward-compatible alias pointing to the same execute functionmediaConfig.jscentralizes format/MIME config, replacingimageConfig.js(which is kept for external consumers)Backward Compatibility
readImagetool name still works (alias)loadImageIfValid()still works (alias toloadMediaIfValid())getCurrentImages()still returns only image data URLs (filters out documents)readImageSchemastill exported at all levelsNew APIs
getCurrentMedia()— returns Vercel AI SDK content parts for both images and documentsreadMediaSchema— exported alongsidereadImageSchema{ type: 'document', mimeType, data, filename }objects inpendingImagesTest plan
readImagealias works for both images and PDFsgetCurrentImages()excludes PDFs (backward compat)getCurrentMedia()returns both image and file content parts🤖 Generated with Claude Code