gooddata-eval 1.80.1.dev9__py3-none-any.whl → 1.80.1.dev10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -919,20 +919,70 @@ def _normalize_expected_output(expected: dict) -> CatalogMetricAlert:
919
919
  )
920
920
 
921
921
 
922
- def _extract_alert_call(tool_call_events: list[ToolCallEvent]) -> tuple[str | None, dict, bool]:
923
- """Return (alert_id, args, tool_called). tool_called=True whenever create_metric_alert appears."""
922
+ def _alert_call_failed(result: dict | None) -> bool:
923
+ """Whether a ``create_metric_alert`` result reports an error, so the call created nothing.
924
+
925
+ An MCP error carries ``isError``. gen-ai's tool registry reports rejected arguments and a
926
+ failed execution as ``{"success": false, "error": ...}`` instead, with no ``isError``.
927
+ """
928
+ if not isinstance(result, dict):
929
+ return False
930
+ data = result.get("data")
931
+ payloads = [result, data] if isinstance(data, dict) else [result]
932
+ return any(p.get("isError") or p.get("success") is False for p in payloads)
933
+
934
+
935
+ def _created_alert_id(result: dict | None) -> str | None:
936
+ """Server-assigned id of the automation a call created: it lives in the result, not the arguments."""
937
+ if not isinstance(result, dict):
938
+ return None
939
+ data = result.get("data")
940
+ alert_id = result.get("id") or (data.get("id") if isinstance(data, dict) else None)
941
+ return alert_id if isinstance(alert_id, str) and alert_id else None
942
+
943
+
944
+ @dataclass
945
+ class _AlertCalls:
946
+ """Every ``create_metric_alert`` call of a turn, read for scoring and for cleanup."""
947
+
948
+ called: bool = False
949
+ """The agent called the tool at least once."""
950
+ created: bool = False
951
+ """At least one call did not report an error."""
952
+ created_ids: list[str] = field(default_factory=list)
953
+ """Ids of every alert the calls created; each one is deleted after the run."""
954
+ args: dict = field(default_factory=dict)
955
+ """Arguments of the first call that did not fail, else of the last call."""
956
+ alert_id: str | None = None
957
+ """Id of the alert the call in ``args`` created, None when that call failed or its result has no id."""
958
+
959
+
960
+ def _extract_alert_calls(tool_call_events: list[ToolCallEvent]) -> _AlertCalls:
961
+ """Read every ``create_metric_alert`` call, not only the first.
962
+
963
+ The agent may retry after an error. Reading only the first call scored the arguments of a
964
+ call that failed and missed the id of the retry that succeeded, so that alert leaked into
965
+ the workspace (QA-29886). The run is scored on the first call that did not fail, which is
966
+ the first call whenever none failed, as before.
967
+ """
968
+ calls = _AlertCalls()
924
969
  for tc in tool_call_events:
925
- if tc.function_name == "create_metric_alert":
926
- args = tc.parsed_arguments() or {}
927
- alert_id: str | None = None
928
- if tc.result:
929
- try:
930
- result_data = json.loads(tc.result)
931
- alert_id = result_data.get("id") or (result_data.get("data") or {}).get("id")
932
- except Exception:
933
- pass
934
- return alert_id, args, True
935
- return None, {}, False
970
+ if tc.function_name != "create_metric_alert":
971
+ continue
972
+ calls.called = True
973
+ args = tc.parsed_arguments() or {}
974
+ result = tc.parsed_result()
975
+ if _alert_call_failed(result):
976
+ if not calls.created:
977
+ calls.args = args
978
+ continue
979
+ alert_id = _created_alert_id(result)
980
+ if alert_id is not None:
981
+ calls.created_ids.append(alert_id)
982
+ if not calls.created:
983
+ calls.created = True
984
+ calls.args, calls.alert_id = args, alert_id
985
+ return calls
936
986
 
937
987
 
938
988
  def render_alert_proposal(proposal: dict) -> str:
@@ -940,16 +990,20 @@ def render_alert_proposal(proposal: dict) -> str:
940
990
 
941
991
  The alert skill's confirmation step deliberately emits no text part (GDAI-2032) — the
942
992
  prompt and the CTA live only in the proposal payload, which the frontend renders as a
