fix: preserve configured context lengths across runtime paths#14008
Open
tongguang2 wants to merge 1 commit into
Open
fix: preserve configured context lengths across runtime paths#14008tongguang2 wants to merge 1 commit into
tongguang2 wants to merge 1 commit into
Conversation
- normalize context cache keys so /v1 and /v1/ share the same entry - resolve configured context overrides per runtime target during switch and fallback - add regression coverage for cache normalization and per-model override handling
Collaborator
Collaborator
1 similar comment
Collaborator
This was referenced Apr 22, 2026
This was referenced May 12, 2026
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
This PR fixes a set of context length inconsistencies that still affect custom-provider runtimes across different execution paths.
What it fixes
/v1and/v1/resolve to the same provider endpointcustom_providerscontext override for a different target modelRoot cause
There were two separate issues:
.../v1and.../v1/as different keys, which caused cache misses for the same custom provider endpoint in different runtime paths.switch_model()/ fallback activation) did not consistently resolve the configured context-length override for the active target model and endpoint.As a result, custom providers that were correctly configured in
config.yamlcould still fall back to an incorrect detected context length in some paths.Implementation details
AIAgentTests
Verified with:
tests/agent/test_model_metadata.pytests/run_agent/test_switch_model_context.pytests/run_agent/test_fallback_model.pytests/run_agent/test_provider_fallback.pytests/run_agent/test_invalid_context_length_warning.pytests/run_agent/test_compression_feasibility.pyLocal result:
147 passedNotes
This PR is intentionally scoped to the runtime-path inconsistency and cache-key normalization issue. It does not introduce broader changes to provider metadata discovery beyond what is needed to make configured context lengths behave consistently.