fix: request hard-fit context rebuilds and expose budget telemetry - #53
Merged
Merged
Conversation
Generated with Amplifier Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Generated with Amplifier Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Generated with Amplifier Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
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.
Summary
Use the context manager's optional hard-fit capability for provider-directed rebuilds, and make provider-budget decisions discoverable by logging hooks.
hard_fit=Trueonly when a provider preflight asks for a rebuild, in both ordinary generation and finalization paths.TypeError. Old retention signatures and generic contexts keep their existing call shape.orchestrator:provider_budgetin the module'sobservability.eventscontribution.The at-most-one rebuild rule, second preflight, final provider payload guard, required-content retention, tool pairing, and safe notice placement remain intact. No Core, provider implementation, dependency, CI, user configuration, or model-window metadata changes.
Dependency
The context producer change is merged: microsoft/amplifier-module-context-simple#41
Its exact merge commit passed main-branch CI before this downstream publication. Older contexts remain supported through the legacy fallback, with the second preflight still enforcing the provider budget.
Validation
Recorded against this exact candidate in an isolated DTU:
test_hard_fit_stays_compacted_across_real_openai_dispatches.The regression fixture uses generated supplementary Han characters so its character estimate remains below ordinary compaction's threshold while its serialized UTF-8 size triggers the real provider preflight. It does not replace the budget calculation or weaken the test assertions.
These are deterministic offline mechanism tests, not real-vendor requests, task-quality or cache-performance measurements, proof of a native context ceiling, or a claim that the whole Python CI matrix ran in the DTU.
Changed files
amplifier_module_loop_streaming/__init__.pytests/test_provider_budget_guard.pytests/test_provider_budget_context_simple_runtime.pytests/test_request_retention.pyREADME.md