Skip to content

Commit e56f69a

Browse files
committed
fix: Isolate tracking failures and log failed judge evaluations
Wrap tracker.track_judge_result() in try/except inside _run_and_track so a tracking failure (e.g., shutdown LD client) does not propagate through the wrapper task and destroy the evaluation results that were successfully computed. Restores the resilience of the previous add_done_callback approach, which asyncio handled with isolation. Also log a warning when a judge evaluation fails (r.success is False) so failures are visible rather than silently skipped.
1 parent 381cf75 commit e56f69a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/sdk/server-ai/src/ldai/managed_model.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
from typing import List, Optional
33

4+
from ldai import log
45
from ldai.models import AICompletionConfig, LDMessage
56
from ldai.providers.model_runner import ModelRunner
67
from ldai.providers.types import JudgeResult, ModelResponse
@@ -68,7 +69,12 @@ async def _run_and_track(eval_task: asyncio.Task) -> List[JudgeResult]:
6869
results = await eval_task
6970
for r in results:
7071
if r.success:
71-
tracker.track_judge_result(r)
72+
try:
73+
tracker.track_judge_result(r)
74+
except Exception:
75+
pass
76+
else:
77+
log.warning("Judge evaluation failed: %s", r.error_message)
7278
return results
7379

7480
return asyncio.create_task(_run_and_track(evaluator_task))

0 commit comments

Comments
 (0)