943
- widget. Dumping the payload (rather than prose) keeps recipients, condition, trigger and
944
- dashboard visible so the simulated user can still verify them against its goal, and does
945
- not need updating whenever ``AlertProposal`` grows a field.
993
+ widget. Dumping the payload (rather than prose) keeps recipients, condition, trigger,
994
+ filters and dashboard visible so the simulated user can still verify them against its
995
+ goal, and does not need updating whenever ``AlertProposal`` grows a field.
946
996
  """
947
997
  cta = proposal.get("cta") or "Should I create this alert?"
948
998
  summary = {k: v for k, v in proposal.items() if k != "cta"}
949
999
  alert = dict(summary.get("alert") or {})
950
- # The AFM execution block is opaque wire dicts — noise that would crowd out the fields
951
- # the simulated user actually has to check.
952
- alert.pop("execution", None)
1000
+ # `execution` is the only place a proposal carries its filters, which rule 3 of the simulated
1001
+ # user checks. Hoisting them keeps them visible (QA-29886). The rest stays out: the measures
1002
+ # repeat `condition`, and the simulated user is told nothing about group-bys, so a date
1003
+ # group-by would only read as a time window rule 5 tells it to refuse.
1004
+ execution = alert.pop("execution", None)
1005
+ if isinstance(execution, dict):
1006
+ alert["filters"] = execution.get("filters") or []
953
1007
  if "alert" in summary:
954
1008
  # Key off presence, not truthiness: an alert whose only key was `execution` must
955
1009
  # still be replaced, otherwise the original (execution-bearing) dict survives.
@@ -1002,12 +1056,12 @@ def run_agentic_alert_skill(
1002
1056
  sdk = GoodDataSdk.create(host, token)
1003
1057
 
1004
1058
  def _run_once(conv_id: str) -> AlertRunResult:
1005
- alert_id_to_delete: str | None = None
1059
+ alert_ids_to_delete: list[str] = []
1006
1060
  run_started = time.monotonic()
1007
1061
  try:
1008
1062
  alert_id: str | None = None
1009
1063
  actual_args: dict = {}
1010
- tool_called = False
1064
+ alert_created = False
1011
1065
  reasoning_steps: list[str] = []
1012
1066
  response_id: str | None = None
1013
1067
  all_tool_call_events: list[ToolCallEvent] = []
@@ -1036,7 +1090,7 @@ def run_agentic_alert_skill(
1036
1090
  # discarding every K-run already completed along with any exit_reason.
1037
1091
  print(f"[CHAT] send_message failed for conversation {conv_id}: {exc}")
1038
1092
  # The stream can break AFTER create_metric_alert already succeeded
1039
- # server-side. That id only ever reached alert_id_to_delete from the
1093
+ # server-side. That id only ever reached alert_ids_to_delete from the
1040
1094
  # normal path below, so breaking here left the alert in the workspace for
1041
1095
  # the `finally` cleanup to miss -- a real object leaking out of a failed
1042
1096
  # run, not a reporting gap.
@@ -1044,9 +1098,7 @@ def run_agentic_alert_skill(
1044
1098
  if partial is not None:
1045
1099
  reasoning_steps.extend(partial.reasoning_steps or [])
1046
1100
  response_id = partial.response_id or response_id
1047
- partial_alert_id, _, partial_tool_called = _extract_alert_call(partial.tool_call_events or [])
1048
- if partial_tool_called:
1049
- alert_id_to_delete = partial_alert_id
1101
+ alert_ids_to_delete.extend(_extract_alert_calls(partial.tool_call_events or []).created_ids)
1050
1102
  exit_reason = chat_failure_exit(exc)
1051
1103
  break
1052
1104
  # `turns_used` counts attempts (set above, so a failed send still shows the
@@ -1064,14 +1116,24 @@ def run_agentic_alert_skill(
1064
1116
  )
1065
1117
  all_tool_call_events.extend(chat_result.tool_call_events or [])
1066
1118
  all_reasoning_step_events.extend(chat_result.reasoning_step_events or [])
1067
- alert_id, actual_args, tool_called = _extract_alert_call(chat_result.tool_call_events or [])
1068
- if tool_called:
1069
- alert_id_to_delete = alert_id
1119
+ calls = _extract_alert_calls(chat_result.tool_call_events or [])
1120
+ alert_ids_to_delete.extend(calls.created_ids)
1121
+ if calls.created:
1122
+ alert_id, actual_args = calls.alert_id, calls.args
1123
+ alert_created = True
1070
1124
  exit_reason = LoopExit.SUCCESS
1071
1125
  break
1126
+ if calls.called:
1127
+ # Every call reported an error, so nothing was created. Scoring their arguments
1128
+ # would pass a run whose creation failed, and ending here would label it a
1129
+ # success. The agent gets the next turn to recover, as with a user, and the
1130
+ # failed arguments are kept for triage.
1131
+ actual_args = calls.args
1072
1132
  response_text = render_turn_for_simulated_user(chat_result)
1073
- # Stop if agent gave a completely empty response (stuck)
1074
- if not response_text and not chat_result.tool_call_events:
1133
+ # Stop if the agent gave a completely empty response (stuck), or wrote nothing after
1134
+ # every create call failed: the rendered turn holds no tool results, so the simulated
1135
+ # user would be asked to answer an empty message.
1136
+ if not response_text and (calls.called or not chat_result.tool_call_events):
1075
1137
  exit_reason = LoopExit.AGENT_SILENT
1076
1138
  break
1077
1139
  # Stop before generating a follow-up for the last iteration
@@ -1100,23 +1162,23 @@ def run_agentic_alert_skill(
1100
1162
  current_question = follow_up
1101
1163
 
1102
1164
  ev = AlertEvaluation(
1103
- alert_created=tool_called,
1104
- operator_correct=tool_called and expected.operator == actual_args.get("operator"),
1105
- threshold_correct=tool_called and _check_threshold(expected, actual_args),
1106
- trigger_correct=tool_called and _check_trigger(expected, actual_args),
1107
- filters_correct=tool_called and _check_filters(expected, actual_args),
1108
- metric_correct=tool_called and _check_metric(expected, actual_args),
1109
- recipients_correct=tool_called
1165
+ alert_created=alert_created,
1166
+ operator_correct=alert_created and expected.operator == actual_args.get("operator"),
1167
+ threshold_correct=alert_created and _check_threshold(expected, actual_args),
1168
+ trigger_correct=alert_created and _check_trigger(expected, actual_args),
1169
+ filters_correct=alert_created and _check_filters(expected, actual_args),
1170
+ metric_correct=alert_created and _check_metric(expected, actual_args),
1171
+ recipients_correct=alert_created
1110
1172
  and _check_recipients(expected, actual_args, sdk=sdk, current_user_id=current_user_id),
1111
- attributes_correct=tool_called and _check_attributes(expected, actual_args),
1112
- granularity_correct=tool_called and _check_granularity(expected, actual_args),
1173
+ attributes_correct=alert_created and _check_attributes(expected, actual_args),
1174
+ granularity_correct=alert_created and _check_granularity(expected, actual_args),
1113
1175
  comparison_correct=None
1114
1176
  if expected.comparison is None
1115
- else tool_called and _check_comparison(expected, actual_args),
1116
- title_correct=None if expected.title is None else tool_called and _check_title(expected, actual_args),
1177
+ else alert_created and _check_comparison(expected, actual_args),
1178
+ title_correct=None if expected.title is None else alert_created and _check_title(expected, actual_args),
1117
1179
  dashboard_correct=None
1118
1180
  if expected.dashboard_id is None
1119
- else tool_called and _check_dashboard(expected, actual_args),
1181
+ else alert_created and _check_dashboard(expected, actual_args),
1120
1182
  )
1121
1183
  return AlertRunResult(
1122
1184
  conversation_id=conv_id,
@@ -1134,8 +1196,8 @@ def run_agentic_alert_skill(
1134
1196
  run_latency_s=time.monotonic() - run_started,
1135
1197
  )
1136
1198
  finally:
1137
- if alert_id_to_delete:
1138
- _delete_alert(sdk, workspace_id, alert_id_to_delete)
1199
+ for created_id in dict.fromkeys(alert_ids_to_delete):
1200
+ _delete_alert(sdk, workspace_id, created_id)
1139
1201
 
1140
1202
  try:
1141
1203
  conv_id_0 = initial_conversation_id if initial_conversation_id is not None else client.create_conversation()
@@ -28,7 +28,7 @@ def _extract_metric_id(metric_str: str) -> str | None:
28
28
  def _extract_automation_id(tool_event) -> str | None:
29
29
  """Real server-assigned id of the automation this call created.
