The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: refresh xai-oauth on auto-routed auxiliary 403 bad-credentials
teknium1c739ab15f6d3
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex 354636f0796..dfbe139c4c2 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -3413,6 +3413,9 @@ _POOL_PROVIDER_BY_HOST = (_AUTH_REFRESH_PROVIDER_BY_HOST = (("api.githubcopilot.com", "copilot"), ("chatgpt.com", "openai-codex"),("api.anthropic.com", "anthropic"), ("inference-api.nousresearch.com", "nous"),+ # An aux call that inherits the main xai-oauth route arrives as "auto"; without this row the+ # 403 bad-credentials rung skipped the refresh and benched the only grant (#84845).+ ("api.x.ai", "xai-oauth"),)diff --git a/tests/agent/test_auxiliary_auto_route_xai_oauth_refresh.py b/tests/agent/test_auxiliary_auto_route_xai_oauth_refresh.pynew file mode 100644index 00000000000..39cc6b96d2a--- /dev/null+++ b/tests/agent/test_auxiliary_auto_route_xai_oauth_refresh.py@@ -0,0 +1,16 @@+"""Auto-routed auxiliary calls on xAI OAuth refresh the grant after a 403 bad-credentials (#84845).++A plugin/hook ``call_llm`` with no provider override inherits the main ``xai-oauth`` route as+``resolved_provider == "auto"``; the refresh rung must still resolve the concrete backend from the+client's host so the expired bearer is refreshed and retried instead of benching the only grant.+"""++from agent.auxiliary_client import _auth_refresh_provider_for_route+++def test_auto_route_on_xai_host_refreshes_xai_oauth():+ assert _auth_refresh_provider_for_route("auto", "https://api.x.ai/v1") == "xai-oauth"+++def test_unknown_host_on_auto_route_stays_auto():+ assert _auth_refresh_provider_for_route("auto", "https://unknown.example.com/v1") == "auto"