refactor(gateway): use get_custom_provider_context_length() helper + pass custom_providers to @context path#18844
Conversation
|
Related to #15844 (merged), which introduced the helper this PR now uses in the remaining code paths. |
1 similar comment
|
Related to #15844 (merged), which introduced the helper this PR now uses in the remaining code paths. |
New commit:
|
f0918e8 to
b764842
Compare
1549dba to
1c7ebc2
Compare
Rebased onto latest
|
| Path | Before | After |
|---|---|---|
Gateway footer context_pct |
Always blank (None) | Shows correct % |
| CLI status bar | Already correct | Unchanged |
/modelinfo command |
Already correct | Unchanged |
/model switch display |
Already correct | Unchanged |
This is the last remaining gap from the custom_providers context-length work (#15844 merged). Ready for merge whenever.
The gateway footer reads agent_result.get('context_length') to display
context usage percentage. After the 3-module refactor (v2026.5.29), the
result dict was extracted to agent/turn_finalizer.py — but context_length
was never included, leaving the gateway footer blank.
The CLI status bar works fine because it reads context_compressor directly.
This 1-line fix makes gateway and CLI consistent.
Adapted to v2026.6.5: result dict now in agent/turn_finalizer.py.
1c7ebc2 to
d4f02d1
Compare
Rebased onto v2026.6.5 (commit c94e93a)Adapted to the
Gateway footer |
Summary
Three targeted fixes for the
custom_providerscontext-length resolution chain:1. Bug fix:
@contextexpansion path ignorescustom_providersThe
@contextreference expansion path callsget_model_context_length()without passingcustom_providers. This skips step 0b (per-modelcontext_lengthfromcustom_providers), so users who configurecustom_providers[].models.<m>.context_lengthwithout a top-levelmodel.context_lengthget wrong injection limits.2. Refactor: replace inline parsing with
get_custom_provider_context_length()helperThe hygiene-run path has a 27-line inline
custom_providersparsing loop. PR #15844 introducedget_custom_provider_context_length()as the single source of truth. This replaces the inline loop with a helper call.3. Bug fix:
run_conversation()result dict missingcontext_lengthfield (NEW)The gateway runtime_footer reads
context_lengthfromagent_result, butrun_conversation()never included this field in its return dict. This caused the footer'scontext_pctdisplay to always be skipped (None).The CLI status bar works fine because
_get_status_bar_snapshot()readscontext_lengthdirectly fromcontext_compressor. But the gateway footer only sees the result dict — soagent_result.get("context_length")was always None.Fix: Add
"context_length"to the result dict returned byrun_conversation(), derived fromcontext_compressor.context_length, matching the same source the CLI uses.New commit:
fix/context-length-result-dictbranch (1 line change in run_agent.py).Related
get_custom_provider_context_length()and fixed the main/modelswitch paths)Test Plan
@contextwith large file: Before → hard limit 64K; After → hard limit 100K/modelinfo: Already correct (usescustom_providers=param from fix(context): honor custom_providers context_length on /model switch + bump probe tier to 256K #15844)/modelswitch: Already correct (usesresolve_display_context_lengthfrom fix(context): honor custom_providers context_length on /model switch + bump probe tier to 256K #15844)