30
30
 
31
- Mirrors ``core/agentic/alert_skill.py``'s ``_extract_alert_call`` — the id
31
+ Mirrors ``core/agentic/alert_skill.py``'s ``_created_alert_id`` — the id
32
32
  lives in the tool *result* (what the server assigned), not the tool call
33
33
  *arguments* (what the agent asked for).
34
34
  """
@@ -39,7 +39,8 @@ class LoopExit(str, Enum):
39
39
  """The agent produced the expected output; the loop broke early."""
40
40
 
41
41
  AGENT_SILENT = "agent_silent"
42
- """The agent returned neither text nor a tool call -- genuinely stuck."""
42
+ """The agent returned neither text nor a tool call -- genuinely stuck. The alert skill also
43
+ ends here when the agent writes nothing after every ``create_metric_alert`` call failed."""
43
44
 
44
45
  BUDGET_EXHAUSTED = "budget_exhausted"
45
46
  """The loop hit ``max_iterations`` without the agent producing its output. Says nothing
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: gooddata-eval
3
- Version: 1.80.1.dev9
3
+ Version: 1.80.1.dev10
4
4
  Summary: Evaluate the GoodData AI agent against your own questions and models.
5
5
  Project-URL: Source, https://github.com/gooddata/gooddata-python-sdk
