fix(run_agent): use aux provider for compression context length lookup (salvage #16918)#20218
Merged
Conversation
Each auxiliary model must be resolved with its own provider so that provider-specific paths (e.g. Bedrock static table, OpenRouter API) are invoked for the correct client, not inherited from the main model. When the main model is Bedrock, passing self.provider unconditionally to get_model_context_length() for the aux model caused the Bedrock static table hard-intercept (step 1b) to fire for non-Bedrock models, returning BEDROCK_DEFAULT_CONTEXT_LENGTH=128K instead of the model's real context window — triggering a false compression warning every session. Fix: pass _aux_cfg_provider when explicitly set, falling back to self.provider only when the aux provider is unset or "auto". Closes #12977 Related: #13807, #17460
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.
Salvages @rxdxxxx's PR #16918 onto current main. Closes #12977.
What it does
get_model_context_length()for the auxiliary compression model was called withself.provider(the MAIN model's provider). When the main model is on Bedrock, the Bedrock static-table hard-intercept fired for non-Bedrock auxiliary models and returnedBEDROCK_DEFAULT_CONTEXT_LENGTH=128Kinstead of the aux model's real context window — triggering a false compression warning every session.Changes
run_agent.py— pass_aux_cfg_provider(resolved a few lines above) when explicitly set, fall back toself.provideronly when_aux_cfg_provideris unset orauto.Validation
tests/run_agent/ -k 'compression or aux or context_length'— 69 passed locally.Closes #16918 via salvage.