diff --git a/app/agent/llm/discovery.py b/app/agent/llm/discovery.py index f65435667..0b1050fab 100644 --- a/app/agent/llm/discovery.py +++ b/app/agent/llm/discovery.py @@ -397,9 +397,15 @@ class _ProviderDiscovery: connect_timeout=10, trust_env=False, ) + # google-genai 的 aiohttp 请求已经显式传入 timeout,不能再从 + # async_client_args 透传同名参数,否则会触发重复关键字异常。 + async_client_args = { + key: value for key, value in client_args.items() if key != "timeout" + } http_options = HttpOptions( + timeout=15_000, client_args=client_args, - async_client_args=client_args, + async_client_args=async_client_args, ) client = genai.Client(api_key=api_key, http_options=http_options) diff --git a/tests/test_llm_provider_transport.py b/tests/test_llm_provider_transport.py index 3948d9a73..ae849dbdb 100644 --- a/tests/test_llm_provider_transport.py +++ b/tests/test_llm_provider_transport.py @@ -136,8 +136,10 @@ def test_google_model_client_uses_adapter_args_and_closes_both_clients( client = captured["client"] http_options = captured["http_options"] assert result[0]["id"] == "gemini-test" + assert http_options.timeout == 15_000 assert http_options.client_args["trust_env"] is False assert http_options.async_client_args["trust_env"] is False + assert "timeout" not in http_options.async_client_args assert any( key in http_options.async_client_args for key in ("proxy", "proxies") )