6
6
  Author-email: GoodData <support@gooddata.com>
@@ -18,7 +18,7 @@ Classifier: Topic :: Scientific/Engineering
18
18
  Classifier: Topic :: Software Development
19
19
  Classifier: Typing :: Typed
20
20
  Requires-Python: >=3.11
21
- Requires-Dist: gooddata-sdk~=1.80.1.dev9
21
+ Requires-Dist: gooddata-sdk~=1.80.1.dev10
22
22
  Requires-Dist: httpx<1.0,>=0.27
23
23
  Requires-Dist: jsonpatch<2.0,>=1.33
24
24
  Requires-Dist: orjson<4.0.0,>=3.9.15
@@ -10,7 +10,7 @@ gooddata_eval/core/config.py,sha256=hla5t294uHC5Q9bzrhPjsdkwEcetLsEH-GqGAhs94b4,
10
10
  gooddata_eval/core/connection.py,sha256=mh-Do5-Ti0-DXXikfCIH10eTTUbKuZUAS_sLoPNDJ5I,1229
11
11
  gooddata_eval/core/granularity.py,sha256=CbniwgxtVj0oyf41UjeeZbBzOpeisSBlAfdkL79e6O0,3932
12
12
  gooddata_eval/core/interaction.py,sha256=hJxrTNpEN7s0fctdJGW511bf_thfXJJ1Dn3E2cGgtP0,2224
13
- gooddata_eval/core/models.py,sha256=4-b_TzHAYKP19VSwmLhQYMAUnNuYyaDFxN1csK2koag,30696
13
+ gooddata_eval/core/models.py,sha256=Fkm50EJlxbm9rA_FRxm6B_9RAiRuvbqj0xGEL1Xg26M,30810
14
14
  gooddata_eval/core/number_format.py,sha256=bQv3YqlMtBHNSMZx2_qGMWXFDdeXNkAGVg3WFIKUd-k,9264
15
15
  gooddata_eval/core/outcome.py,sha256=Ax9uAgxUlKSATWd_xFp959jijVhsNoH0oSmRyOnXsWA,6509
16
16
  gooddata_eval/core/runner.py,sha256=IrMOVFUd-WkcYLhYiQYeEzZjacYKnjao3GBm6JGtisQ,21605
@@ -33,7 +33,7 @@ gooddata_eval/core/agentic/_outcome.py,sha256=AL1ULyD9zpC8A-MhyLp2CW68Rnezl39heR
33
33
  gooddata_eval/core/agentic/_search_expectation.py,sha256=I_NSxfuT0r5uOwvGe6hCcgpeGvdtLAcCki_RgELJaes,13964
34
34
  gooddata_eval/core/agentic/_trace_linker.py,sha256=Bc-UOPB3bcJqb6kmHnkMnbNVbZPPB7Dn5awM7bNm-qY,15851
35
35
  gooddata_eval/core/agentic/agent_switcher.py,sha256=DWkv2iB0RGzM4-wLkhoru4b8fPYHDwYaBPcSVcjZ74g,37636
36
- gooddata_eval/core/agentic/alert_skill.py,sha256=N0gWOPiETnA83wLOoDZ4QNjcxXm2oDMv7x9CNEuemAg,63623
36
+ gooddata_eval/core/agentic/alert_skill.py,sha256=GLmvEVxsiBhqL-RkZ_kKp6MFYQmIRyP-0iXCqSJA2BE,66730
37
37
  gooddata_eval/core/agentic/anomaly_detection.py,sha256=XMd0zsS3hgASJND6UwhNXdoBXUzDm_pMuGS2Dv-1FNg,30053
