Repository navigation
feat(gooddata-eval): populate best_run_latency_s for agentic evaluators #1845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
177025b
feat(gooddata-eval): populate best_run_latency_s for agentic evaluators
Tomkess 887c536
refactor(gooddata-eval): centralize agentic outcome fields; fix exit_…
Tomkess 92cd8ea
fix(gooddata-eval): record a dashboard chat fault instead of letting …
Tomkess 84e33ec
style(gooddata-eval): annotate the three ChatError tests
Tomkess File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
packages/gooddata-eval/src/gooddata_eval/core/agentic/_outcome.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # (C) 2026 GoodData Corporation | ||
| """The common tail of every ``evaluate_agentic_*`` function. | ||
|
|
||
| Before this module, each of the agentic evaluators hand-wrote the same block: copy | ||
| ``reasoning_steps``/``conversation_id``/``response_id``/``detail``/``runs_passed``/ | ||
| ``runs_effective``/``best_run_latency_s`` (and sometimes ``timings``) either onto a | ||
| raised exception or into the returned ``AgenticEvalOutcome``. Eleven independent copies | ||
| of the same ~7 lines meant a new universal field needed eleven edits, not one, and | ||
| nothing failed loudly when a copy was missed -- exactly what happened to ``timings`` | ||
| (see ``AgenticAssertionError``'s docstring: "while it lived in eight copies, two | ||
| declared timings and six did not") and again to ``best_run_latency_s`` (every agentic | ||
| kind silently reported it as ``null`` until this was noticed and fixed kind-by-kind). | ||
|
|
||
| ``agentic_detail`` has the same motivation for the ``detail`` dict's timeline fields: | ||
| ``timeline_detail`` builds both ``latency_breakdown`` and ``tool_calls`` from the same | ||
| events so they stay index-aligned, but roughly half the evaluators called | ||
| ``build_latency_breakdown`` directly and silently never got a ``tool_calls`` key. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any, NoReturn | ||
|
|
||
| from gooddata_eval.core.models import ( | ||
| AgenticAssertionError, | ||
| AgenticEvalOutcome, | ||
| ReasoningStepEvent, | ||
| ToolCallEvent, | ||
| timeline_detail, | ||
| ) | ||
| from gooddata_eval.core.timing import PhaseTimings | ||
|
|
||
| __all__ = ["agentic_detail", "agentic_success", "raise_agentic_failure"] | ||
|
|
||
|
|
||
| def agentic_detail( | ||
| tool_call_events: list[ToolCallEvent], | ||
| reasoning_step_events: list[ReasoningStepEvent] | None, | ||
| **kind_specific: Any, | ||
| ) -> dict: | ||
| """A kind's full ``detail`` dict: its own fields plus the universal timeline ones. | ||
|
|
||
| ``kind_specific`` comes first in the merge so a kind can never accidentally shadow | ||
| ``latency_breakdown``/``tool_calls`` with a same-named field of its own. | ||
| """ | ||
| return {**kind_specific, **timeline_detail(tool_call_events, reasoning_step_events)} | ||
|
|
||
|
|
||
| def raise_agentic_failure( | ||
| exception_cls: type[AgenticAssertionError], | ||
| message: str, | ||
| *, | ||
| reasoning_steps: list[str], | ||
| conversation_id: str, | ||
| response_id: str | None, | ||
| detail: dict, | ||
| runs_passed: int, | ||
| runs_effective: int, | ||
| best_run_latency_s: float | None, | ||
| timings: PhaseTimings | None = None, | ||
| failed_runs: list[dict] | None = None, | ||
| run_latencies_s: list[float] | None = None, | ||
| ) -> NoReturn: | ||
| """Build ``exception_cls(message)`` with every common field attached, and raise it. | ||
|
|
||
| ``exception_cls`` must be an ``AgenticAssertionError`` subclass -- that base class is | ||
| what declares these fields as legal targets (see its docstring). A kind whose own | ||
| "no verdict at all" branch raises a bare ``JudgeResponseError`` instead (not a subclass) | ||
| does not go through this helper for that branch. | ||
|
|
||
| ``timings`` stays optional: only the three kinds that track per-run ``PhaseTimings`` | ||
| (general_question, metric_skill, dashboard_skill) pass one -- the rest keep their | ||
| own ``PhaseTimings()`` zero default, same as before this helper existed. ``failed_runs`` | ||
| and ``run_latencies_s`` are likewise optional: not every kind has built them by the | ||
| time it raises. | ||
| """ | ||
| exc = exception_cls(message) | ||
| exc.reasoning_steps = reasoning_steps | ||
| exc.conversation_id = conversation_id | ||
| exc.response_id = response_id | ||
| exc.detail = detail | ||
| exc.runs_passed = runs_passed | ||
| exc.runs_effective = runs_effective | ||
| exc.best_run_latency_s = best_run_latency_s | ||
| if timings is not None: | ||
| exc.timings = timings | ||
| if failed_runs is not None: | ||
| exc.failed_runs = failed_runs | ||
| if run_latencies_s is not None: | ||
| exc.run_latencies_s = run_latencies_s | ||
| raise exc | ||
|
|
||
|
|
||
| def agentic_success( | ||
| *, | ||
| reasoning_steps: list[str], | ||
| conversation_id: str | None, | ||
| response_id: str | None, | ||
| detail: dict, | ||
| runs_passed: int, | ||
| runs_effective: int, | ||
| best_run_latency_s: float | None, | ||
| timings: PhaseTimings | None = None, | ||
| failed_runs: list[dict] | None = None, | ||
| run_latencies_s: list[float] | None = None, | ||
| ) -> AgenticEvalOutcome: | ||
| """The success-path mirror of ``raise_agentic_failure`` -- same fields, same shape.""" | ||
| kwargs: dict[str, Any] = { | ||
| "reasoning_steps": reasoning_steps, | ||
| "conversation_id": conversation_id, | ||
| "response_id": response_id, | ||
| "detail": detail, | ||
| "runs_passed": runs_passed, | ||
| "runs_effective": runs_effective, | ||
| "best_run_latency_s": best_run_latency_s, | ||
| } | ||
| if timings is not None: | ||
| kwargs["timings"] = timings | ||
| if failed_runs is not None: | ||
| kwargs["failed_runs"] = failed_runs | ||
| if run_latencies_s is not None: | ||
| kwargs["run_latencies_s"] = run_latencies_s | ||
| return AgenticEvalOutcome(**kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore the conditional checks in the best-run
detail.The old detail spread
eval.checks(). It includedcomparison_correct,title_correctanddashboard_correctwhen the fixture asserts them. The newagentic_detail(...)call lists only nine fixed checks. An item that fails only ontitle_correctnow reports adetailwhere every boolean isTrue. This also inflatesquality_score, which counts the boolean keys inbest_detail. The per-run_run_detailstill useschecks(), so the winning run and the failed runs now have different keys.🐛 Proposed fix
Also add the conditional checks to the failure message at Lines 1297-1304, or the message hides the failing check.
Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid finding, will be handled separately: #1942