feat(agentkit): add MultiModalRead for images and PDFs#812
Open
feat(agentkit): add MultiModalRead for images and PDFs#812
Conversation
Add MultiModalRead to SandboxTool that returns structured multimodal
content for image and PDF files, with fallback to Read for other types.
Images:
- Read raw bytes via readAllBytes Python template (base64 transfer)
- Detect MIME type via magic-number headers (PNG/JPEG/GIF/BMP/WebP/TIFF)
- Enforce 10 MB size limit
PDFs:
- Full read (no 'pages'): return raw PDF bytes, 20 MB limit
- Paged read (with 'pages'): render page range to PNG via go-fitz at
150 DPI, 100 MB limit, max 20 pages per request
- Validate 'pages' parameter syntax and ranges upfront
- Clamp end page with warning when it exceeds total page count
Size enforcement:
- Dual-layer check: Python side (os.path.getsize) rejects before read,
Go side re-checks after decode as defense-in-depth
- Use stdout sentinel marker (__READALLBYTES_TOO_LARGE__) instead of
exit codes to distinguish size errors from other failures
- Provide actionable error messages (e.g. suggest 'pages' param when
full-read limit is exceeded)
Also:
- Switch Write template to binary mode ('wb') for byte-level fidelity
- Add table-driven tests for parsePagesParam
- Bump go directive to 1.23; upgrade eino to v0.9.0-alpha.5
Need to create a new tagThe following modules have changes and may need version updates:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add MultiModalRead to SandboxTool that returns structured multimodal content for image and PDF files, with fallback to Read for other types.
Images:
PDFs:
Size enforcement:
Also: