gooddata-eval 1.80.1.dev4__py3-none-any.whl → 1.80.1.dev5__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.
- gooddata_eval/cli/agentic_runner.py +28 -10
- gooddata_eval/core/agentic/_search_expectation.py +310 -0
- gooddata_eval/core/agentic/alert_skill.py +20 -2
- gooddata_eval/core/agentic/search_tool.py +421 -89
- gooddata_eval/core/agentic/visualization.py +14 -5
- {gooddata_eval-1.80.1.dev4.dist-info → gooddata_eval-1.80.1.dev5.dist-info}/METADATA +2 -2
- {gooddata_eval-1.80.1.dev4.dist-info → gooddata_eval-1.80.1.dev5.dist-info}/RECORD +10 -9
- {gooddata_eval-1.80.1.dev4.dist-info → gooddata_eval-1.80.1.dev5.dist-info}/WHEEL +0 -0
- {gooddata_eval-1.80.1.dev4.dist-info → gooddata_eval-1.80.1.dev5.dist-info}/entry_points.txt +0 -0
- {gooddata_eval-1.80.1.dev4.dist-info → gooddata_eval-1.80.1.dev5.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -11,6 +11,7 @@ from typing import Any, TypedDict
|
|
|
11
11
|
|
|
12
12
|
from gooddata_eval.core.agentic._gate import DEFAULT_GATE, EvalGate, normalize_gate
|
|
13
13
|
from gooddata_eval.core.agentic._langfuse import make_langfuse_client
|
|
14
|
+
from gooddata_eval.core.agentic._search_expectation import SEARCH_ARGUMENT_KEYS
|
|
14
15
|
from gooddata_eval.core.agentic._trace_linker import BackgroundTraceLinker, SubmitTraceLink, run_trace_link_inline
|
|
15
16
|
from gooddata_eval.core.agentic.alert_skill import evaluate_agentic_alert_skill
|
|
16
17
|
from gooddata_eval.core.agentic.anomaly_detection import evaluate_agentic_anomaly_detection
|
|
@@ -81,7 +82,8 @@ UNGATED_AGENTIC_TEST_KINDS = frozenset({"agentic_conversation"})
|
|
|
81
82
|
# reads like a model regression.
|
|
82
83
|
#
|
|
83
84
|
# agentic_general_question, agentic_guardrail answer questions only, no tool writes
|
|
84
|
-
# agentic_search search_objects, read-only by definition
|
|
85
|
+
# agentic_search search_objects, read-only by definition; an item
|
|
86
|
+
# with setup_turns runs serially (item_runs_in_parallel)
|
|
85
87
|
# vis_agentic, agentic_visualization visualizations come back as AAC proposals
|
|
86
88
|
# in the chat response; nothing is persisted
|
|
87
89
|
# and neither module has cleanup code
|
|
@@ -115,6 +117,18 @@ def runs_in_parallel(test_kind: str) -> bool:
|
|
|
115
117
|
return test_kind in PARALLEL_SAFE_TEST_KINDS
|
|
116
118
|
|
|
117
119
|
|
|
120
|
+
def item_runs_in_parallel(item: DatasetItem) -> bool:
|
|
121
|
+
"""True for an item of a cleared kind that sends nothing the clearance does not cover.
|
|
122
|
+
|
|
123
|
+
``agentic_search`` is cleared for its search. An item's ``setup_turns`` are free text sent before the question,
|
|
124
|
+
and nothing stops one from asking the agent to save something, so such an item runs serially.
|
|
125
|
+
"""
|
|
126
|
+
if not runs_in_parallel(item.test_kind):
|
|
127
|
+
return False
|
|
128
|
+
eo = item.expected_output
|
|
129
|
+
return not (item.test_kind == "agentic_search" and isinstance(eo, dict) and "setup_turns" in eo)
|
|
130
|
+
|
|
131
|
+
|
|
118
132
|
def _parse_visualization_expected(expected_output: Any) -> list[CreatedVisualization]:
|
|
119
133
|
"""Parse expected_output into a list of CreatedVisualization candidates.
|
|
120
134
|
|
|
@@ -253,15 +267,18 @@ def _dispatch_agentic(
|
|
|
253
267
|
**lf_kw,
|
|
254
268
|
)
|
|
255
269
|
elif kind == "agentic_search":
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
270
|
+
if not isinstance(eo, dict):
|
|
271
|
+
raise ValueError(f"agentic_search expected_output must be an object, got {eo!r}")
|
|
272
|
+
eo_dict = eo
|
|
273
|
+
# Anything but bare search_objects arguments is parsed as an item, so an unknown key fails it.
|
|
274
|
+
is_item_shape = "tool_call" in eo_dict or not eo_dict.keys() <= SEARCH_ARGUMENT_KEYS
|
|
259
275
|
return evaluate_agentic_search_tool(
|
|
260
276
|
host=host,
|
|
261
277
|
token=token,
|
|
262
278
|
workspace_id=workspace_id,
|
|
263
279
|
question=item.question,
|
|
264
|
-
expected_tool_call=
|
|
280
|
+
expected_tool_call=None if is_item_shape else eo_dict,
|
|
281
|
+
expected_output=eo_dict if is_item_shape else None,
|
|
265
282
|
k=k,
|
|
266
283
|
gate=gate,
|
|
267
284
|
agent_id=agent_id,
|
|
@@ -485,7 +502,8 @@ def run_agentic_items(
|
|
|
485
502
|
) -> EvalReport:
|
|
486
503
|
"""Run agentic items through evaluate_agentic_* and return an EvalReport.
|
|
487
504
|
|
|
488
|
-
``concurrency`` > 1 runs PARALLEL_SAFE_TEST_KINDS items simultaneously
|
|
505
|
+
``concurrency`` > 1 runs PARALLEL_SAFE_TEST_KINDS items simultaneously, except those
|
|
506
|
+
``item_runs_in_parallel`` holds back.
|
|
489
507
|
WORKSPACE_MUTATING_TEST_KINDS items always run one at a time, and in a separate phase
|
|
490
508
|
from the parallel ones -- a metric being created and dropped mid-run would otherwise be
|
|
491
509
|
visible to a catalog-reading item running alongside it.
|
|
@@ -637,13 +655,13 @@ def run_agentic_items(
|
|
|
637
655
|
concurrency = max(1, concurrency)
|
|
638
656
|
indexed = list(enumerate(items, start=1))
|
|
639
657
|
if concurrency > 1:
|
|
640
|
-
parallel = [(i, it) for i, it in indexed if
|
|
641
|
-
serial = [(i, it) for i, it in indexed if not
|
|
658
|
+
parallel = [(i, it) for i, it in indexed if item_runs_in_parallel(it)]
|
|
659
|
+
serial = [(i, it) for i, it in indexed if not item_runs_in_parallel(it)]
|
|
642
660
|
if not parallel and serial:
|
|
643
661
|
blocked = ", ".join(sorted({it.test_kind for _, it in serial}))
|
|
644
662
|
print(
|
|
645
|
-
f"warning: --concurrency {concurrency} has no effect here; every item is a "
|
|
646
|
-
|
|
663
|
+
f"warning: --concurrency {concurrency} has no effect here; every item ({blocked}) is a "
|
|
664
|
+
"workspace-mutating kind or a search item with setup turns, and those always run one at a time.",
|
|
647
665
|
file=sys.stderr,
|
|
648
666
|
)
|
|
649
667
|
else:
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# (C) 2026 GoodData Corporation. All rights reserved.
|
|
2
|
+
"""The search-tool item: the expected ``search_objects`` arguments plus the checks an item opts into.
|
|
3
|
+
|
|
4
|
+
An item that carries only ``tool_call``, or reaches the runner as the bare arguments, is scored on
|
|
5
|
+
``tool_selection`` (gating) and ``tool_correctness`` (informing). Each other key adds one check, and a
|
|
6
|
+
key the module does not know is rejected, so a misspelt check cannot read as a pass.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from gooddata_eval.core.models import ChatResult, ToolCallEvent
|
|
16
|
+
|
|
17
|
+
SEARCH_TOOL = "search_objects"
|
|
18
|
+
|
|
19
|
+
# The keys of an item's expected output beside ``tool_call``. Public so a caller holding a raw item can
|
|
20
|
+
# tell the options shape from bare arguments.
|
|
21
|
+
SEARCH_OPTION_KEYS = frozenset(
|
|
22
|
+
{
|
|
23
|
+
"expected_objects",
|
|
24
|
+
"expect_widget",
|
|
25
|
+
"required_tools",
|
|
26
|
+
"forbidden_tools",
|
|
27
|
+
"search_required",
|
|
28
|
+
"answer_rubric",
|
|
29
|
+
"expected_limit",
|
|
30
|
+
"no_raw_ids",
|
|
31
|
+
"setup_turns",
|
|
32
|
+
"report_only",
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
_KNOWN_KEYS = SEARCH_OPTION_KEYS | {"tool_call"}
|
|
36
|
+
# The search_objects parameters, and emit_widget, the old name of user_requested_search. An expected output with
|
|
37
|
+
# any other key is read as an item, so a misspelt check key fails it instead of passing as an argument.
|
|
38
|
+
SEARCH_ARGUMENT_KEYS = frozenset(
|
|
39
|
+
{"keywords", "object_types", "limit", "compatible_with_afm", "kda_eligible", "user_requested_search", "emit_widget"}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
_OBJECT_TYPES = frozenset(
|
|
43
|
+
{
|
|
44
|
+
"metric",
|
|
45
|
+
"fact",
|
|
46
|
+
"attribute",
|
|
47
|
+
"label",
|
|
48
|
+
"date_attribute",
|
|
49
|
+
"computed_attribute",
|
|
50
|
+
"dataset",
|
|
51
|
+
"date",
|
|
52
|
+
"parameter",
|
|
53
|
+
"visualization",
|
|
54
|
+
"dashboard",
|
|
55
|
+
"document",
|
|
56
|
+
"report",
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
# The agent's tools take an attribute by either of its ids, and search returns a date attribute with
|
|
60
|
+
# ``type`` attribute and ``final_type`` date_attribute, so these spellings name one object.
|
|
61
|
+
_ATTRIBUTE_TYPES = frozenset({"attribute", "label", "date_attribute"})
|
|
62
|
+
|
|
63
|
+
# A ``{type/id}`` chip is the UI's own syntax for a named object and renders as its title, also inside
|
|
64
|
+
# inline code. An id outside a chip reaches the user as raw text.
|
|
65
|
+
_CHIP = re.compile(r"\{[a-z_]+/[^{}\s]+\}")
|
|
66
|
+
_UUID = re.compile(r"\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b", re.IGNORECASE)
|
|
67
|
+
_TYPED_ID = re.compile(rf"\b(?:{'|'.join(sorted(_OBJECT_TYPES))})/([A-Za-z0-9_](?:[A-Za-z0-9_.-]*[A-Za-z0-9_])?)")
|
|
68
|
+
# Prose pairs type words with a slash ("date/time", "label/value pairs"). Only an id with an underscore,
|
|
69
|
+
# a dot or a digit, as the workspace ids have, counts. A one-word id such as metric/revenue is not caught.
|
|
70
|
+
_ID_MARK = re.compile(r"[_.0-9]")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@dataclass(frozen=True)
|
|
74
|
+
class SearchExpectation:
|
|
75
|
+
"""What one item expects. Every field but ``tool_args`` is an opt-in check.
|
|
76
|
+
|
|
77
|
+
``setup_turns`` should only read the workspace (search, describe, an unsaved chart). The CLI runs an item with
|
|
78
|
+
setup turns in its serial phase, so a write cannot race another item, but nothing removes what it writes.
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
tool_args: dict[str, Any] = field(default_factory=dict)
|
|
82
|
+
expected_objects: tuple[str, ...] = ()
|
|
83
|
+
expect_widget: bool | None = None
|
|
84
|
+
required_tools: tuple[str, ...] = ()
|
|
85
|
+
forbidden_tools: tuple[str, ...] = ()
|
|
86
|
+
search_required: bool = True
|
|
87
|
+
answer_rubric: tuple[str, ...] = ()
|
|
88
|
+
expected_limit: int | None = None
|
|
89
|
+
no_raw_ids: bool = False
|
|
90
|
+
setup_turns: tuple[str, ...] = ()
|
|
91
|
+
report_only: bool = False
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def has_turn_checks(self) -> bool:
|
|
95
|
+
"""Whether the item opts into a check of the scored turn. Each one is published as a score of its own."""
|
|
96
|
+
return bool(
|
|
97
|
+
self.expected_objects
|
|
98
|
+
or self.expect_widget is not None
|
|
99
|
+
or self.required_tools
|
|
100
|
+
or self.forbidden_tools
|
|
101
|
+
or self.answer_rubric
|
|
102
|
+
or self.expected_limit is not None
|
|
103
|
+
or self.no_raw_ids
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def has_checks(self) -> bool:
|
|
108
|
+
"""Whether the item opts into anything beyond ``tool_selection`` and ``tool_correctness``."""
|
|
109
|
+
return self.has_turn_checks or bool(self.setup_turns) or not self.search_required
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _string_list(key: str, value: Any) -> tuple[str, ...]:
|
|
113
|
+
# isinstance, not str(entry): an unquoted YAML `no` loads as False and would turn into the text "False".
|
|
114
|
+
if not isinstance(value, list) or not value:
|
|
115
|
+
raise ValueError(f"{key} must be a non-empty list of strings, got {value!r}")
|
|
116
|
+
if any(not isinstance(entry, str) or not entry.strip() for entry in value):
|
|
117
|
+
raise ValueError(f"{key} must hold non-empty strings only, got {value!r}")
|
|
118
|
+
return tuple(value)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _flag(key: str, value: Any) -> bool:
|
|
122
|
+
if not isinstance(value, bool):
|
|
123
|
+
raise ValueError(f"{key} must be true or false, got {value!r}")
|
|
124
|
+
return value
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _object_ref(ref: str) -> tuple[str, str]:
|
|
128
|
+
object_type, sep, object_id = ref.partition("/")
|
|
129
|
+
if not sep or object_type not in _OBJECT_TYPES or not object_id or object_id != object_id.strip():
|
|
130
|
+
raise ValueError(f"expected_objects entry must be '<type>/<id>' with a known type, got {ref!r}")
|
|
131
|
+
return object_type, object_id
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _tool_args(tool_call: Any) -> dict[str, Any]:
|
|
135
|
+
if not isinstance(tool_call, dict):
|
|
136
|
+
raise ValueError(f"tool_call must be an object, got {tool_call!r}")
|
|
137
|
+
name = tool_call.get("function_name")
|
|
138
|
+
if name is not None and name != SEARCH_TOOL:
|
|
139
|
+
raise ValueError(f"tool_call.function_name must be {SEARCH_TOOL!r}, got {name!r}")
|
|
140
|
+
return check_arguments(tool_call.get("function_arguments", {}))
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def check_arguments(args: Any) -> dict[str, Any]:
|
|
144
|
+
"""The expected ``search_objects`` arguments, whichever way the item gives them.
|
|
145
|
+
|
|
146
|
+
Raises:
|
|
147
|
+
ValueError: The arguments are not an object, or ``compatible_with_afm`` is not lists of objects.
|
|
148
|
+
"""
|
|
149
|
+
if not isinstance(args, dict):
|
|
150
|
+
raise ValueError(f"tool_call.function_arguments must be an object, got {args!r}")
|
|
151
|
+
afm = args.get("compatible_with_afm")
|
|
152
|
+
if afm is not None and (
|
|
153
|
+
not isinstance(afm, dict)
|
|
154
|
+
or not set(afm) <= {"measures", "attributes"}
|
|
155
|
+
or any(value is not None and not isinstance(value, list) for value in afm.values())
|
|
156
|
+
or any(not isinstance(item, dict) for value in afm.values() for item in value or [])
|
|
157
|
+
):
|
|
158
|
+
raise ValueError(f"compatible_with_afm must hold lists of measure and attribute objects, got {afm!r}")
|
|
159
|
+
return dict(args)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def parse_expectation(expected_output: Any) -> SearchExpectation:
|
|
163
|
+
"""Read an item's whole expected output.
|
|
164
|
+
|
|
165
|
+
Raises:
|
|
166
|
+
ValueError: The expected output is not an object, names an unknown key, or holds a value the
|
|
167
|
+
run could not score. Raised before any request is sent.
|
|
168
|
+
"""
|
|
169
|
+
if not isinstance(expected_output, dict):
|
|
170
|
+
raise ValueError(f"expected_output must be an object, got {expected_output!r}")
|
|
171
|
+
unknown = sorted(set(expected_output) - _KNOWN_KEYS)
|
|
172
|
+
if unknown:
|
|
173
|
+
raise ValueError(f"expected_output has unknown keys {unknown}; known keys are {sorted(_KNOWN_KEYS)}")
|
|
174
|
+
raw = expected_output
|
|
175
|
+
tool_args = _tool_args(raw["tool_call"]) if "tool_call" in raw else {}
|
|
176
|
+
|
|
177
|
+
expected_objects: tuple[str, ...] = ()
|
|
178
|
+
if "expected_objects" in raw:
|
|
179
|
+
expected_objects = _string_list("expected_objects", raw["expected_objects"])
|
|
180
|
+
for ref in expected_objects:
|
|
181
|
+
_object_ref(ref)
|
|
182
|
+
required = _string_list("required_tools", raw["required_tools"]) if "required_tools" in raw else ()
|
|
183
|
+
forbidden = _string_list("forbidden_tools", raw["forbidden_tools"]) if "forbidden_tools" in raw else ()
|
|
184
|
+
both = sorted(set(required) & set(forbidden))
|
|
185
|
+
if both:
|
|
186
|
+
raise ValueError(f"tools {both} are both required and forbidden")
|
|
187
|
+
limit = raw.get("expected_limit")
|
|
188
|
+
if "expected_limit" in raw and (not isinstance(limit, int) or isinstance(limit, bool) or limit < 1):
|
|
189
|
+
raise ValueError(f"expected_limit must be a positive integer, got {limit!r}")
|
|
190
|
+
|
|
191
|
+
spec = SearchExpectation(
|
|
192
|
+
tool_args=tool_args,
|
|
193
|
+
expected_objects=expected_objects,
|
|
194
|
+
expect_widget=_flag("expect_widget", raw["expect_widget"]) if "expect_widget" in raw else None,
|
|
195
|
+
required_tools=required,
|
|
196
|
+
forbidden_tools=forbidden,
|
|
197
|
+
search_required=_flag("search_required", raw["search_required"]) if "search_required" in raw else True,
|
|
198
|
+
answer_rubric=_string_list("answer_rubric", raw["answer_rubric"]) if "answer_rubric" in raw else (),
|
|
199
|
+
expected_limit=limit,
|
|
200
|
+
no_raw_ids=_flag("no_raw_ids", raw["no_raw_ids"]) if "no_raw_ids" in raw else False,
|
|
201
|
+
setup_turns=_string_list("setup_turns", raw["setup_turns"]) if "setup_turns" in raw else (),
|
|
202
|
+
report_only=_flag("report_only", raw["report_only"]) if "report_only" in raw else False,
|
|
203
|
+
)
|
|
204
|
+
if "tool_call" not in raw and not spec.has_checks:
|
|
205
|
+
raise ValueError("expected_output asserts nothing: give tool_call or at least one check")
|
|
206
|
+
# tool_correctness only informs, so without tool_selection's gate a check of the turn is all that can fail a run.
|
|
207
|
+
if not spec.search_required and not spec.has_turn_checks:
|
|
208
|
+
raise ValueError(
|
|
209
|
+
"search_required: false needs a check of the scored turn (such as expect_widget or forbidden_tools), "
|
|
210
|
+
"or the item passes whatever the agent does"
|
|
211
|
+
)
|
|
212
|
+
if spec.report_only and not spec.has_turn_checks:
|
|
213
|
+
raise ValueError("report_only has no check to report")
|
|
214
|
+
return spec
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _ref_key(object_type: str, object_id: str) -> tuple[str, str]:
|
|
218
|
+
return ("attribute" if object_type in _ATTRIBUTE_TYPES else object_type, object_id)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def call_args(tc: ToolCallEvent) -> dict[str, Any]:
|
|
222
|
+
"""The call's arguments, or {} when they are missing or not a JSON object."""
|
|
223
|
+
args = tc.parsed_arguments()
|
|
224
|
+
return args if isinstance(args, dict) else {}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def search_calls(events: list[ToolCallEvent]) -> list[ToolCallEvent]:
|
|
228
|
+
"""The turn's ``search_objects`` calls, in order."""
|
|
229
|
+
return [tc for tc in events if tc.function_name == SEARCH_TOOL]
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _objects(container: Any) -> list[dict]:
|
|
233
|
+
"""The object entries of a search result or widget part; none when its shape is not the expected one."""
|
|
234
|
+
objects = container.get("objects") if isinstance(container, dict) else None
|
|
235
|
+
return [obj for obj in objects if isinstance(obj, dict)] if isinstance(objects, list) else []
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def returned_refs(result: ChatResult) -> list[str]:
|
|
239
|
+
"""Every object the turn's searches returned, as ``type/id``, first sighting first.
|
|
240
|
+
|
|
241
|
+
Read from the ``search_objects`` results and from the ``searchResults`` widget parts: a search
|
|
242
|
+
the agent runs for itself shows no widget, so its result is the only place its objects appear.
|
|
243
|
+
"""
|
|
244
|
+
refs: dict[tuple[str, str], str] = {}
|
|
245
|
+
|
|
246
|
+
def _add(object_type: Any, object_id: Any) -> None:
|
|
247
|
+
if isinstance(object_type, str) and isinstance(object_id, str) and object_type and object_id:
|
|
248
|
+
refs.setdefault(_ref_key(object_type, object_id), f"{object_type}/{object_id}")
|
|
249
|
+
|
|
250
|
+
for tc in search_calls(result.tool_call_events or []):
|
|
251
|
+
for obj in _objects(tc.parsed_result()):
|
|
252
|
+
_add(obj.get("final_type") or obj.get("type"), obj.get("id"))
|
|
253
|
+
for part in result.search_results:
|
|
254
|
+
for obj in _objects(part):
|
|
255
|
+
_add(obj.get("type"), obj.get("id"))
|
|
256
|
+
return list(refs.values())
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _key_of(ref: str) -> tuple[str, str]:
|
|
260
|
+
object_type, _, object_id = ref.partition("/")
|
|
261
|
+
return _ref_key(object_type, object_id)
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def missing_objects(expected: tuple[str, ...], returned: list[str]) -> list[str]:
|
|
265
|
+
"""The expected refs no search returned. Every one must be found, not any one."""
|
|
266
|
+
found = {_key_of(ref) for ref in returned}
|
|
267
|
+
return [ref for ref in expected if _key_of(ref) not in found]
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def raw_ids(text: str) -> list[str]:
|
|
271
|
+
"""The UUIDs and ``type/id`` spellings in ``text`` that sit outside a ``{type/id}`` chip."""
|
|
272
|
+
outside = _CHIP.sub(" ", text)
|
|
273
|
+
typed = [m.group(0) for m in _TYPED_ID.finditer(outside) if _ID_MARK.search(m.group(1))]
|
|
274
|
+
return _UUID.findall(outside) + typed
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def deterministic_checks(spec: SearchExpectation, result: ChatResult) -> tuple[dict[str, bool], dict[str, Any]]:
|
|
278
|
+
"""The checks of one scored turn that need no judge, with the evidence of each failure."""
|
|
279
|
+
checks: dict[str, bool] = {}
|
|
280
|
+
details: dict[str, Any] = {}
|
|
281
|
+
|
|
282
|
+
def _check(name: str, ok: bool, why: Any) -> None:
|
|
283
|
+
checks[name] = ok
|
|
284
|
+
if not ok:
|
|
285
|
+
details[name] = why
|
|
286
|
+
|
|
287
|
+
events = result.tool_call_events or []
|
|
288
|
+
if spec.expected_objects:
|
|
289
|
+
returned = returned_refs(result)
|
|
290
|
+
missing = missing_objects(spec.expected_objects, returned)
|
|
291
|
+
_check("search_expected_objects", not missing, {"missing": missing, "returned": returned[:30]})
|
|
292
|
+
if spec.expect_widget is not None:
|
|
293
|
+
parts = len(result.search_results)
|
|
294
|
+
_check("search_widget", (parts > 0) == spec.expect_widget, {"expected": spec.expect_widget, "parts": parts})
|
|
295
|
+
if spec.required_tools or spec.forbidden_tools:
|
|
296
|
+
called = [tc.function_name for tc in events]
|
|
297
|
+
not_called = [name for name in spec.required_tools if name not in called]
|
|
298
|
+
forbidden = [name for name in spec.forbidden_tools if name in called]
|
|
299
|
+
_check(
|
|
300
|
+
"search_routing",
|
|
301
|
+
not not_called and not forbidden,
|
|
302
|
+
{"not_called": not_called, "forbidden_called": forbidden, "called": called},
|
|
303
|
+
)
|
|
304
|
+
if spec.expected_limit is not None:
|
|
305
|
+
limits = [call_args(tc).get("limit") for tc in search_calls(events)]
|
|
306
|
+
_check("search_limit", spec.expected_limit in limits, {"expected": spec.expected_limit, "limits": limits})
|
|
307
|
+
if spec.no_raw_ids:
|
|
308
|
+
found = raw_ids(result.text_response or "")
|
|
309
|
+
_check("search_no_raw_ids", not found, {"raw_ids": found})
|
|
310
|
+
return checks, details
|
|
@@ -592,6 +592,21 @@ def generate_simulated_alert_response(
|
|
|
592
592
|
|
|
593
593
|
original_request = f'Your original request to the agent was: "{question}"\n' if question else ""
|
|
594
594
|
|
|
595
|
+
# The agent may offer several metrics and describe one as ignoring filters or counting all
|
|
596
|
+
# time. That reads like rule 5's "no filters ... all time", which made the simulated user
|
|
597
|
+
# pick it. The pick follows the goal's metric whatever its description says, matched by id
|
|
598
|
+
# or by title, and repeats the option as the agent wrote it, so the reply adds no reference
|
|
599
|
+
# the agent did not offer. A fixture names a bare metric id: `_check_metric` compares it as
|
|
600
|
+
# written.
|
|
601
|
+
metric_choice_rule = (
|
|
602
|
+
f" If the agent offers several metrics to choose from, choose the option for your goal metric "
|
|
603
|
+
f"({expected.metric_id}; the agent may show it by this id or only by its title) and repeat that option "
|
|
604
|
+
"as the agent wrote it. How the agent describes a metric, for example as ignoring filters or counting all "
|
|
605
|
+
"time, never changes which metric you want: rule 5 is about filters on the alert.\n"
|
|
606
|
+
if expected.metric_id
|
|
607
|
+
else ""
|
|
608
|
+
)
|
|
609
|
+
|
|
595
610
|
# Only a stated title is enforced: an unstated one is the agent's to choose, and telling the
|
|
596
611
|
# sim-user nothing keeps it from objecting to a generated name.
|
|
597
612
|
title_rule = (
|
|
@@ -607,8 +622,11 @@ def generate_simulated_alert_response(
|
|
|
607
622
|
+ original_request
|
|
608
623
|
+ "Rules you MUST follow:\n"
|
|
609
624
|
f"1. Your goal: metric={metric}, operator={operator}, threshold={threshold}, "
|
|
610
|
-
f"recipients={recipients}, trigger={trigger_key}"
|
|
611
|
-
"
|
|
625
|
+
f"recipients={recipients}, trigger={trigger_key}"
|
|
626
|
+
+ (f", filters={filters}" if filters else "")
|
|
627
|
+
+ ".\n"
|
|
628
|
+
+ metric_choice_rule
|
|
629
|
+
+ "2. Never revert or change a decision that was already confirmed in a previous turn.\n"
|
|
612
630
|
"3. If the agent shows a final summary, an alert proposal or asks for confirmation, check "
|
|
613
631
|
" ALL of these against your goal: recipients, trigger (how often you are alerted), "
|
|
614
632
|
" filters / time window, threshold and operator. If ANY of them differs — for example the "
|
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
# (C) 2026 GoodData Corporation. All rights reserved.
|
|
2
|
-
"""Agentic search-tool evaluation runner (
|
|
2
|
+
"""Agentic search-tool evaluation runner (one scored turn, after any setup turns)."""
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
6
|
import time
|
|
7
|
-
from dataclasses import dataclass, field
|
|
7
|
+
from dataclasses import dataclass, field, replace
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
import httpx
|
|
8
11
|
|
|
9
12
|
from gooddata_eval.core.agentic._failed_runs import build_failed_runs
|
|
13
|
+
from gooddata_eval.core.agentic._failure_message import FailedCheck, failed_check_records
|
|
10
14
|
from gooddata_eval.core.agentic._gate import (
|
|
11
15
|
DEFAULT_GATE,
|
|
12
16
|
EvalGate,
|
|
13
|
-
gate_failure_note,
|
|
14
17
|
gate_passed,
|
|
15
18
|
log_gate_scores,
|
|
16
19
|
stamp_gate_metadata,
|
|
17
20
|
)
|
|
18
|
-
from gooddata_eval.core.agentic._outcome import
|
|
21
|
+
from gooddata_eval.core.agentic._outcome import (
|
|
22
|
+
JudgeErrorOf,
|
|
23
|
+
agentic_detail,
|
|
24
|
+
agentic_success,
|
|
25
|
+
chat_failure_exit,
|
|
26
|
+
failure_message_head,
|
|
27
|
+
label_runs,
|
|
28
|
+
log_eval_error_score,
|
|
29
|
+
raise_agentic_failure,
|
|
30
|
+
)
|
|
31
|
+
from gooddata_eval.core.agentic._search_expectation import (
|
|
32
|
+
SEARCH_TOOL,
|
|
33
|
+
SearchExpectation,
|
|
34
|
+
call_args,
|
|
35
|
+
check_arguments,
|
|
36
|
+
deterministic_checks,
|
|
37
|
+
parse_expectation,
|
|
38
|
+
search_calls,
|
|
39
|
+
)
|
|
19
40
|
from gooddata_eval.core.agentic._trace_linker import (
|
|
20
41
|
RunIdentity,
|
|
21
42
|
RunTraceContext,
|
|
@@ -25,23 +46,70 @@ from gooddata_eval.core.agentic._trace_linker import (
|
|
|
25
46
|
submit_trace_scoring,
|
|
26
47
|
utc_now,
|
|
27
48
|
)
|
|
28
|
-
from gooddata_eval.core.chat.
|
|
49
|
+
from gooddata_eval.core.chat.render import render_answer_text
|
|
50
|
+
from gooddata_eval.core.chat.sse_client import ChatClient, ChatError
|
|
29
51
|
from gooddata_eval.core.config import ReasoningEffort
|
|
52
|
+
from gooddata_eval.core.evaluators._llm_judge import JudgeVerdict, LLMJudge, score_run
|
|
30
53
|
from gooddata_eval.core.langfuse.item_scope import item_scope
|
|
31
54
|
from gooddata_eval.core.models import (
|
|
32
55
|
AgenticAssertionError,
|
|
33
56
|
AgenticEvalOutcome,
|
|
57
|
+
ChatResult,
|
|
58
|
+
LoopExit,
|
|
34
59
|
ReasoningStepEvent,
|
|
35
60
|
ToolCallEvent,
|
|
36
61
|
build_latency_breakdown,
|
|
37
62
|
)
|
|
38
63
|
|
|
64
|
+
_TRANSPORT_ERRORS: tuple[type[BaseException], ...] = (httpx.HTTPError, TimeoutError, ConnectionError)
|
|
65
|
+
# What a chat turn raises when it fails: ChatClient re-raises an HTTP status that outlasts its retries, and a
|
|
66
|
+
# transport fault, as the httpx error itself. Anything else is a bug in this package and is left to surface.
|
|
67
|
+
_TURN_ERRORS: tuple[type[BaseException], ...] = (ChatError, httpx.HTTPError)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _judge_provider_errors() -> tuple[type[BaseException], ...]:
|
|
71
|
+
"""The errors of a judge request that fails at the provider (timeout, outage, rate limit).
|
|
72
|
+
|
|
73
|
+
Such a request leaves the run unscored, not failed. ``openai`` is the optional llm-judge extra, so its
|
|
74
|
+
errors join only when it is installed.
|
|
75
|
+
"""
|
|
76
|
+
try:
|
|
77
|
+
from openai import OpenAIError # noqa: PLC0415
|
|
78
|
+
except ImportError:
|
|
79
|
+
return _TRANSPORT_ERRORS
|
|
80
|
+
return (OpenAIError, *_TRANSPORT_ERRORS)
|
|
81
|
+
|
|
82
|
+
|
|
39
83
|
_DEFAULT_K = 1
|
|
40
84
|
|
|
85
|
+
# Every check score an item can publish beside tool_selection and tool_correctness. Each is published only for an
|
|
86
|
+
# item that opts into it, and search_answer not for a run the judge could not grade.
|
|
87
|
+
SEARCH_CONDITIONAL_SCORES = (
|
|
88
|
+
"search_expected_objects",
|
|
89
|
+
"search_widget",
|
|
90
|
+
"search_routing",
|
|
91
|
+
"search_answer",
|
|
92
|
+
"search_limit",
|
|
93
|
+
"search_no_raw_ids",
|
|
94
|
+
)
|
|
95
|
+
# The names a score takes where it does not gate the item: every check of a report_only item, and tool_selection of
|
|
96
|
+
# an item with search_required false. A score name then means the same on every item.
|
|
97
|
+
_DIAGNOSTIC_SUFFIX = "_diagnostic"
|
|
98
|
+
SEARCH_DIAGNOSTIC_SCORES = tuple(
|
|
99
|
+
f"{name}{_DIAGNOSTIC_SUFFIX}" for name in ("tool_selection", *SEARCH_CONDITIONAL_SCORES)
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
_RUBRIC_STEPS = [
|
|
103
|
+
"EXPECTED OUTPUT lists the criteria, one per line, that the assistant's LAST reply must meet.",
|
|
104
|
+
"ACTUAL OUTPUT holds the conversation in order. Earlier turns are context only.",
|
|
105
|
+
"A {type/id} chip in a reply is shown to the user as that object's title.",
|
|
106
|
+
"Pass only when the last reply meets every criterion. Fail when it breaks any.",
|
|
107
|
+
]
|
|
108
|
+
|
|
41
109
|
|
|
42
110
|
def _tool_selection(tool_call_events: list[ToolCallEvent]) -> bool:
|
|
43
111
|
"""Return True if search_objects was called."""
|
|
44
|
-
return any(tc.function_name ==
|
|
112
|
+
return any(tc.function_name == SEARCH_TOOL for tc in tool_call_events)
|
|
45
113
|
|
|
46
114
|
|
|
47
115
|
# Arguments that do not determine search quality, so a fixture naming them must not
|
|
@@ -77,30 +145,54 @@ def _list_matches(expected: list, actual: list, *, loose: bool) -> bool:
|
|
|
77
145
|
return all(e in actual for e in expected)
|
|
78
146
|
|
|
79
147
|
|
|
148
|
+
def _afm_matches(expected: dict, actual: Any) -> bool:
|
|
149
|
+
"""Every expected measure and attribute is in the call's AFM; a null field in the fixture matches anything.
|
|
150
|
+
|
|
151
|
+
The agent states ``aggregation: null`` for a metric and may add objects to the AFM, so neither fails it.
|
|
152
|
+
"""
|
|
153
|
+
if not isinstance(actual, dict):
|
|
154
|
+
return False
|
|
155
|
+
if any(actual.get(key) is not None and not isinstance(actual.get(key), list) for key in ("measures", "attributes")):
|
|
156
|
+
return False
|
|
157
|
+
for key in ("measures", "attributes"):
|
|
158
|
+
listed = actual.get(key)
|
|
159
|
+
actual_items = [item for item in listed if isinstance(item, dict)] if isinstance(listed, list) else []
|
|
160
|
+
for exp in expected.get(key) or []:
|
|
161
|
+
if not isinstance(exp, dict):
|
|
162
|
+
return False
|
|
163
|
+
if not any(all(v is None or act.get(k) == v for k, v in exp.items()) for act in actual_items):
|
|
164
|
+
return False
|
|
165
|
+
return True
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _call_matches(args: dict, expected_tool_call: dict) -> bool:
|
|
169
|
+
for key, exp_val in expected_tool_call.items():
|
|
170
|
+
if key in _IGNORED_SEARCH_ARGS:
|
|
171
|
+
continue
|
|
172
|
+
act_val = args.get(key)
|
|
173
|
+
if key == "compatible_with_afm" and isinstance(exp_val, dict):
|
|
174
|
+
if not _afm_matches(exp_val, act_val):
|
|
175
|
+
return False
|
|
176
|
+
elif isinstance(exp_val, list) and isinstance(act_val, list):
|
|
177
|
+
if not _list_matches(exp_val, act_val, loose=key == "keywords"):
|
|
178
|
+
return False
|
|
179
|
+
elif isinstance(exp_val, str) and isinstance(act_val, str):
|
|
180
|
+
if not _loosely_contains(exp_val, act_val):
|
|
181
|
+
return False
|
|
182
|
+
elif exp_val != act_val:
|
|
183
|
+
return False
|
|
184
|
+
return True
|
|
185
|
+
|
|
186
|
+
|
|
80
187
|
def _tool_correctness(tool_call_events: list[ToolCallEvent], expected_tool_call: dict) -> bool:
|
|
81
|
-
"""Return True if
|
|
188
|
+
"""Return True if a search_objects call's arguments match expected.
|
|
82
189
|
|
|
83
190
|
List fields (keywords, object_types) use subset matching: every expected value must
|
|
84
191
|
appear in the actual call and the agent may include extras. ``keywords`` match by
|
|
85
|
-
substring; every other list is compared exactly.
|
|
192
|
+
substring; every other list is compared exactly. Any call of the turn may match: the
|
|
193
|
+
agent often looks the measure up first and asks for compatible attributes after.
|
|
86
194
|
"""
|
|
87
|
-
for tc in tool_call_events
|
|
88
|
-
if tc.function_name == "search_objects":
|
|
89
|
-
args = tc.parsed_arguments() or {}
|
|
90
|
-
for key, exp_val in expected_tool_call.items():
|
|
91
|
-
if key in _IGNORED_SEARCH_ARGS:
|
|
92
|
-
continue
|
|
93
|
-
act_val = args.get(key)
|
|
94
|
-
if isinstance(exp_val, list) and isinstance(act_val, list):
|
|
95
|
-
if not _list_matches(exp_val, act_val, loose=key == "keywords"):
|
|
96
|
-
return False
|
|
97
|
-
elif isinstance(exp_val, str) and isinstance(act_val, str):
|
|
98
|
-
if not _loosely_contains(exp_val, act_val):
|
|
99
|
-
return False
|
|
100
|
-
elif exp_val != act_val:
|
|
101
|
-
return False
|
|
102
|
-
return True
|
|
103
|
-
return False
|
|
195
|
+
return any(_call_matches(call_args(tc), expected_tool_call) for tc in search_calls(tool_call_events))
|
|
104
196
|
|
|
105
197
|
|
|
106
198
|
@dataclass
|
|
@@ -118,6 +210,21 @@ class SearchResult:
|
|
|
118
210
|
# This run's own wall time -- mirrors the single-shot path's best_run_latency_s
|
|
119
211
|
# (see core/runner.py's _run_one_item).
|
|
120
212
|
run_latency_s: float = 0.0
|
|
213
|
+
# The item's opt-in checks of this run, and why each failed one failed.
|
|
214
|
+
checks: dict[str, bool] = field(default_factory=dict)
|
|
215
|
+
check_details: dict[str, Any] = field(default_factory=dict)
|
|
216
|
+
# Why the judge could not grade the answer; the run is then labelled ERROR unless another check failed it.
|
|
217
|
+
harness_error: str | None = None
|
|
218
|
+
# The checks that read False only because of harness_error. Their scores are not published.
|
|
219
|
+
harness_checks: tuple[str, ...] = ()
|
|
220
|
+
# Set when a setup turn failed, so the question was never sent.
|
|
221
|
+
exit_reason: LoopExit | None = None
|
|
222
|
+
passed: bool = False
|
|
223
|
+
|
|
224
|
+
@property
|
|
225
|
+
def judge_error(self) -> str | None:
|
|
226
|
+
"""The name ``build_failed_runs`` reads a run's ungraded verdict under."""
|
|
227
|
+
return self.harness_error
|
|
121
228
|
|
|
122
229
|
|
|
123
230
|
@dataclass
|
|
@@ -130,19 +237,174 @@ class AgenticSearchSummary:
|
|
|
130
237
|
best: SearchResult
|
|
131
238
|
|
|
132
239
|
|
|
240
|
+
def _judge_rubric(judge: LLMJudge, rubric: tuple[str, ...], transcript: list[tuple[str, str]]) -> JudgeVerdict:
|
|
241
|
+
"""Grade the last reply against the rubric, with the turns before it as context."""
|
|
242
|
+
conversation = "\n\n".join(f"{role}: {text}" for role, text in transcript)
|
|
243
|
+
criteria = "\n".join(f"- {criterion}" for criterion in rubric)
|
|
244
|
+
question = next((text for role, text in reversed(transcript) if role == "User"), "")
|
|
245
|
+
return score_run(judge, input=question, expected_output=criteria, actual_output=conversation)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def _turn_failed(
|
|
249
|
+
conversation_id: str,
|
|
250
|
+
turn: str,
|
|
251
|
+
exit_reason: LoopExit,
|
|
252
|
+
reason: str,
|
|
253
|
+
latency_s: float,
|
|
254
|
+
partial: ChatResult | None = None,
|
|
255
|
+
) -> SearchResult:
|
|
256
|
+
"""A run whose ``turn`` (``setup_turn`` or ``question_turn``) failed: the agent's FAIL, as a chat failure is for
|
|
257
|
+
every kind.
|
|
258
|
+
|
|
259
|
+
Nothing of it is scored. Its latency is the failed turn's own, and the setup turns' when the question was never
|
|
260
|
+
sent. What the agent did before a turn failed is kept for diagnosis only.
|
|
261
|
+
"""
|
|
262
|
+
if partial is None:
|
|
263
|
+
partial = ChatResult()
|
|
264
|
+
events = list(partial.tool_call_events or [])
|
|
265
|
+
return SearchResult(
|
|
266
|
+
conversation_id=conversation_id,
|
|
267
|
+
tool_selected=False,
|
|
268
|
+
tool_correct=False,
|
|
269
|
+
tool_call_names=[tc.function_name for tc in events],
|
|
270
|
+
reasoning_steps=list(partial.reasoning_steps or []),
|
|
271
|
+
response_id=partial.response_id,
|
|
272
|
+
tool_call_events=events,
|
|
273
|
+
reasoning_step_events=list(partial.reasoning_step_events or []),
|
|
274
|
+
check_details={turn: reason},
|
|
275
|
+
exit_reason=exit_reason,
|
|
276
|
+
run_latency_s=latency_s,
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def _execute_run(
|
|
281
|
+
client: ChatClient,
|
|
282
|
+
conversation_id: str,
|
|
283
|
+
question: str,
|
|
284
|
+
spec: SearchExpectation,
|
|
285
|
+
judge: LLMJudge | None,
|
|
286
|
+
) -> SearchResult:
|
|
287
|
+
"""Send the item's setup turns, then the question, and score the question's turn alone."""
|
|
288
|
+
transcript: list[tuple[str, str]] = []
|
|
289
|
+
setup_started = time.monotonic()
|
|
290
|
+
for number, turn in enumerate(spec.setup_turns, start=1):
|
|
291
|
+
try:
|
|
292
|
+
setup = client.send_message(conversation_id, turn)
|
|
293
|
+
except _TURN_ERRORS as exc:
|
|
294
|
+
reason = f"setup turn {number} failed: {exc}"
|
|
295
|
+
elapsed = time.monotonic() - setup_started
|
|
296
|
+
partial = getattr(exc, "partial_result", None)
|
|
297
|
+
return _turn_failed(conversation_id, "setup_turn", chat_failure_exit(exc), reason, elapsed, partial)
|
|
298
|
+
setup_text = render_answer_text(setup)
|
|
299
|
+
if not setup_text and not setup.tool_call_events:
|
|
300
|
+
reason = f"setup turn {number} got no answer"
|
|
301
|
+
elapsed = time.monotonic() - setup_started
|
|
302
|
+
return _turn_failed(conversation_id, "setup_turn", LoopExit.AGENT_SILENT, reason, elapsed)
|
|
303
|
+
transcript += [("User", turn), ("Assistant", setup_text)]
|
|
304
|
+
|
|
305
|
+
run_started = time.monotonic()
|
|
306
|
+
try:
|
|
307
|
+
chat_result = client.send_message(conversation_id, question)
|
|
308
|
+
except _TURN_ERRORS as exc:
|
|
309
|
+
# Recorded, not raised: an escaping error would discard the runs already completed.
|
|
310
|
+
reason = f"question turn failed: {exc}"
|
|
311
|
+
elapsed = time.monotonic() - run_started
|
|
312
|
+
partial = getattr(exc, "partial_result", None)
|
|
313
|
+
return _turn_failed(conversation_id, "question_turn", chat_failure_exit(exc), reason, elapsed, partial)
|
|
314
|
+
run_latency = time.monotonic() - run_started
|
|
315
|
+
tcs = chat_result.tool_call_events or []
|
|
316
|
+
selected = _tool_selection(tcs)
|
|
317
|
+
run = SearchResult(
|
|
318
|
+
conversation_id=conversation_id,
|
|
319
|
+
tool_selected=selected,
|
|
320
|
+
tool_correct=selected and _tool_correctness(tcs, spec.tool_args),
|
|
321
|
+
tool_call_names=[tc.function_name for tc in tcs],
|
|
322
|
+
reasoning_steps=list(chat_result.reasoning_steps or []),
|
|
323
|
+
response_id=chat_result.response_id,
|
|
324
|
+
tool_call_events=list(chat_result.tool_call_events or []),
|
|
325
|
+
reasoning_step_events=list(chat_result.reasoning_step_events or []),
|
|
326
|
+
run_latency_s=run_latency,
|
|
327
|
+
)
|
|
328
|
+
if spec.has_turn_checks:
|
|
329
|
+
run.checks, run.check_details = deterministic_checks(spec, chat_result)
|
|
330
|
+
if spec.answer_rubric:
|
|
331
|
+
_score_answer(run, spec, judge, transcript, question, chat_result)
|
|
332
|
+
run.passed = (selected or not spec.search_required) and (spec.report_only or all(run.checks.values()))
|
|
333
|
+
return run
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def _score_answer(
|
|
337
|
+
run: SearchResult,
|
|
338
|
+
spec: SearchExpectation,
|
|
339
|
+
judge: LLMJudge | None,
|
|
340
|
+
transcript: list[tuple[str, str]],
|
|
341
|
+
question: str,
|
|
342
|
+
chat_result: ChatResult,
|
|
343
|
+
) -> None:
|
|
344
|
+
"""Grade the reply's text against the rubric. A turn without text fails without asking the judge."""
|
|
345
|
+
answer = (chat_result.text_response or "").strip()
|
|
346
|
+
if not answer:
|
|
347
|
+
run.checks["search_answer"] = False
|
|
348
|
+
run.check_details["search_answer"] = "empty answer: the turn has no text"
|
|
349
|
+
return
|
|
350
|
+
if judge is None:
|
|
351
|
+
raise RuntimeError("answer_rubric needs the LLM judge, which was not built")
|
|
352
|
+
try:
|
|
353
|
+
verdict = _judge_rubric(judge, spec.answer_rubric, [*transcript, ("User", question), ("Assistant", answer)])
|
|
354
|
+
except _judge_provider_errors() as exc:
|
|
355
|
+
verdict = JudgeVerdict(passed=False, reasoning="", error=f"{type(exc).__name__}: {exc}")
|
|
356
|
+
run.checks["search_answer"] = verdict.passed if verdict.error is None else False
|
|
357
|
+
if verdict.error is not None:
|
|
358
|
+
reason = f"judge gave no verdict: {verdict.error}"
|
|
359
|
+
run.check_details["search_answer"] = f"harness: {reason}"
|
|
360
|
+
run.harness_error = reason
|
|
361
|
+
run.harness_checks = ("search_answer",)
|
|
362
|
+
elif not verdict.passed:
|
|
363
|
+
run.check_details["search_answer"] = verdict.reasoning
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def _open_harness_error(spec: SearchExpectation) -> JudgeErrorOf:
|
|
367
|
+
"""How labels read a run's harness error: only when nothing but the harness-scored checks failed it.
|
|
368
|
+
|
|
369
|
+
A run that also failed a check the harness did score is the agent's FAIL, whatever the judge would have said.
|
|
370
|
+
"""
|
|
371
|
+
|
|
372
|
+
def _read(run: Any) -> str | None:
|
|
373
|
+
if run.harness_error is None:
|
|
374
|
+
return None
|
|
375
|
+
gate_ok = run.tool_selected or not spec.search_required
|
|
376
|
+
failing = {name for name, ok in run.checks.items() if not ok}
|
|
377
|
+
return run.harness_error if gate_ok and failing <= set(run.harness_checks) else None
|
|
378
|
+
|
|
379
|
+
return _read
|
|
380
|
+
|
|
381
|
+
|
|
133
382
|
def run_agentic_search_tool(
|
|
134
383
|
host: str,
|
|
135
384
|
token: str,
|
|
136
385
|
workspace_id: str,
|
|
137
386
|
question: str,
|
|
138
|
-
expected_tool_call: dict,
|
|
387
|
+
expected_tool_call: dict | None = None,
|
|
139
388
|
k: int = _DEFAULT_K,
|
|
140
389
|
initial_conversation_id: str | None = None,
|
|
141
390
|
reasoning_effort: ReasoningEffort | None = None,
|
|
142
391
|
agent_id: str | None = None,
|
|
143
392
|
user_context: dict | None = None,
|
|
393
|
+
expected_output: dict | None = None,
|
|
144
394
|
) -> AgenticSearchSummary:
|
|
145
|
-
"""Run the search-tool agentic evaluation K times
|
|
395
|
+
"""Run the search-tool agentic evaluation K times.
|
|
396
|
+
|
|
397
|
+
``expected_tool_call`` is the bare ``search_objects`` arguments. ``expected_output`` is the item's whole expected output (``tool_call`` plus the checks of
|
|
398
|
+
``_search_expectation``); when it has no ``tool_call``, ``expected_tool_call`` supplies the arguments.
|
|
399
|
+
|
|
400
|
+
Raises:
|
|
401
|
+
ValueError: ``expected_output`` or ``expected_tool_call`` is malformed. Raised before any request.
|
|
402
|
+
ImportError, OSError: The item has an answer rubric and the LLM judge cannot be built (the llm-judge
|
|
403
|
+
extra or OPENAI_API_KEY is missing). Raised before any request.
|
|
404
|
+
"""
|
|
405
|
+
spec = _expectation(expected_tool_call, expected_output)
|
|
406
|
+
# Built before the first request: a missing judge is a setup error to report at once.
|
|
407
|
+
judge = LLMJudge(_RUBRIC_STEPS) if spec.answer_rubric else None
|
|
146
408
|
run_results: list[SearchResult] = []
|
|
147
409
|
|
|
148
410
|
client = ChatClient(
|
|
@@ -156,24 +418,7 @@ def run_agentic_search_tool(
|
|
|
156
418
|
try:
|
|
157
419
|
conv_id_0 = initial_conversation_id if initial_conversation_id is not None else client.create_conversation()
|
|
158
420
|
try:
|
|
159
|
-
|
|
160
|
-
chat_result = client.send_message(conv_id_0, question)
|
|
161
|
-
tcs = chat_result.tool_call_events or []
|
|
162
|
-
selected = _tool_selection(tcs)
|
|
163
|
-
correct = selected and _tool_correctness(tcs, expected_tool_call)
|
|
164
|
-
run_results.append(
|
|
165
|
-
SearchResult(
|
|
166
|
-
conversation_id=conv_id_0,
|
|
167
|
-
tool_selected=selected,
|
|
168
|
-
tool_correct=correct,
|
|
169
|
-
tool_call_names=[tc.function_name for tc in tcs],
|
|
170
|
-
reasoning_steps=list(chat_result.reasoning_steps or []),
|
|
171
|
-
response_id=chat_result.response_id,
|
|
172
|
-
tool_call_events=list(chat_result.tool_call_events or []),
|
|
173
|
-
reasoning_step_events=list(chat_result.reasoning_step_events or []),
|
|
174
|
-
run_latency_s=time.monotonic() - run_started,
|
|
175
|
-
)
|
|
176
|
-
)
|
|
421
|
+
run_results.append(_execute_run(client, conv_id_0, question, spec, judge))
|
|
177
422
|
finally:
|
|
178
423
|
if initial_conversation_id is None:
|
|
179
424
|
client.delete_conversation(conv_id_0)
|
|
@@ -181,34 +426,20 @@ def run_agentic_search_tool(
|
|
|
181
426
|
for _ in range(1, k):
|
|
182
427
|
conv_id = client.create_conversation()
|
|
183
428
|
try:
|
|
184
|
-
|
|
185
|
-
chat_result = client.send_message(conv_id, question)
|
|
186
|
-
tcs = chat_result.tool_call_events or []
|
|
187
|
-
selected = _tool_selection(tcs)
|
|
188
|
-
correct = selected and _tool_correctness(tcs, expected_tool_call)
|
|
189
|
-
run_results.append(
|
|
190
|
-
SearchResult(
|
|
191
|
-
conversation_id=conv_id,
|
|
192
|
-
tool_selected=selected,
|
|
193
|
-
tool_correct=correct,
|
|
194
|
-
tool_call_names=[tc.function_name for tc in tcs],
|
|
195
|
-
reasoning_steps=list(chat_result.reasoning_steps or []),
|
|
196
|
-
response_id=chat_result.response_id,
|
|
197
|
-
tool_call_events=list(chat_result.tool_call_events or []),
|
|
198
|
-
reasoning_step_events=list(chat_result.reasoning_step_events or []),
|
|
199
|
-
run_latency_s=time.monotonic() - run_started,
|
|
200
|
-
)
|
|
201
|
-
)
|
|
429
|
+
run_results.append(_execute_run(client, conv_id, question, spec, judge))
|
|
202
430
|
finally:
|
|
203
431
|
client.delete_conversation(conv_id)
|
|
204
432
|
finally:
|
|
205
433
|
client.close()
|
|
206
434
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
best = max(
|
|
435
|
+
pass_at_k = any(r.passed for r in run_results)
|
|
436
|
+
pass_power_k = all(r.passed for r in run_results)
|
|
437
|
+
# A run whose open verdict is the judge's has none, so it ranks below every graded run, as JudgeVerdict.rank does.
|
|
438
|
+
open_error = _open_harness_error(spec)
|
|
439
|
+
best = max(
|
|
440
|
+
run_results,
|
|
441
|
+
key=lambda r: (r.passed, open_error(r) is None, sum(r.checks.values()), r.tool_correct, r.tool_selected),
|
|
442
|
+
)
|
|
212
443
|
return AgenticSearchSummary(
|
|
213
444
|
run_results=run_results,
|
|
214
445
|
pass_at_k=pass_at_k,
|
|
@@ -217,23 +448,71 @@ def run_agentic_search_tool(
|
|
|
217
448
|
)
|
|
218
449
|
|
|
219
450
|
|
|
451
|
+
def _expectation(expected_tool_call: dict | None, expected_output: dict | None) -> SearchExpectation:
|
|
452
|
+
"""The item's expectation from either calling convention.
|
|
453
|
+
|
|
454
|
+
Raises:
|
|
455
|
+
ValueError: ``expected_output`` or ``expected_tool_call`` is malformed.
|
|
456
|
+
"""
|
|
457
|
+
if expected_output is None:
|
|
458
|
+
return SearchExpectation(tool_args=check_arguments({} if expected_tool_call is None else expected_tool_call))
|
|
459
|
+
spec = parse_expectation(expected_output)
|
|
460
|
+
if "tool_call" in expected_output or expected_tool_call is None:
|
|
461
|
+
return spec
|
|
462
|
+
return replace(spec, tool_args=check_arguments(expected_tool_call))
|
|
463
|
+
|
|
464
|
+
|
|
220
465
|
class SearchToolAssertionError(AgenticAssertionError):
|
|
221
466
|
"""Raised when a search-tool evaluation fails."""
|
|
222
467
|
|
|
223
468
|
|
|
224
|
-
def
|
|
225
|
-
"""The
|
|
469
|
+
def _gating_checks(run: SearchResult, spec: SearchExpectation) -> dict[str, bool]:
|
|
470
|
+
"""The run's checks that decide it: none for a report-only item, and never one the judge could not grade."""
|
|
471
|
+
if spec.report_only:
|
|
472
|
+
return {}
|
|
473
|
+
return {name: ok for name, ok in run.checks.items() if name not in run.harness_checks}
|
|
474
|
+
|
|
226
475
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
476
|
+
def _check_scores(run: SearchResult, spec: SearchExpectation) -> dict[str, bool]:
|
|
477
|
+
"""The run's check scores by published name, ``<name>_diagnostic`` for a check that does not gate the item.
|
|
478
|
+
|
|
479
|
+
tool_correctness informs on every item, so it keeps its name. A check the judge could not grade is left out,
|
|
480
|
+
and so is every score of a run whose turn failed: it measured nothing.
|
|
481
|
+
"""
|
|
482
|
+
if run.exit_reason is not None:
|
|
483
|
+
return {}
|
|
484
|
+
selection = "tool_selection" if spec.search_required else f"tool_selection{_DIAGNOSTIC_SUFFIX}"
|
|
485
|
+
suffix = _DIAGNOSTIC_SUFFIX if spec.report_only else ""
|
|
486
|
+
scores = {selection: run.tool_selected}
|
|
487
|
+
if spec.tool_args:
|
|
488
|
+
scores["tool_correctness"] = run.tool_correct
|
|
489
|
+
scores.update({f"{name}{suffix}": ok for name, ok in run.checks.items() if name not in run.harness_checks})
|
|
490
|
+
return scores
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
def _verdict_fields(run: SearchResult, spec: SearchExpectation) -> dict[str, Any]:
|
|
494
|
+
"""The run's gating verdicts as top-level booleans of its detail, which the report's quality score counts.
|
|
495
|
+
|
|
496
|
+
What does not gate sits under ``diagnostics``: the search verdicts of an item that needs no search, and
|
|
497
|
+
the checks of a report-only item. A run whose turn failed has no search verdicts, as nothing was measured.
|
|
230
498
|
"""
|
|
231
|
-
|
|
232
|
-
"tool_selected": run.tool_selected,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
499
|
+
searched = (
|
|
500
|
+
{} if run.exit_reason is not None else {"tool_selected": run.tool_selected, "tool_correct": run.tool_correct}
|
|
501
|
+
)
|
|
502
|
+
fields: dict[str, Any] = dict(searched) if spec.search_required else {}
|
|
503
|
+
fields.update(_gating_checks(run, spec))
|
|
504
|
+
diagnostics: dict[str, bool] = {} if spec.search_required else dict(searched)
|
|
505
|
+
if spec.report_only:
|
|
506
|
+
diagnostics.update({name: ok for name, ok in run.checks.items() if name not in run.harness_checks})
|
|
507
|
+
if diagnostics:
|
|
508
|
+
fields["diagnostics"] = diagnostics
|
|
509
|
+
if run.check_details:
|
|
510
|
+
fields["check_details"] = run.check_details
|
|
511
|
+
if run.harness_error:
|
|
512
|
+
fields["harness_error"] = run.harness_error
|
|
513
|
+
if run.exit_reason is not None:
|
|
514
|
+
fields["exit_reason"] = run.exit_reason.value
|
|
515
|
+
return fields
|
|
237
516
|
|
|
238
517
|
|
|
239
518
|
def evaluate_agentic_search_tool(
|
|
@@ -241,7 +520,7 @@ def evaluate_agentic_search_tool(
|
|
|
241
520
|
token: str,
|
|
242
521
|
workspace_id: str,
|
|
243
522
|
question: str,
|
|
244
|
-
expected_tool_call: dict,
|
|
523
|
+
expected_tool_call: dict | None = None,
|
|
245
524
|
k: int = _DEFAULT_K,
|
|
246
525
|
initial_conversation_id: str | None = None,
|
|
247
526
|
agent_id: str | None = None,
|
|
@@ -254,6 +533,7 @@ def evaluate_agentic_search_tool(
|
|
|
254
533
|
reasoning_effort: ReasoningEffort | None = None,
|
|
255
534
|
submit_trace_link: SubmitTraceLink = run_trace_link_inline,
|
|
256
535
|
user_context: dict | None = None,
|
|
536
|
+
expected_output: dict | None = None,
|
|
257
537
|
gate: EvalGate = DEFAULT_GATE,
|
|
258
538
|
) -> AgenticEvalOutcome:
|
|
259
539
|
"""Run search-tool evaluation, log to Langfuse, and raise SearchToolAssertionError on failure.
|
|
@@ -261,7 +541,12 @@ def evaluate_agentic_search_tool(
|
|
|
261
541
|
Returns the best run's outcome (reasoning_steps, conversation_id, response_id) as an
|
|
262
542
|
AgenticEvalOutcome on success; on failure the same three values are attached to the
|
|
263
543
|
raised exception as ``.reasoning_steps``/``.conversation_id``/``.response_id``.
|
|
544
|
+
``expected_tool_call`` and ``expected_output`` are read as in ``run_agentic_search_tool``.
|
|
545
|
+
|
|
546
|
+
Raises:
|
|
547
|
+
ValueError: ``expected_output`` or ``expected_tool_call`` is malformed. Raised before any request.
|
|
264
548
|
"""
|
|
549
|
+
spec = _expectation(expected_tool_call, expected_output)
|
|
265
550
|
identity = RunIdentity(
|
|
266
551
|
host,
|
|
267
552
|
token,
|
|
@@ -285,8 +570,30 @@ def evaluate_agentic_search_tool(
|
|
|
285
570
|
reasoning_effort=reasoning_effort,
|
|
286
571
|
agent_id=agent_id,
|
|
287
572
|
user_context=user_context,
|
|
573
|
+
expected_output=expected_output,
|
|
288
574
|
)
|
|
289
575
|
|
|
576
|
+
# Before the Langfuse scores, so an ERROR run gets its marker beside its usual scores.
|
|
577
|
+
open_error = _open_harness_error(spec)
|
|
578
|
+
run_labels = label_runs(summary.run_results, passed=lambda r: r.passed, judge_error=open_error)
|
|
579
|
+
# The runs left without a verdict because the judge's was the one still open. A passing run is not one.
|
|
580
|
+
ungraded = sum(1 for r in summary.run_results if not r.passed and open_error(r) is not None)
|
|
581
|
+
|
|
582
|
+
def _strict(run: SearchResult) -> dict[str, bool]:
|
|
583
|
+
# A run whose turn failed measured nothing, so its quality rests on the run's own verdict.
|
|
584
|
+
measured = spec.search_required and run.exit_reason is None
|
|
585
|
+
strict = {"tool_selection": run.tool_selected} if measured else {}
|
|
586
|
+
strict.update(_gating_checks(run, spec))
|
|
587
|
+
return strict or {"passed": run.passed}
|
|
588
|
+
|
|
589
|
+
def _run_detail(run: SearchResult) -> dict:
|
|
590
|
+
"""The diagnostic fields for ONE run, shared by the best run and every failing one."""
|
|
591
|
+
return {
|
|
592
|
+
**_verdict_fields(run, spec),
|
|
593
|
+
"tool_call_names": run.tool_call_names,
|
|
594
|
+
"latency_breakdown": build_latency_breakdown(run.tool_call_events, run.reasoning_step_events),
|
|
595
|
+
}
|
|
596
|
+
|
|
290
597
|
if langfuse is not None and dataset_item_id:
|
|
291
598
|
# Pinned on the calling thread: a deferred poll must not widen its query window.
|
|
292
599
|
window_end = utc_now()
|
|
@@ -299,12 +606,14 @@ def evaluate_agentic_search_tool(
|
|
|
299
606
|
with ctx.observe(
|
|
300
607
|
pt, run_idx, conversation_id=run.conversation_id, output={"tool_selection": run.tool_selected}
|
|
301
608
|
) as tid:
|
|
302
|
-
|
|
303
|
-
|
|
609
|
+
if (run_error := run_labels.error_label(run_idx)) is not None:
|
|
610
|
+
log_eval_error_score(ctx, tid, run_error)
|
|
611
|
+
for name, ok in _check_scores(run, spec).items():
|
|
612
|
+
ctx.score(tid, name=name, value=float(ok), data_type="BOOLEAN")
|
|
304
613
|
log_gate_scores(ctx, tid, gate=gate, pass_at_k=summary.pass_at_k, pass_power_k=summary.pass_power_k)
|
|
305
614
|
ctx.quality(
|
|
306
615
|
tid,
|
|
307
|
-
strict_checks=
|
|
616
|
+
strict_checks=_strict(run),
|
|
308
617
|
latency_sec=pt.latency if pt else None,
|
|
309
618
|
cost_usd=pt.total_cost if pt else None,
|
|
310
619
|
)
|
|
@@ -324,32 +633,54 @@ def evaluate_agentic_search_tool(
|
|
|
324
633
|
item_input=question,
|
|
325
634
|
)
|
|
326
635
|
|
|
327
|
-
runs_passed = sum(1 for r in summary.run_results if r.
|
|
636
|
+
runs_passed = sum(1 for r in summary.run_results if r.passed)
|
|
328
637
|
runs_effective = len(summary.run_results)
|
|
329
638
|
|
|
639
|
+
def _failed_checks(run: SearchResult) -> list[dict]:
|
|
640
|
+
if run.exit_reason is not None:
|
|
641
|
+
# The failed turn, setup_turn or question_turn: no check ran.
|
|
642
|
+
return failed_check_records([FailedCheck(turn, actual=why) for turn, why in run.check_details.items()])
|
|
643
|
+
checks: list[FailedCheck] = []
|
|
644
|
+
if spec.search_required and not run.tool_selected:
|
|
645
|
+
checks.append(FailedCheck("tool_selection", expected=True, actual=run.tool_call_names))
|
|
646
|
+
# An ungraded check is listed only where it gates: a report-only item's checks never fail its run.
|
|
647
|
+
open_checks = {} if spec.report_only else {name: run.checks[name] for name in run.harness_checks}
|
|
648
|
+
checks += [
|
|
649
|
+
FailedCheck(name, expected=True, actual=run.check_details.get(name, False))
|
|
650
|
+
for name, ok in {**_gating_checks(run, spec), **open_checks}.items()
|
|
651
|
+
if not ok
|
|
652
|
+
]
|
|
653
|
+
return failed_check_records(checks)
|
|
654
|
+
|
|
330
655
|
best = summary.best
|
|
331
656
|
detail = agentic_detail(
|
|
332
657
|
best.tool_call_events,
|
|
333
658
|
best.reasoning_step_events,
|
|
334
|
-
|
|
335
|
-
tool_correct=best.tool_correct,
|
|
659
|
+
**_verdict_fields(best, spec),
|
|
336
660
|
tool_call_names=best.tool_call_names,
|
|
661
|
+
# Only present when it happened, so the usual detail is unchanged. The CLI reports it as runs_ungraded.
|
|
662
|
+
**({"unscored_runs": ungraded} if ungraded else {}),
|
|
337
663
|
)
|
|
338
664
|
# Same predicate pass@K and runs_passed are taken over, so an item's failed_runs and its
|
|
339
665
|
# counts cannot disagree about which runs failed.
|
|
340
666
|
failed_runs = build_failed_runs(
|
|
341
667
|
summary.run_results,
|
|
342
|
-
|
|
668
|
+
labels=run_labels,
|
|
343
669
|
detail=_run_detail,
|
|
670
|
+
failed_checks=_failed_checks,
|
|
344
671
|
)
|
|
345
672
|
|
|
346
673
|
if not gate_passed(gate, pass_at_k=summary.pass_at_k, pass_power_k=summary.pass_power_k):
|
|
347
|
-
gate_note =
|
|
674
|
+
gate_note = failure_message_head(gate, run_labels, runs_passed, failed_runs, ungraded)
|
|
675
|
+
failing = [record["name"] for record in _failed_checks(best)]
|
|
676
|
+
checks_str = f" Failed checks: {', '.join(failing)}; details: {best.check_details}." if failing else ""
|
|
348
677
|
raise_agentic_failure(
|
|
349
678
|
SearchToolAssertionError,
|
|
350
679
|
f"Search tool assertion failed. {gate_note} "
|
|
351
680
|
f"tool_selected={best.tool_selected}, tool_correct={best.tool_correct}. "
|
|
352
|
-
f"Tool calls made: {best.tool_call_names}",
|
|
681
|
+
f"Tool calls made: {best.tool_call_names}.{checks_str}",
|
|
682
|
+
harness_error=run_labels.harness_error_record,
|
|
683
|
+
shadow=run_labels.shadow(gate),
|
|
353
684
|
reasoning_steps=best.reasoning_steps,
|
|
354
685
|
conversation_id=best.conversation_id,
|
|
355
686
|
response_id=best.response_id,
|
|
@@ -361,6 +692,7 @@ def evaluate_agentic_search_tool(
|
|
|
361
692
|
run_latencies_s=[r.run_latency_s for r in summary.run_results],
|
|
362
693
|
)
|
|
363
694
|
return agentic_success(
|
|
695
|
+
shadow=run_labels.shadow(gate),
|
|
364
696
|
reasoning_steps=best.reasoning_steps,
|
|
365
697
|
conversation_id=best.conversation_id,
|
|
366
698
|
response_id=best.response_id,
|
|
@@ -108,8 +108,13 @@ class AgenticRunSummary:
|
|
|
108
108
|
def generate_simulated_response(agent_message: str, expected_output: CreatedVisualization) -> str:
|
|
109
109
|
"""Generate a simulated user reply to an agent clarification question.
|
|
110
110
|
|
|
111
|
-
Uses OpenAI gpt-5.2 to produce a realistic reply that guides the agent
|
|
112
|
-
|
|
111
|
+
Uses OpenAI gpt-5.2 to produce a realistic reply that guides the agent toward the
|
|
112
|
+
expected visualization without revealing the answer directly. Objects are named in words
|
|
113
|
+
made from their ids (`uri_to_display_name`: `metric/total_returns` -> "total returns"), not
|
|
114
|
+
by their titles, which are not available here, and never as `{type/id}` references: a goal
|
|
115
|
+
of references makes the simulated user volunteer them, handing the agent objects it should
|
|
116
|
+
resolve itself. A date filter names its date dataset the same way, without which the
|
|
117
|
+
simulated user cannot say which date "2024" means.
|
|
113
118
|
Requires the [llm-judge] extra: pip install gooddata-eval[llm-judge]
|
|
114
119
|
"""
|
|
115
120
|
try:
|
|
@@ -138,10 +143,12 @@ def generate_simulated_response(agent_message: str, expected_output: CreatedVisu
|
|
|
138
143
|
granularity = filter_dict.get("granularity", "")
|
|
139
144
|
from_val = filter_dict.get("from", "")
|
|
140
145
|
to_val = filter_dict.get("to", "")
|
|
146
|
+
dataset = filter_dict.get("using")
|
|
147
|
+
on_dataset = f" on the {uri_to_display_name(dataset)}" if isinstance(dataset, str) and dataset else ""
|
|
141
148
|
filter_parts.append(
|
|
142
|
-
f"date filter: {granularity} from {from_val} to {to_val}"
|
|
149
|
+
f"date filter{on_dataset}: {granularity} from {from_val} to {to_val}"
|
|
143
150
|
if granularity
|
|
144
|
-
else f"date filter: {from_val} to {to_val}"
|
|
151
|
+
else f"date filter{on_dataset}: {from_val} to {to_val}"
|
|
145
152
|
)
|
|
146
153
|
elif ft == "ranking_filter":
|
|
147
154
|
n = filter_dict.get("top") or filter_dict.get("bottom")
|
|
@@ -196,7 +203,9 @@ def generate_simulated_response(agent_message: str, expected_output: CreatedVisu
|
|
|
196
203
|
f"Respond naturally to the agent's question. Be helpful and answer what they're asking about.\n"
|
|
197
204
|
f"If the agent asks specifically about items from your goal (like which metrics or dimensions "
|
|
198
205
|
f"you want), you should mention them. Keep your response concise and natural, as a real user would."
|
|
199
|
-
f"{no_filter_hint}"
|
|
206
|
+
f"{no_filter_hint}\n"
|
|
207
|
+
f"If the agent offers alternatives, choose the one that matches your goal and repeat it as the "
|
|
208
|
+
f"agent wrote it."
|
|
200
209
|
),
|
|
201
210
|
},
|
|
202
211
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: gooddata-eval
|
|
3
|
-
Version: 1.80.1.
|
|
3
|
+
Version: 1.80.1.dev5
|
|
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.
|
|
21
|
+
Requires-Dist: gooddata-sdk~=1.80.1.dev5
|
|
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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
gooddata_eval/__init__.py,sha256=9Nz0iJXzkJWiL40PijM6AMpAqQOH-dbYNfDtDysBPYc,186
|
|
2
2
|
gooddata_eval/_version.py,sha256=L4nT6RJQ2vc_F9stvO59xZv92xsRUqbpUh1sGlb-UNU,195
|
|
3
3
|
gooddata_eval/cli/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
|
|
4
|
-
gooddata_eval/cli/agentic_runner.py,sha256=
|
|
4
|
+
gooddata_eval/cli/agentic_runner.py,sha256=kOmhscLvnxSYOO68U74pOa9xgi6JfZwk_YGUyTv9hk8,33154
|
|
5
5
|
gooddata_eval/cli/main.py,sha256=_SEw16H2Hc772K-TB9tZyZKUlL_k695KM--aYitaIa8,34790
|
|
6
6
|
gooddata_eval/core/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
|
|
7
7
|
gooddata_eval/core/_output.py,sha256=sFbNtKg1lx431jpb15jISLlOXGTZ-r_KodfaTVyka6I,580
|
|
@@ -28,8 +28,9 @@ gooddata_eval/core/agentic/_filters.py,sha256=arAesTihu67a-1xccREfN1KBj46Jm-dOJr
|
|
|
28
28
|
gooddata_eval/core/agentic/_gate.py,sha256=9hwdjSm8RFPw9I-NF4s4hTUcVl1aD9RWp8RcRvLdp7U,3074
|
|
29
29
|
gooddata_eval/core/agentic/_langfuse.py,sha256=74_pf1XU6fQG6qrgRB18XYrMlO69tnH1uNi5TJWPt-o,29706
|
|
30
30
|
gooddata_eval/core/agentic/_outcome.py,sha256=AL1ULyD9zpC8A-MhyLp2CW68Rnezl39heRkHr7xcbEA,13478
|
|
31
|
+
gooddata_eval/core/agentic/_search_expectation.py,sha256=I_NSxfuT0r5uOwvGe6hCcgpeGvdtLAcCki_RgELJaes,13964
|
|
31
32
|
gooddata_eval/core/agentic/_trace_linker.py,sha256=Bc-UOPB3bcJqb6kmHnkMnbNVbZPPB7Dn5awM7bNm-qY,15851
|
|
32
|
-
gooddata_eval/core/agentic/alert_skill.py,sha256=
|
|
33
|
+
gooddata_eval/core/agentic/alert_skill.py,sha256=N0gWOPiETnA83wLOoDZ4QNjcxXm2oDMv7x9CNEuemAg,63623
|
|
33
34
|
gooddata_eval/core/agentic/anomaly_detection.py,sha256=XMd0zsS3hgASJND6UwhNXdoBXUzDm_pMuGS2Dv-1FNg,30053
|
|
34
35
|
gooddata_eval/core/agentic/conversation.py,sha256=AC-k4ju2Ic_X8UkERLWHstNKKBGTtrj7p-Ld-82K8T8,75946
|
|
35
36
|
gooddata_eval/core/agentic/dashboard_skill.py,sha256=eHQWVcoYIBc0QCJnu4VmpZVMffNHckSCYuBo67a-asE,132462
|
|
@@ -41,8 +42,8 @@ gooddata_eval/core/agentic/guardrail.py,sha256=_7-nlBNVnGaYJx9Oq8V08npe1IunxgwH1
|
|
|
41
42
|
gooddata_eval/core/agentic/kda_skill.py,sha256=L89qH8-cUzJxr105GsGC7WK4Cpg6i_M8wbUca8Wf-2Y,27881
|
|
42
43
|
gooddata_eval/core/agentic/metric_skill.py,sha256=OIykX-TQD8tLh1EpS_07LmY4m_AbjADVbPg5AAptGEY,31749
|
|
43
44
|
gooddata_eval/core/agentic/report_skill.py,sha256=ZpuKuQpor56ywDKauzQKAx18vFHcW6uq3nFgV2GjVvM,1583
|
|
44
|
-
gooddata_eval/core/agentic/search_tool.py,sha256=
|
|
45
|
-
gooddata_eval/core/agentic/visualization.py,sha256=
|
|
45
|
+
gooddata_eval/core/agentic/search_tool.py,sha256=oo5hPlEp4gabz_gsMzcn_dYn0T8tbjmq6PDA5K1Oak8,30553
|
|
46
|
+
gooddata_eval/core/agentic/visualization.py,sha256=TmXCe5cUQoWebAUQlbJYO0LohVIamBHgb_-5uRsQDNI,39239
|
|
46
47
|
gooddata_eval/core/agentic/what_if.py,sha256=AA3DJOrtezRLnUxzq48olwSgDQN6Qfwqfbx5XnsQhrA,28746
|
|
47
48
|
gooddata_eval/core/catalog/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
|
|
48
49
|
gooddata_eval/core/catalog/evaluate.py,sha256=Uf4ABvlIY0ks5OKTUpJsoFKHBai390cPidzFZIro_ZE,11373
|
|
@@ -89,8 +90,8 @@ gooddata_eval/core/summary/http_client.py,sha256=Umae42fiiJQ0e4hv63NRROHYvcFAGgX
|
|
|
89
90
|
gooddata_eval/core/takeaway/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
|
|
90
91
|
gooddata_eval/core/takeaway/evaluate.py,sha256=AjS_rCHWUSJKv0jfEfL0-dVPoDaf3RkGdmeZiIwjd6A,11312
|
|
91
92
|
gooddata_eval/core/takeaway/http_client.py,sha256=YMfafOcHJ184i49Qoh0ZNPKKTMKBSgeDUM4zk_H3yM8,3955
|
|
92
|
-
gooddata_eval-1.80.1.
|
|
93
|
-
gooddata_eval-1.80.1.
|
|
94
|
-
gooddata_eval-1.80.1.
|
|
95
|
-
gooddata_eval-1.80.1.
|
|
96
|
-
gooddata_eval-1.80.1.
|
|
93
|
+
gooddata_eval-1.80.1.dev5.dist-info/METADATA,sha256=14HnUxxTW6x1vVnGyOzAHSni2tXTDbV0AiS4fuPj9es,66070
|
|
94
|
+
gooddata_eval-1.80.1.dev5.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
95
|
+
gooddata_eval-1.80.1.dev5.dist-info/entry_points.txt,sha256=28nFp5Viknx4haPYgzK9QHlwPFfC6rPF6RmjC2ht8EI,56
|
|
96
|
+
gooddata_eval-1.80.1.dev5.dist-info/licenses/LICENSE.txt,sha256=LVfVlC9maU3K9lgMwdZnClQQsOIbOekdcdVKr9qzJtk,256836
|
|
97
|
+
gooddata_eval-1.80.1.dev5.dist-info/RECORD,,
|
|
File without changes
|
{gooddata_eval-1.80.1.dev4.dist-info → gooddata_eval-1.80.1.dev5.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{gooddata_eval-1.80.1.dev4.dist-info → gooddata_eval-1.80.1.dev5.dist-info}/licenses/LICENSE.txt
RENAMED
|
File without changes
|