Problem
When an agent uses the Read tool on large images, the full image is sent to the model, consuming significant context tokens. This can contribute to context overflow, especially in sessions with multiple image operations.
Current Workaround
I've created a wrapper script (view-image) that:
- Checks image dimensions and file size
- Creates a thumbnail if the image exceeds thresholds
- Returns the path to use (original or thumbnail)
But this requires the agent to remember to use the script — there's no automatic interception.
Proposed Solution
Add optional image preprocessing for the Read tool:
{
tools: {
read: {
imageMaxBytes: 2097152, // 2MB max
imageMaxDimension: 1024, // resize if larger
imageQuality: 85 // JPEG quality for resized images
}
}
}
When Read encounters an image exceeding these limits, it would automatically resize before sending to the model.
Benefits
- Prevents context bloat from accidental large image views
- No agent-side discipline required
- Configurable per user's needs
- Similar to existing
mediaMaxMb on channels
Environment
- OpenClaw version: 2026.1.30
- Related: context overflow issues with image-heavy sessions
Problem
When an agent uses the
Readtool on large images, the full image is sent to the model, consuming significant context tokens. This can contribute to context overflow, especially in sessions with multiple image operations.Current Workaround
I've created a wrapper script (
view-image) that:But this requires the agent to remember to use the script — there's no automatic interception.
Proposed Solution
Add optional image preprocessing for the
Readtool:When
Readencounters an image exceeding these limits, it would automatically resize before sending to the model.Benefits
mediaMaxMbon channelsEnvironment