Interactions retries ignore the documented `initial_delay` and `max_delay` defaults
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
阅读 types.py 中 HttpRetryOptions 默认值附近的内容,以及 _gaos/google_genai.py 中 _DEFAULT_INITIAL_INTERVAL_MS 附近的内容,然后将它们与 _api_client 中的重试默认值进行比较。Issue 报告称 client.interactions 和 client.models 的重试延迟和抖动不同;请判断 Interactions 是否应使用共享默认值,并使用提供的无网络复现方法验证重试计划。
由索引模型根据 Issue 内容生成。
描述
client.interactions backs off half as long as client.models when initial_delay and max_delay are left unset, so the same HttpRetryOptions give two different retry schedules in one client.
Repro at afb10e8 (3.0.0), with no network and no real key:
import time, httpx2
from google import genai
from google.genai import types
stamps = []
def handler(request):
stamps.append(time.monotonic())
return httpx2.Response(503, json={"error": {"code": 503, "message": "unavailable", "status": "UNAVAILABLE"}})
def gaps():
return [round(b - a, 1) for a, b in zip(stamps, stamps[1:])]
retry = types.HttpRetryOptions(attempts=4, jitter=0) # jitter=0 keeps the gaps exact; delays left unset
client = genai.Client(
api_key="test",
http_options=types.HttpOptions(
retry_options=retry, httpx_client=httpx2.Client(transport=httpx2.MockTransport(handler))
),
)
for name, call in [
("models.generate_content", lambda: client.models.generate_content(model="gemini-3.8-flash", contents="hi")),
("interactions.create", lambda: client.interactions.create(model="gemini-3.8-flash", input="hi")),
]:
stamps.clear()
try:
call()
except Exception as e:
print(f"{name}: {len(stamps)} requests, gaps {gaps()} s, {type(e).__name__}")
$ python repro.py
models.generate_content: 4 requests, gaps [1.0, 2.0, 4.0] s, ServerError
interactions.create: 4 requests, gaps [0.5, 1.0, 2.0] s, InternalServerError
HttpRetryOptions documents initial_delay as "If not specified, default to 1.0 second" and max_delay as "default to 60.0 seconds" (types.py:2671-2678). The comment above _DEFAULT_INITIAL_INTERVAL_MS in _gaos/google_genai.py calls 0.5 s and 8 s the default, so one of the two contracts is wrong. An unset jitter differs too: Interactions takes up to 25% off each delay, while client.models adds up to 1 s. #3263 already moved the unset attempts onto _api_client._RETRY_ATTEMPTS. I checked the sync client only.
I'd take all three from _api_client (_RETRY_INITIAL_DELAY, _RETRY_MAX_DELAY, _RETRY_JITTER) in the same way. Or are 0.5 s and 8 s meant to stay specific to Interactions?
- 主要语言
- Python
- 星标
- 4.1k
- 派生
- 1.1k
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 99
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googleapis/python-genai 的其他 Issue
-
Test import module that doesn't exist可能已有人在做 @Venkaiahbabuneelam 于 25 天前认领。 未关闭priority: p2 type: bug
难度 2/5 1-3 小时 新手友好度 66/100
googleapis/python-genai#3122 · 6 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Curated history keeps half a user turn when the model turn is invalid可能已有人在做 @Venkaiahbabuneelam 于 34 天前认领。 未关闭priority: p2 type: bug
难度 2/5 1-3 小时 新手友好度 62/100
googleapis/python-genai#3051 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC可能已有人在做 @Venkaiahbabuneelam 于 34 天前认领。 未关闭priority: p2 type: bug
难度 2/5 1-3 小时 新手友好度 82/100
googleapis/python-genai#3044 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
all `client.webhooks` operations fail with API error occurred: Status 404可能已有人在做 @VISHNU0906 今天认领。 未关闭priority: p2 type: bug
难度 3/5 1-2 天 新手友好度 54/100
googleapis/python-genai#3316 ·
维护者通常 1 天内回复
-
Curated chat history ends on an unanswered function_call when the turn after AFC is invalid可能已有人在做 @copybara-service 于 1 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
googleapis/python-genai#3314 ·
维护者通常 1 天内回复
查看 googleapis/python-genai 的全部 Issue
相似的 Issue
-
area: web priority: P1 story
难度 2/5 1-3 小时 新手友好度 76/100
nfiasco/Quant-Time-Machine#151 ·
维护者通常 1 天内回复
-
docs pydanty:is-working
难度 1/5 1-3 小时 新手友好度 85/100
pydantic/pydantic-ai#12892 ·
维护者通常 1 天内回复
-
needs-triage
难度 1/5 1-3 小时 新手友好度 72/100
Azure/azure-sdk-for-python#49886 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
[Core] Deprecated(error=True) raises only on the first call; later calls run the removed API可能已有人在做 @wguo7 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
ray-project/ray#67965 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
btclib-org/btclib#3006 ·
维护者通常 1 天内回复