fix simulation reporting and research resilience
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user