fix(agent): pass config_context_length in fallback activation path#14727
Closed
CruxExperts wants to merge 1 commit into
Closed
fix(agent): pass config_context_length in fallback activation path#14727CruxExperts wants to merge 1 commit into
CruxExperts wants to merge 1 commit into
Conversation
Try to activate fallback model after errors was calling get_model_context_length() without the config_context_length parameter, causing it to fall through to DEFAULT_FALLBACK_CONTEXT (128K) even when config.yaml has an explicit model.context_length value (e.g. 204800 for MiniMax-M2.7). This mirrors the fix already present in switch_model() at line 1988, which correctly passes config_context_length. The fallback path was missed. Fixes: context_length forced to 128K on fallback activation
Collaborator
|
Related: #12630 (broader fix propagating config_context_length to all 7 missed call sites). This PR fixes only the fallback activation path. |
Contributor
|
This fix has already landed on Automated hermes-sweeper review confirmed the change is present:
No action needed — this PR's change is already incorporated. Thanks for the contribution, @CruxExperts! |
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 does this PR do?
Fixes a bug where
_try_activate_fallback()callsget_model_context_length()without theconfig_context_lengthparameter. This causes the fallback activation to ignore the explicitmodel.context_lengthvalue inconfig.yamland instead fall through toDEFAULT_FALLBACK_CONTEXT(128K).Root cause
In
run_agent.py, theswitch_model()method (line 1988) correctly passesconfig_context_length=getattr(self, '_config_context_length', None)when callingget_model_context_length(). However,_try_activate_fallback()(line 6435) was missing this parameter.The resolution chain in
get_model_context_length()is:config_context_lengthis passed → return it immediately (respects config.yaml)DEFAULT_FALLBACK_CONTEXT(128K) — the fallback for everything that failsWithout
config_context_lengthpassed, a fallback activation that fails all probes lands at step 9 → 128K, overwriting the correct 204800 value from config.The crash cascade
get_model_context_length()called without config override → returns 128Kcontext_compressor.update_model(128K)overwrites the correct 204800Changes
run_agent.py— line ~6438fb_context_length = get_model_context_length( self.model, base_url=self.base_url, api_key=self.api_key, provider=self.provider, + config_context_length=getattr(self, "_config_context_length", None), )This mirrors the existing correct behavior in
switch_model()at line 1988.Risk
Very low:
switch_model()already doesTesting
_try_activate_fallback()with a mocked_config_context_lengthand verifiesget_model_context_lengthis called with that parameterFixes: context_length forced to 128K on fallback activation even when config.yaml has a higher value