fix(tui_gateway): restore openrouter provider on session resume - #57593
liuhao1024 wants to merge 1 commit into
Conversation
BARE_BILLING_PROVIDERS incorrectly included "openrouter" alongside "auto" and "custom". OpenRouter is a fully routable provider with its own API key and base_url — sessions that used OpenRouter store billing_provider="openrouter", and dropping it forces resume to the current global model (e.g. a custom endpoint), which is the wrong provider for the stored model. Remove "openrouter" from the bare-bucket set so OpenRouter sessions correctly restore their provider identity on resume. Fixes NousResearch#57588
|
Thanks for the focused regression fix. Current The proposed change restores the provider exactly at the shared helper, while preserving the existing This is an automated hermes-sweeper review. |
|
Merged via #85558 — your commit was cherry-picked onto current main with your authorship preserved ( Thanks for the focused fix and the regression test — this closes #57588. (@Ahmett101's #57597 implemented the same fix and is credited in the salvage PR as well.) |
What does this PR do?
When a user switches from OpenRouter to a custom endpoint, resuming any previous OpenRouter session fails with a misleading context-window error. The root cause is
_BARE_BILLING_PROVIDERSintui_gateway/server.pytreating"openrouter"as a non-routable billing bucket (alongside"auto"and"custom"), which causes_stored_session_runtime_overridesto drop the provider override on resume. The session then falls back to the current global model (the custom endpoint), which serves a completely different model catalog and returns a tiny context window for the stored model name.OpenRouter is a fully routable provider with its own API key, base URL, and model catalog. Removing it from
_BARE_BILLING_PROVIDERSlets OpenRouter sessions correctly restore their provider identity on resume.Related Issue
Fixes #57588
Type of Change
Changes Made
tui_gateway/server.py— Remove"openrouter"from_BARE_BILLING_PROVIDERSset."auto"and"custom"remain as non-routable billing classes. Added comment explaining why"openrouter"is excluded ([Bug]: Adding new custom provider breaks all previous sessions. Provider changes, but not the model. #57588).tests/test_tui_gateway_server.py— Updatedtest_stored_session_runtime_overrides_skips_bare_billing_providerto remove"openrouter"from the bare-bucket loop. Addedtest_openrouter_session_resume_restores_providerregression test verifying that OpenRouter sessions restore the"openrouter"provider override on resume.How to Test
anthropic/claude-opus-4.8)./sessions.python -m pytest tests/test_tui_gateway_server.py::test_stored_session_runtime_overrides_skips_bare_billing_provider tests/test_tui_gateway_server.py::test_openrouter_session_resume_restores_provider tests/tui_gateway/test_custom_provider_session_persistence.py -v→ should pass.Checklist
Code
fix(scope):)pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/A