The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gemini): verify alias routing and compatible endpoint controls
Teknium1eb1b795b5ea
diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.pyindex b5483643d86..52c7762d9be 100644--- a/agent/agent_runtime_helpers.py+++ b/agent/agent_runtime_helpers.py@@ -1705,10 +1705,8 @@ def create_openai_client(agent, client_kwargs: dict, *, reason: str, shared: booagent.provider, reason, shared, agent._client_log_context(),)return provider_client- # Aliases of the "gemini" profile (e.g. a "google" fallback_providers entry) must route- # through the native client too, else thinking_config gets sent unnested to the raw REST- # endpoint and Google 400s with "Unknown name 'thinking_config': Cannot find field." (#hermes-thinking-config-fallback)- if agent.provider in {"gemini", "google", "google-gemini", "google-ai-studio"}:+ from agent.auxiliary_client import _GEMINI_NATIVE_PROVIDER_NAMES+ if agent.provider in _GEMINI_NATIVE_PROVIDER_NAMES:client = _gemini_native_client(agent, client_kwargs, httpx_verify, reason=reason, shared=shared)if client is not None:return clientdiff --git a/tests/agent/test_gemini_alias_native_route.py b/tests/agent/test_gemini_alias_native_route.pynew file mode 100644index 00000000000..f35b30097f4--- /dev/null+++ b/tests/agent/test_gemini_alias_native_route.py@@ -0,0 +1,30 @@+"""Provider aliases preserve the native-vs-compatible client boundary."""+from types import SimpleNamespace++from openai import OpenAI++from agent.agent_runtime_helpers import create_openai_client+from agent.gemini_native_adapter import GeminiNativeClient+from providers import get_provider_profile+++def test_gemini_aliases_preserve_native_endpoint_selection():+ profile = get_provider_profile("gemini")+ for provider in (profile.name, *profile.aliases):+ for base_url, expected in (+ ("https://generativelanguage.googleapis.com/v1beta", GeminiNativeClient),+ ("https://example.invalid/v1", OpenAI),+ ):+ agent = SimpleNamespace(+ provider=provider, model="gemini-flash-latest",+ _client_log_context=lambda: "test",+ _build_keepalive_http_client=lambda *a, **k: None,+ )+ client = create_openai_client(+ agent, {"api_key": "test-key", "base_url": base_url},+ reason="fallback", shared=False,+ )+ try:+ assert isinstance(client, expected), (provider, base_url, type(client))+ finally:+ client.close()diff --git a/website/docs/user-guide/features/fallback-providers.md b/website/docs/user-guide/features/fallback-providers.mdindex 51a9ea066bb..dc0b01f5e5c 100644--- a/website/docs/user-guide/features/fallback-providers.md+++ b/website/docs/user-guide/features/fallback-providers.md@@ -39,6 +39,11 @@ fallback_providers:Each entry requires both `provider` and `model`. Entries missing either field are ignored.+Gemini fallback entries accept `gemini`, `google`, `google-gemini`, and+`google-ai-studio`. On Google's native API endpoint, all use the native Gemini+client, including its `generationConfig.thinkingConfig` translation. A custom+OpenAI-compatible base URL continues to use the compatible client instead.+:::note `fallback_model` vs `fallback_providers``fallback_providers` (plural, list) is the current config shape and supports multiple fallbacks tried in order. `fallback_model` (singular) is the legacy single-fallback key — Hermes still honors it for back-compat, but `hermes fallback` writes the current `fallback_providers` key and migrates legacy config on write. When both are set, `fallback_providers` takes priority.:::