Skip to content

feat(agentkit): add MultiModalRead for images and PDFs#812

Open
JonXSnow wants to merge 1 commit intomainfrom
feat/multimodal-read
Open

feat(agentkit): add MultiModalRead for images and PDFs#812
JonXSnow wants to merge 1 commit intomainfrom
feat/multimodal-read

Conversation

@JonXSnow
Copy link
Copy Markdown
Contributor

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

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
@github-actions
Copy link
Copy Markdown

Need to create a new tag

The following modules have changes and may need version updates:

  • adk/backend/agentkit (Current: adk/backend/agentkit/v0.2.5)

⚠️ Please create and push new version tags for these modules after merging this PR.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant