Stop Base64 Encoding Large Files in Tool Calls
MarcusW4evr · reddit · 2026-07-19
While implementing a tool call for agents to upload files, the author discovered that converting files to base64 and embedding them in the payload works for small files but fails badly with real-world files. A JPEG of a few to hundreds of KB bloats into tens of thousands of tokens after base64 encoding. Although the upload succeeds, the cost is entirely disproportionate, as this encoded data isn't meant for model reasoning but merely transferring "from A to B."
A more rational approach is having the agent write files to disk or reference existing paths/URLs, letting the server-side tool read the bytes directly instead of routing binary content into the context. Base64 should be reserved exclusively for truly small items like icons or thumbnails.
More from coding & agent
- A better path to agent autonomy is running waves, finding friction, and iterating — JnBrymn · 2026-07-22
- Coding agents are heading toward an AI-writes, AI-reviews, human-approves workflow — aftahi_ai · 2026-07-22
- oMLX 0.5.2 adds Mac menu-bar stats, low-bit decode kernels, and faster downloads — awnihannun · 2026-07-22
- GitHub review bot hits its PR limit and forces a 39-minute cooldown — DanielLockyer · 2026-07-22
- Max reasoning effort appears to be mobile-only in Codex Remote, not desktop — GabGarrett · 2026-07-22
- A Reddit demo argues online stores should expose carts and pricing through MCP — gelembjuk · 2026-07-22