fix(loop): recover provider input overflow once. - #56
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>
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.
What changed
Adds one bounded recovery path for a provider-reported input-context overflow:
recover_context_overflowcapability can return a strict budget dictionary after aContextLengthError.Noneretry-preflight result remains unproven rather than being treated as a local fit; the prior server rejection is the narrow authorization for that retry.tool_choice="none"; cancellation, iterator finalization, and tool-turn closure remain protected.request_optionsare forwarded only to optional methods that explicitly declare that named parameter. Providers with only**kwargsretain their existing call shape.Why
A provider can reject an input after ordinary request assembly. The generic loop needs a narrowly bounded, provider-authorized way to retry with a smaller context without parsing provider-private error text or replaying turn side effects.
Compatibility and scope
Providers that do not expose the recovery capability retain the existing dispatch behavior. The generic loop does not define or parse provider-private feedback formats. This change introduces no release or host-rollout claim.
Validation
Previously completed isolated validation against Core 1.6.1 (not rerun while publishing this PR):
SDK/transport cases use a synthetic byte-count oracle, not native vendor token limits; they do not prove live restoration or general output quality. Remaining module-wide Ruff diagnostics are pre-existing, so this is not a full clean-lint claim.
Follow-up
A companion Anthropic change remains pending Loop
mainCI; it is not part of this PR.How to verify
Run the module's provider budget and overflow recovery tests in an environment with the compatible Core version, then run the applicable joint provider/context collection.
Breaking changes
None expected for providers without the optional recovery capability.