fix(llm): call_id 移入重试循环,每 attempt 独立

消除重试时遥测主键冲突的根因。每次 attempt 独立记录,
parent_call_id 不受影响(循环外固定),更利于事后诊断重试轨迹。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-09 00:12:38 -04:00
parent 5a91f392f0
commit f733c13dd1
2 changed files with 8 additions and 9 deletions
+2 -2
View File
@@ -197,9 +197,9 @@ async def test_transient_error_retries_and_records_telemetry():
success_calls = [c for c in telemetry.calls if c.get("error") is None]
assert len(success_calls) == 1
# 所有遥测记录应使用同一个 call_id(Important 2 修复验证
# 每次 attempt 应使用独立的 call_id(根因修复:防遥测主键冲突
call_ids = {c["call_id"] for c in telemetry.calls}
assert len(call_ids) == 1
assert len(call_ids) == 3 # 2 次失败 + 1 次成功 = 3 个独立 call_id
@pytest.mark.asyncio