Keep image payloads out of managed context text estimates - #11
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bundled context manager also counted typed image base64 as text, inflating running usage and triggering summaries or inline compaction for ordinary images. Use a text-only estimate for both list and single-message accounting; mark pressure diagnostics when media cost is unmeasured. The input, transcript, and image bytes remain unchanged. Quoted data URLs and tool arguments continue to count as text; no invented pixel-token allowance is added.
Found during a class-wide audit using current MODULES.md plus local/configured/community sources. Companion fixes cover context-simple and loop-streaming; context-persistent inherits the simple-context fix. Native provider validation remains responsible for actual image cost and service limits.
Validation: all 374 context-managed module tests pass, including an 8.5 MB encoded image that stays present without triggering inline compaction and typed-vs-quoted/tool-image checks. New files pass Ruff; pre-existing main-file lint findings are unchanged. Live provider acceptance remains pending.
Companion draft PRs: microsoft/amplifier-module-context-simple#46, microsoft/amplifier-module-loop-streaming#64, #11.
Text estimates are partial, not a complete-request fit guarantee. Provider-native counts, request-size validation, and actual provider errors retain authority.