38
38
  gooddata_eval/core/agentic/conversation.py,sha256=AC-k4ju2Ic_X8UkERLWHstNKKBGTtrj7p-Ld-82K8T8,75946
39
39
  gooddata_eval/core/agentic/dashboard_skill.py,sha256=eHQWVcoYIBc0QCJnu4VmpZVMffNHckSCYuBo67a-asE,132462
@@ -66,7 +66,7 @@ gooddata_eval/core/evaluators/_llm_judge.py,sha256=A5lukKt8IG26BoN_oU2DvkOHAQwV0
66
66
  gooddata_eval/core/evaluators/_maql.py,sha256=XpamaPXixBTpiMGrZYnV0t_4DEmuPSa32PqQOk0RG_k,4348
67
67
  gooddata_eval/core/evaluators/_rubric.py,sha256=hHBsE52M2E2JaRuN07Vs1ST0nVaq44kft5QqgoaO3-g,4248
68
68
  gooddata_eval/core/evaluators/_text_utils.py,sha256=GWGJB6uJFhwZTiy4QcthXd2z_GtUdh5p6gZqHVnfBo4,1816
69
- gooddata_eval/core/evaluators/alert_skill.py,sha256=I5Zgo972JR6WhqYeDZ8ttncBr8tehlklFQhukqPdy8M,6203
69
+ gooddata_eval/core/evaluators/alert_skill.py,sha256=iLDV8ZSAMjgiGxi6i7RpdVzcMXVihEn5yiz4JqV2wVE,6201
70
70
  gooddata_eval/core/evaluators/base.py,sha256=H9EMG57jX0W4vmasgJNUhwRjtGRuVBik2MhN9ZDV1Jk,777
71
71
  gooddata_eval/core/evaluators/catalog_metadata.py,sha256=knj_7N_nEznHHnJMnBVYsNGMqA4GYQLmfGnQHUkIg9Y,8868
72
72
  gooddata_eval/core/evaluators/general_question.py,sha256=3YIuCH7t_Ih6Of8hozRUHd6Vaum2X3KxhKFCjzthLHg,2170
@@ -95,8 +95,8 @@ gooddata_eval/core/summary/http_client.py,sha256=Umae42fiiJQ0e4hv63NRROHYvcFAGgX
95
95
  gooddata_eval/core/takeaway/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
96
96
  gooddata_eval/core/takeaway/evaluate.py,sha256=AjS_rCHWUSJKv0jfEfL0-dVPoDaf3RkGdmeZiIwjd6A,11312
97
97
  gooddata_eval/core/takeaway/http_client.py,sha256=YMfafOcHJ184i49Qoh0ZNPKKTMKBSgeDUM4zk_H3yM8,3955
98
- gooddata_eval-1.80.1.dev9.dist-info/METADATA,sha256=DTZEynYDbunL3pEvDS2ykVfMZ_xrohYiLzQumKPG62o,73706
99
- gooddata_eval-1.80.1.dev9.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
100
- gooddata_eval-1.80.1.dev9.dist-info/entry_points.txt,sha256=28nFp5Viknx4haPYgzK9QHlwPFfC6rPF6RmjC2ht8EI,56
101
- gooddata_eval-1.80.1.dev9.dist-info/licenses/LICENSE.txt,sha256=LVfVlC9maU3K9lgMwdZnClQQsOIbOekdcdVKr9qzJtk,256836
102
- gooddata_eval-1.80.1.dev9.dist-info/RECORD,,
98
+ gooddata_eval-1.80.1.dev10.dist-info/METADATA,sha256=uvCc2vZ0ty6wVDcTF4jsodLFoaNUrTkv9p0jav4BSpU,73708
99
+ gooddata_eval-1.80.1.dev10.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
100
+ gooddata_eval-1.80.1.dev10.dist-info/entry_points.txt,sha256=28nFp5Viknx4haPYgzK9QHlwPFfC6rPF6RmjC2ht8EI,56
101
+ gooddata_eval-1.80.1.dev10.dist-info/licenses/LICENSE.txt,sha256=LVfVlC9maU3K9lgMwdZnClQQsOIbOekdcdVKr9qzJtk,256836
102
+ gooddata_eval-1.80.1.dev10.dist-info/RECORD,,