fix: preserve configured context lengths across runtime paths - #14008
fix: preserve configured context lengths across runtime paths#14008tongguang2 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
1 similar comment
|
Thanks for digging into this, @tongguang2 — the context-length consistency area is genuinely fiddly and the investigation was solid. Closing without merge after verifying both halves against current Runtime-path overrides (switch_model / fallback): already solved on Persistent cache-key So both halves are either already covered or fix a scenario that doesn't occur at runtime. Closing as superseded by #15779. Appreciate the contribution and the careful write-up. |
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.