Conversation
|
| Filename | Overview |
|---|---|
| api/routes.py | Adds shared _context_length_lookup_inputs_for_model() helper plus supporting utilities; replaces the inline extraction block in _resolve_context_length_for_session_model(). Logic is well-guarded and the precedence chain (provider > custom_provider > global) is correct. |
| api/streaming.py | Two context-length fallback sites updated to use the shared helper. _cfg_base_url is now pre-assigned before the helper call in the session-save path, resolving the prior unbound-variable risk in the legacy TypeError handler; the SSE usage path assigns it after the helper but before the inner try/except, so no NameError is possible. |
| tests/test_issue3717_context_length_provider_overrides.py | New regression suite with four functional tests covering named providers with/without base_url, named custom_providers, and the default-model-only guard. |
| tests/test_issue1896_context_length_fallback_args.py | Updated to match renamed _cfg_provider variable and the moved config-extraction logic. Assertions remain meaningful and correctly anchor the source-code contracts. |
| CHANGELOG.md | CHANGELOG entry added under [Unreleased] per AGENTS.md requirements; accurately describes the user-visible fix and the legacy-path hardening. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Context-length resolution needed"] --> B["_context_length_lookup_inputs_for_model()"]
B --> C{"providers cfg matches provider?"}
C -- Yes --> D["Read provider.models context_length + base_url"]
C -- No --> E{"custom_providers matches?"}
D --> F{"provider_context_length found?"}
F -- Yes --> G["Use provider_context_length"]
F -- No --> E
E -- Yes --> H["Read custom entry context_length + base_url"]
E -- No --> I{"global model.context_length applies?"}
H --> J{"custom_context_length found?"}
J -- Yes --> K["Use custom_context_length"]
J -- No --> I
I -- Yes --> L["Use global_context_length"]
I -- No --> M["config_context_length = None"]
G & K & L & M --> N["_ContextLengthLookupInputs returned"]
N --> O["get_model_context_length() called"]
O -- TypeError --> P["legacy 2-arg fallback"]
O -- Success --> Q["context_length resolved"]
P --> Q
Reviews (2): Last reviewed commit: "fix(#3717): tighten provider override fa..." | Re-trigger Greptile
| return _ContextLengthLookupInputs( | ||
| config_context_length=provider_context_length or custom_context_length or global_context_length, | ||
| custom_providers=custom_providers, | ||
| base_url=effective_base_url, | ||
| provider=effective_provider, | ||
| ) |
There was a problem hiding this comment.
Missing CHANGELOG entry for user-visible fix
AGENTS.md requires updating CHANGELOG.md for user-visible behavior changes that are release-note ready. This PR corrects what the PR description calls a "misleading usage indicator" — wrong context-window display when per-provider or custom-provider overrides are configured — which is squarely user-visible. No CHANGELOG entry was added.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Read the full diff plus This closes the standard-provider gap that the earlier #3717 analysis flagged as needing a separate fixThe prior writeup on #3717 noted that the This PR sidesteps that correctly. for provider_key, provider_cfg in providers_cfg.items():
if not _providers_match_for_context(provider_key, effective_provider):
continue
...
provider_context_length = _models_config_context_length(
provider_cfg.get("models"), bare_model or model_for_lookup,
)
breakand is then fed as # agent/model_metadata.py:1517
if config_context_length is not None and isinstance(config_context_length, int) and config_context_length > 0:
return config_context_lengthSo a Minor:
|
|
Pushed 5927949. The session-save fallback now seeds \_cfg_base_url\ before the shared helper runs, so the legacy 2-arg retry cannot hit an unbound local if that helper ever raises \TypeError\. I also added the missing regression case for \providers..models..context_length\ with no configured \�ase_url\, plus the requested CHANGELOG note. Rechecked with \ ests/test_issue3717_context_length_provider_overrides.py tests/test_issue1896_context_length_fallback_args.py tests/test_issue1436_context_indicator_load_path.py -v --timeout=60\ (26 passed). |
…des (#3726) (#3752) @rodboev. providers.<name>.models.<model>.context_length overrides (standard provider, no base_url) were invisible to the session context resolver → wrong window shown/persisted, could trip auto-compression at the wrong threshold. New _context_length_lookup_inputs_for_model helper resolves provider config / base_url / custom_providers across route-load, session-save, and SSE-usage paths; provider-scoped overrides match by provider name and forward as config_context_length (returned before any base-url-gated probe). Maintainer pre-merge items both already satisfied in PR head: no-base_url regression test (test_route_resolver_uses_provider_model_context_length_without_base_url) present; session-save _cfg_base_url assigned before the helper call (safe-bound, no NameError on TypeError fallback). Verified api code byte-identical to PR head; 14 context-length tests pass. + CHANGELOG v0.51.300. Co-authored-by: nesquena-hermes <[email protected]>
|
Thanks @(author) — this fix shipped in v0.51.300. Your change was cherry-picked onto the release stage during the 2026-06-06 sweep (context-length indicator honors per-model overrides — stage-3726), so this PR is now redundant against master (it shows as conflicting because the fix is already present). Closing as indirectly merged with full attribution. Appreciate the contribution! 🙏 |
|
(Correcting attribution above: thanks @rodboev for this — credited in the release CHANGELOG.) |
…l overrides (nesquena#3726) (nesquena#3752) @rodboev. providers.<name>.models.<model>.context_length overrides (standard provider, no base_url) were invisible to the session context resolver → wrong window shown/persisted, could trip auto-compression at the wrong threshold. New _context_length_lookup_inputs_for_model helper resolves provider config / base_url / custom_providers across route-load, session-save, and SSE-usage paths; provider-scoped overrides match by provider name and forward as config_context_length (returned before any base-url-gated probe). Maintainer pre-merge items both already satisfied in PR head: no-base_url regression test (test_route_resolver_uses_provider_model_context_length_without_base_url) present; session-save _cfg_base_url assigned before the helper call (safe-bound, no NameError on TypeError fallback). Verified api code byte-identical to PR head; 14 context-length tests pass. + CHANGELOG v0.51.300. Co-authored-by: nesquena-hermes <[email protected]>
Thinking Path
custom_providers, but Bug: Context length indicator ignoresproviders/custom_providersper-model overrides #3717 reports the remaining configured-provider path.What Changed
api/routes.py: resolve provider-specific/base-url context metadata in_resolve_context_length_for_session_model().api/streaming.py: mirror the same resolution for session-save and live SSE usage fallbacks.tests/test_issue3717_context_length_provider_overrides.py: add regression coverage forprovidersand namedcustom_providersper-model overrides.tests/test_issue1896_context_length_fallback_args.py: update source-shape assertions if needed for the shared helper.Why It Matters
Users who configure custom or provider-specific model windows should see the real context window immediately and persist it correctly. A stale fallback cap causes misleading usage indicators and can trigger compression too early.
Verification
Local tests were skipped for this push so CI can provide the concrete validation result without Windows console-window interference.
Risks / Follow-ups
Model Used
GPT 5.5 via Codex CLI