Skip to content

Use image-aware text estimates throughout loop budgeting - #64

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

The loop independently estimated context by stringifying messages, turning image base64 into millions of text tokens even when the provider understood typed media. Use a structured text-only estimate consistently in preflight, measured candidates, overflow recovery, and both dispatch telemetry paths. Image token cost remains unknown without a provider count; images and canonical history are untouched. Provider-native limits and failure semantics are unchanged.

Companion context-simple and context-managed changes remove the same false accounting upstream of the loop. Class review included loop-basic/events (delegate context budgeting), Microsoft and bkrabach loop-live (delegate execution to streaming), all known provider sources, and the latest MODULES.md catalog. No host/Foundation dependency is added.

Validation: 449 loop tests pass, including 20 large-valid-PNG runtime scenarios across streaming/nonstreaming, estimate/actual context modes, and absent/unavailable/exact/oversized/failed counters. Existing real OpenAI integration tests run without skips. The real Unified fixture sends the original 6,310,938-byte PNG once and completes with no image data in public events and no network requests. OpenAI request-budget suite: 85 pass. Live provider acceptance and deployment dependency updates remain pending. New files pass Ruff; pre-existing main-file lint findings are unchanged.

Companion draft PRs: microsoft/amplifier-module-context-simple#46, #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