An image counted as half a million tokens: the context estimate measured its base64 as text, so a 1-3 MB screenshot read as "context at 150-280%" the moment view_image added it, and the session compacted after every image. An image now counts by its dimensions (28 px patches, at most 16k tokens, a flat 1600 when unreadable) everywhere the CLI estimates -- the meter, pruning, /context and the no-usage fallback of all five dialects. Images over 1600 px or 500 KB are shrunk to 1600 px when ImageMagick is there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
12 files changed
+196
-18
No files matched your search
@@ -2,7 +2,7 @@
|
||||
// up to what the server last reported when it reported anything.
|
||||
import type { Engine } from "./engine.ts"
|
||||
import { contextWindow } from "../provider/discover.ts"
|
||||
import { estimateTokens } from "../provider/tokens.ts"
|
||||
import { estimateTokens, imageTokens } from "../provider/tokens.ts"
|
||||
import { toSpec, type Tool } from "../tool/tool.ts"
|
||||
|
||||
export interface ContextRow {
|
||||
@@ -29,7 +29,7 @@ export function contextBreakdown(engine: Engine, system: string, instructions: {
|
||||
else if (p.type === "tool_call") by.calls += estimateTokens(p.name + p.args)
|
||||
else {
|
||||
imageCount++
|
||||
by.images += 800 // providers bill an image at roughly this for a typical screenshot
|
||||
by.images += imageTokens(p.data) // by its dimensions, as contextUsed counts it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user