2323 log_gate_scores ,
2424 stamp_gate_metadata ,
2525)
26+ from gooddata_eval .core .agentic ._outcome import agentic_detail , agentic_success , raise_agentic_failure
2627from gooddata_eval .core .agentic ._trace_linker import (
2728 RunIdentity ,
2829 RunTraceContext ,
@@ -700,7 +701,8 @@ class AlertRunResult:
700701 # also report operator/threshold/metric/recipients as False.
701702 exit_reason : LoopExit = LoopExit .BUDGET_EXHAUSTED
702703 turns_used : int = 0
703- # This run's own wall time, from just before its chat call to the end of its scoring.
704+ # This run's own wall time, across all its turns -- mirrors the single-shot
705+ # path's best_run_latency_s (see core/runner.py's _run_one_item).
704706 run_latency_s : float = 0.0
705707
706708
@@ -975,6 +977,7 @@ def run_agentic_alert_skill(
975977
976978 def _run_once (conv_id : str ) -> AlertRunResult :
977979 alert_id_to_delete : str | None = None
980+ run_started = time .monotonic ()
978981 try :
979982 alert_id : str | None = None
980983 actual_args : dict = {}
@@ -1260,9 +1263,25 @@ def _write_scores(ctx: RunTraceContext) -> None:
12601263
12611264 best = summary .best
12621265 ev = best .eval
1263- # max_iterations is the same for every run, so it stays at the item level rather than
1264- # being repeated into each failing run's detail.
1265- detail = {** _run_detail (best ), "max_iterations" : max_iterations }
1266+ detail = agentic_detail (
1267+ best .tool_call_events ,
1268+ best .reasoning_step_events ,
1269+ alert_created = ev .alert_created ,
1270+ operator_correct = ev .operator_correct ,
1271+ threshold_correct = ev .threshold_correct ,
1272+ trigger_correct = ev .trigger_correct ,
1273+ filters_correct = ev .filters_correct ,
1274+ metric_correct = ev .metric_correct ,
1275+ recipients_correct = ev .recipients_correct ,
1276+ attributes_correct = ev .attributes_correct ,
1277+ granularity_correct = ev .granularity_correct ,
1278+ actual_alert_arguments = best .actual_alert_arguments ,
1279+ # Why the loop stopped. alert_created=False alone cannot tell a refusal from a run
1280+ # that hit max_iterations while still on track -- see LoopExit.
1281+ exit_reason = best .exit_reason .value ,
1282+ turns_used = best .turns_used ,
1283+ max_iterations = max_iterations ,
1284+ )
12661285 # Same predicate runs_passed is taken over, so an item's failed_runs and its counts
12671286 # cannot disagree about which runs failed.
12681287 failed_runs = build_failed_runs (
@@ -1273,29 +1292,34 @@ def _write_scores(ctx: RunTraceContext) -> None:
12731292
12741293 if not gate_passed (gate , pass_at_k = summary .pass_at_k , pass_power_k = summary .pass_power_k ):
12751294 gate_note = gate_failure_note (gate , runs_passed , runs_effective )
1276- exc = AlertSkillAssertionError (
1295+ raise_agentic_failure (
1296+ AlertSkillAssertionError ,
12771297 f"Alert skill assertion failed. { gate_note } strict_pass={ ev .strict_pass } . "
1278- + ", " .join (f"{ name } ={ value } " for name , value in ev .checks ().items ())
1279- + f". Actual args: { best .actual_alert_arguments } "
1298+ f"alert_created={ ev .alert_created } , operator_correct={ ev .operator_correct } , "
1299+ f"threshold_correct={ ev .threshold_correct } , trigger_correct={ ev .trigger_correct } , "
1300+ f"filters_correct={ ev .filters_correct } , metric_correct={ ev .metric_correct } , "
1301+ f"recipients_correct={ ev .recipients_correct } , "
1302+ f"attributes_correct={ ev .attributes_correct } , "
1303+ f"granularity_correct={ ev .granularity_correct } . "
1304+ f"Actual args: { best .actual_alert_arguments } " ,
1305+ reasoning_steps = best .reasoning_steps ,
1306+ conversation_id = best .conversation_id ,
1307+ response_id = best .response_id ,
1308+ detail = detail ,
1309+ runs_passed = runs_passed ,
1310+ runs_effective = runs_effective ,
1311+ failed_runs = failed_runs ,
1312+ run_latencies_s = [r .run_latency_s for r in summary .run_results ],
1313+ best_run_latency_s = best .run_latency_s ,
12801314 )
1281- exc .reasoning_steps = best .reasoning_steps
1282- exc .conversation_id = best .conversation_id
1283- exc .response_id = best .response_id
1284- exc .detail = detail
1285- exc .runs_passed = runs_passed
1286- exc .runs_effective = runs_effective
1287- exc .failed_runs = failed_runs
1288- exc .run_latencies_s = [r .run_latency_s for r in summary .run_results ]
1289- raise exc
1290- return AgenticEvalOutcome (
1291- runs_passed = runs_passed ,
1292- runs_effective = runs_effective ,
1315+ return agentic_success (
12931316 reasoning_steps = best .reasoning_steps ,
12941317 conversation_id = best .conversation_id ,
12951318 response_id = best .response_id ,
12961319 detail = detail ,
1297- # Also on the success path: pass@K clears the gate with one passing run, so a
1298- # 1/3 item reports success while two of its runs failed for reasons worth reading.
1320+ runs_passed = runs_passed ,
1321+ runs_effective = runs_effective ,
12991322 failed_runs = failed_runs ,
13001323 run_latencies_s = [r .run_latency_s for r in summary .run_results ],
1324+ best_run_latency_s = best .run_latency_s ,
13011325 )
0 commit comments