fix(gateway): restore credential pools for session overrides - #30802
fix(gateway): restore credential pools for session overrides#30802Qwinty wants to merge 1 commit into
Conversation
|
Scope note: this draft remains focused on restoring credential pools for persisted session runtime overrides. The separate live Codex quota/exhaustion bug is now isolated in draft PR #31032.\n\nThat separation matters because this PR only reloads the pool object for an override; it does not change Codex usage-limit reconciliation or duplicate quota grouping. If #31032 lands first, this PR is still the small gateway/session-override follow-up. |
|
Decision after updating #31032: leaving this PR as a draft fallback for now, not marking it ready. #31032 now includes this exact helper as commit |
What does this PR do?
Restores the missing helper used by the gateway session model override fast path. Complete persisted
/modeloverrides include an API key and should avoid global runtime resolution, but currentmaincalls_load_credential_pool_for_provider(...)without defining it. That raisesNameErrorbefore an agent is created and messaging users see a generic provider authentication failure withapi_calls=0.The helper is intentionally best-effort: it returns a credential pool when available, and otherwise falls back to
Noneso a complete session override with an explicit API key still works.Related Issue
No existing issue found. I searched related PRs/issues for
_load_credential_pool_for_providerand session model override credential pool failures before opening this PR.Type of Change
Changes Made
gateway/run.py: adds_load_credential_pool_for_provider()for persisted session runtime overrides, with safe fallback when the pool cannot be loaded.How to Test
mainby running the focused gateway test:python -m pytest -q -o addopts='' tests/gateway/test_session_model_override_routing.py::test_run_agent_prefers_session_override_over_global_runtimeProvider authentication failed: name '_load_credential_pool_for_provider' is not defined./usr/local/lib/hermes-agent/venv/bin/python -m pytest -q -o addopts='' tests/gateway/test_session_model_override_routing.py tests/gateway/test_model_switch_persistence.py/usr/local/lib/hermes-agent/venv/bin/python -m ruff check gateway/run.py tests/gateway/test_session_model_override_routing.py tests/gateway/test_model_switch_persistence.pyResult:
12 passed, 1 warning; ruff passed.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Relevant pre-fix failure from focused test:
Full test commands and results are listed above.