fix(model_metadata): auto-load global custom_providers in get_model_context_length (closes #12977) (closes #13807)#17460
Open
smallerxie wants to merge 1 commit into
Conversation
d06b772 to
54fc120
Compare
This was referenced Apr 29, 2026
Open
…ontext_length (closes NousResearch#12977) (closes NousResearch#13807)
54fc120 to
c53d3d1
Compare
This was referenced May 2, 2026
rxdxxxx
added a commit
to rxdxxxx/hermes-agent
that referenced
this pull request
May 5, 2026
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 NousResearch#12977 Related: NousResearch#13807, NousResearch#17460
teknium1
pushed a commit
that referenced
this pull request
May 5, 2026
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
teknium1
pushed a commit
that referenced
this pull request
May 5, 2026
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
nickdlkk
pushed a commit
to nickdlkk/hermes-agent
that referenced
this pull request
May 11, 2026
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 NousResearch#12977 Related: NousResearch#13807, NousResearch#17460
rmulligan
pushed a commit
to rmulligan/hermes-agent
that referenced
this pull request
May 11, 2026
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 NousResearch#12977 Related: NousResearch#13807, NousResearch#17460
JinyuID
pushed a commit
to JinyuID/hermes-agent
that referenced
this pull request
May 11, 2026
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 NousResearch#12977 Related: NousResearch#13807, NousResearch#17460
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
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 NousResearch#12977 Related: NousResearch#13807, NousResearch#17460
jsboige
pushed a commit
to jsboige/hermes-agent
that referenced
this pull request
May 14, 2026
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 NousResearch#12977 Related: NousResearch#13807, NousResearch#17460
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
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 NousResearch#12977 Related: NousResearch#13807, NousResearch#17460
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
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 NousResearch#12977 Related: NousResearch#13807, NousResearch#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.
Summary
get_model_context_length()now auto-loads the globalcustom_providersfromconfig.yamlwhen thecustom_providersparameter isNone. This ensures per-modelcontext_lengthoverrides incustom_providersare visible to all callers — including auxiliary model resolution paths that currently don't passcustom_providers.Symptom: a user with
custom_providersdefiningLongCat-2.0-Previewat 1M context sees this warning on every session start:The
(custom)model correctly reads 1M fromcustom_providers, but the compression feasibility check reads the hardcoded default becauseget_model_context_lengthnever sees the user'scustom_providers.Root cause: step 0b in
get_model_context_length()has acustom_providersparameter (defaultNone). Most callers — compressor feasibility check, fallback model activation, session hygiene, context reference preprocessing — do not pass it, so thecustom_providerslookup is silently skipped. The main model works becauseAIAgent.__init__directly callsget_custom_provider_context_lengthbeforeget_model_context_length. Auxiliary models have no such pre-step.Fix approach: auto-load
custom_providersfrom global config insideget_model_context_length()when the parameter isNone, rather than threading it through every caller. This is the minimal fix — one file, oneifbranch, consistent with how the function already handles other fallback sources.Why this PR is not a duplicate
Relationship to PR #15844 (merged)
PR #15844 added step 0b with a
custom_providers=kwarg and wired it through 5 call sites (startup,/modelswitch, display paths). However, it did not wire the remaining call sites:_check_compression_model_feasibility()inrun_agent.py:2178resolve_vision_provider_client()inauxiliary_client.pyget_title_model_context_length()inrun_agent.pyThese callers still pass
custom_providers=None, so step 0b is silently skipped. The exact symptom described in #12977 and #13807 (compression warning) persists onmaintoday. This PR closes the remaining gap that #15844 left open.Relationship to PR #14023 (closed)
PR #14023 proposed the same step 0b fix but was closed because #15844 had landed. The closing comment stated:
This was incorrect — #15844 only partially addressed the issue. The auxiliary paths that #14023 would have fixed are still broken. This PR completes the work that #14023 started.
Relationship to PR #13813 (open)
PR #13813 fixes only the compression path by duplicating the providers lookup in
run_agent.py's_prepare_compression(). That approach:This PR's auto-load approach is the most general solution: a single change in
model_metadata.pythat protects all current and future callers without requiring each one to be manually wired.Changes
agent/model_metadata.py— step 0b: whencustom_providers is None, auto-load from global config viaget_compatible_custom_providers(). On failure, fall back to[](empty list), preserving existing behavior.tests/run_agent/test_compression_feasibility.py— 3 new tests:test_custom_providers_auto_loaded_when_none: verifies auto-load resolves 1M context from mockedcustom_providerstest_custom_providers_auto_load_failure_falls_through: verifies graceful fallback when auto-load raisestest_explicit_empty_custom_providers_skips_lookup: verifies[]skips auto-load entirelyValidation
test_compression_feasibility.pytest_model_metadata.pyCloses
#12977
#13807
#8785