fix simulation reporting and research resilience

This commit is contained in:
2026-09-28 15:43:23 +08:00
parent 23297be2d7
commit a428214c53
25 changed files with 1488 additions and 244 deletions
+15
View File
@@ -139,6 +139,21 @@ class LLMClient:
)
return content.strip()
except Exception as e:
# Provider validation/policy responses are deterministic for
# the same payload. Retrying them only adds latency and can
# multiply the provider-side rejection count. Keep retries
# for transient network, timeout, and 5xx failures.
status_code = getattr(e, "status_code", None)
if status_code in {400, 401, 403, 404, 422}:
await self._record_purpose(purpose, time.monotonic() - t0, ok=False)
logger.error(
"LLM 请求不可重试(用途=%s,HTTP %s,耗时=%.2f秒):%s",
purpose or "-",
status_code,
time.monotonic() - t0,
e,
)
raise
if attempt == retries - 1:
await self._record_purpose(purpose, time.monotonic() - t0, ok=False)
logger.error(