fix(agent): avoid duplicate Google aiohttp timeout

This commit is contained in:
jxxghp
2026-09-11 11:40:21 +08:00
parent e7b1e2c6e1
commit e4831c3530
2 changed files with 9 additions and 1 deletions

View File

@@ -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)

View File

@@ -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")
)