fix: count reasoning-only liveness responses as healthy
Build and deploy / build-deploy (push) Waiting to run

This commit is contained in:
2026-10-27 12:22:16 +00:00
parent e8177c1270
commit 2fc17ef40b
3 changed files with 35 additions and 18 deletions
+4 -3
View File
@@ -654,10 +654,11 @@ def api_check(model_id: str):
# упадёт, реально потраченные токены сохраняются в checks.
usage = extract_usage(resp)
choice = resp["choices"][0]
content = choice["message"].get("content")
ok = isinstance(content, str) and bool(content.strip())
message = choice["message"]
ok = any(isinstance(message.get(field), str) and message[field].strip()
for field in ("content", "reasoning_content"))
if not ok:
error = f"Empty text response (finish_reason={choice.get('finish_reason')})"
error = f"Empty content and reasoning (finish_reason={choice.get('finish_reason')})"
except Exception as e:
error = f"{type(e).__name__}: {e}"
print(f"[check] {model_id}: {error}")
+8 -5
View File
@@ -51,13 +51,16 @@ def check_model(model_id: str) -> tuple[bool, int | None, str | None, dict]:
resp = json.loads(r.read())
# Usage — до любой валидации контента.
usage = extract_usage(resp)
# HTTP 200 может содержать только reasoning и content=null.
# Это не успешный текстовый ответ и не ошибка Python.
# HTTP 200 может содержать только reasoning при исчерпании лимита.
# Наличие текста в любом из двух полей достаточно для liveness.
choice = resp["choices"][0]
content = choice["message"].get("content")
ok = isinstance(content, str) and bool(content.strip())
message = choice["message"]
# Liveness: непустой текст в content ИЛИ reasoning_content.
# Usage само по себе не доказывает, что модель выдала ответ.
ok = any(isinstance(message.get(field), str) and message[field].strip()
for field in ("content", "reasoning_content"))
if not ok:
error = f"Empty text response (finish_reason={choice.get('finish_reason')})"
error = f"Empty content and reasoning (finish_reason={choice.get('finish_reason')})"
except Exception as e:
error = f"{type(e).__name__}: {e}"
print(f" ✗ {model_id}: {error}", file=sys.stderr)