#2958: fix(media): wire tools.media.image.maxBytes config to image processin…
agents
…g pipeline
Fixes #2954
The configuration setting tools.media.image.maxBytes was defined but not wired through the image sanitization pipeline. This resulted in hardcoded constants being used instead of the user-configured value.
Changes:
- Modified sanitizeSessionMessagesImages() to accept maxBytes in options
- Modified sanitizeSessionHistory() to accept and pass maxBytes parameter
- Updated attempt.ts to pass config value through the sanitization chain
- All sanitizeContentBlocksImages() calls now receive the configured maxBytes
This ensures that when users configure a custom image size limit, it is actually used throughout the image processing pipeline instead of being ignored.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR wires the `tools.media.image.maxBytes` configuration through the Pi embedded image handling pipeline so the configured limit is applied consistently (session history sanitization via `sanitizeSessionHistory()` → `sanitizeSessionMessagesImages()` → `sanitizeContentBlocksImages()`, and prompt image loading via `detectAndLoadPromptImages()`).
Net effect: oversized base64 images and auto-loaded prompt images should now be resized/dropped based on user configuration instead of relying only on hardcoded defaults.
<h3>Confidence Score: 3/5</h3>
- Mostly safe to merge, but there are a couple of correctness/scope concerns worth addressing first.
- The maxBytes wiring itself is straightforward and matches existing sanitizer APIs, but passing raw config values through can create surprising behavior for invalid/non-positive values (effectively dropping all images). Also, the changelog entry appears unrelated to the PR’s described change, suggesting scope creep or an accidental addition.
- src/agents/pi-embedded-runner/run/attempt.ts, CHANGELOG.md
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#9598: fix(agents): check base64 string length against 5MB API limit
by BlockBB · 2026-02-05
81.9%
#20913: fix: intercept Discord embed images to enforce mediaMaxMb
by MumuTW · 2026-02-19
79.7%
#3895: perf: mathematical optimization of vision pipeline via deterministi...
by adarshsen592-create · 2026-01-29
79.0%
#23639: fix(agents): stop re-resizing session history images on every turn ...
by yinghaosang · 2026-02-22
78.1%
#23662: fix: cache sanitized images to avoid redundant re-processing per turn
by davidemanuelDEV · 2026-02-22
77.1%
#4269: fix: support tool result image format in Control UI
by bobcyw · 2026-01-30
76.4%
#19135: fix(agents): prune excess images from conversation history (#19099)
by pierreeurope · 2026-02-17
76.4%
#4445: fix: resolve Antigravity "unsupported version" and tool_use schema ...
by harry2690 · 2026-01-30
76.1%
#3647: fix: sanitize tool arguments in session history
by nhangen · 2026-01-29
76.0%
#18219: fix: validate base64 image data before sending to LLM APIs
by Grynn · 2026-02-16
75.5%