Skip to content

fix: estimate image_url tokens independently of URL length - #27

Merged
royalpinto007 merged 2 commits into
AgentPostmortem:mainfrom
Rayan-and-beyond:fix/image-url-token-estimate-22
Sep 16, 2026
Merged

royalpinto007 merged 2 commits into
AgentPostmortem:mainfrom
Rayan-and-beyond:fix/image-url-token-estimate-22

Conversation

@Rayan-and-beyond

Copy link
Copy Markdown
Contributor

Fixes #22.

image_url blocks now use a documented flat 85-token built-in estimate, so token cost no longer changes with URL length.

Validation: node --test (25 passed) and git diff --check.

@royalpinto007

Copy link
Copy Markdown
Member

Almost there. One inconsistency: compact()'s trim loop still decrements with counter(unit.text), ignoring the new fixedTokens, so dropping an image message under --max decrements after by 0 instead of 85 and over-trims. Please subtract u.fixedTokens ?? counter(u.text) in the trim-loop accounting.

@royalpinto007
royalpinto007 merged commit 14afbcc into AgentPostmortem:main Sep 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

image_url blocks counted as JSON text, no image token model

2 participants