Skip to content

fix: rebuild oversized provider requests once without losing retained context - #52

Merged
Brian Krabach (bkrabach) merged 2 commits into
mainfrom
lane/budget-loop
Sep 15, 2026
Merged

Brian Krabach (bkrabach) merged 2 commits into
mainfrom
lane/budget-loop

Conversation

@bkrabach

Copy link
Copy Markdown
Collaborator

What changed
Adds a provider-budget preflight to the streaming loop. When an optional synchronous request_budget capability reports that a fully assembled request is oversized, the loop performs one request_retention budget rebuild, preserving the same human and reminder bodies and replaying request-only injections without rerunning hooks. If the required floor cannot fit, it raises ContextLengthError locally; it does not retry a real HTTP overflow. Providers without the capability, including Anthropic, preserve legacy behavior and byte parity.

Why
The companion producer change is merged: microsoft/amplifier-module-provider-openai#95. This loop-side guard consumes its optional capability so oversized assembled requests can be reduced once before SDK dispatch while retaining required context.

How to verify
DTU-native validation against Core 1.6.1 passed: Loop 295 tests including 21 focused; OpenAI 973 including 22 focused with 2 live tests deselected; Context 140 plus 1 expected failure; total 1408. Ruff passed for five changed Python files. Coverage includes paired real-context/StreamingOrchestrator/provider-adapter flows with fake SDKs only: baseline fake overflow versus one fitting candidate, required wire bodies exactly once, Anthropic byte parity, irreducible-floor SDK zero calls, and plausible usage calibration. The repository CI matrix runs Python 3.11 through 3.14 against amplifier-core 1.5.2.

Scope and limits
No Core, dependency, configuration-knob, or context-window changes. The guard can compact earlier on an initial or resumed turn; operational estimates are not a native 1M-context guarantee.

Breaking changes
None.

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>
@bkrabach
Brian Krabach (bkrabach) merged commit 678fe6b into main Sep 15, 2026
5 checks 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.

2 participants