Skip to content

Avoid counting typed image payloads as context text - #46

Merged
Brian Krabach (bkrabach) merged 1 commit into
mainfrom
fix/typed-image-budget
Sep 25, 2026
Merged

Brian Krabach (bkrabach) merged 1 commit into
mainfrom
fix/typed-image-budget

Conversation

@bkrabach

@bkrabach Brian Krabach (bkrabach) commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

A valid 6.31 MB PNG was counted as roughly 2.1 million text tokens, so protected current input could fail before any provider call. Estimate textual content without counting typed image transport (base64/URLs), mark the image portion as unmeasured, and use the same estimate for compaction deltas. Original messages and images are unchanged; quoted data and tool arguments still count as text. Native provider counts and real text-budget failures remain authoritative.

Class review refreshed microsoft/amplifier docs/MODULES.md at 33b75749 and checked known contexts, loops, providers, and bundled contexts. context-persistent inherits this fix; loop-streaming and bundled context-managed need companion patches. context-handoff remains unavailable (repository not found). Existing OpenAI PR103 already handles provider-layer typed-media budgeting.

Validation: 227 context-simple tests passed (1 expected failure); 21 context-persistent tests passed; 449 loop-streaming tests passed with both patches, including streaming/nonstreaming, estimate/actual meters, absent/unavailable/exact/oversized/failed counters. The real Unified/loop-live fixture now dispatches the original PNG exactly once and completes; zero provider network calls. Live ChatGPT/Anthropic/OpenAI acceptance remains pending. New files pass Ruff; main-file lint findings are unchanged from the base. No new runtime dependency.

Companion draft PRs: #46, microsoft/amplifier-module-loop-streaming#64, microsoft/amplifier-bundle-context-managed#11.

Text estimates are partial, not a complete-request fit guarantee. Provider-native counts, request-size validation, and actual provider errors retain authority.

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.

1 participant