-
Notifications
You must be signed in to change notification settings - Fork 4
feat(evaluator): promote generic agentic-use runtimes into the Agent-Eval SDK #256
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
Open
arpitsardhana
wants to merge
3
commits into
profbench-mvp-2
Choose a base branch
from
aalgo-258-runner-sdk/arpsingh
base: profbench-mvp-2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
90 changes: 90 additions & 0 deletions
90
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/attempts.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,90 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Helpers for shaping :class:`AgentEvalAttempt` values from runtime artifacts. | ||
|
|
||
| These are the runtime-agnostic pieces: the *scorable* status mapping and the | ||
| standard evidence-key builder. Platform-specific attempt construction (reading | ||
| proprietary artifact layouts, extra evidence keys) composes these in the adapter. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from nemo_evaluator_sdk.agent_eval.types import AgentEvalAttemptStatus | ||
| from nemo_evaluator_sdk.values.evidence import EvidenceDescriptor | ||
|
|
||
|
|
||
| def resolve_attempt_status(agent_ok: bool) -> AgentEvalAttemptStatus: | ||
| """Map an agent-phase outcome to a *scorable* attempt status. | ||
|
|
||
| :class:`~nemo_evaluator_sdk.agent_eval.evaluator.AgentEvaluator` excludes | ||
| ``status=="failed"`` from scoring (it short-circuits to a failed metric | ||
| result). An agent that ran but did not succeed must still be scored — e.g. as | ||
| a ``0`` — so pass-rate gating counts it instead of dropping it. We therefore | ||
| use ``"partial"`` for an executed-but-unsuccessful agent and reserve | ||
| ``"failed"`` for genuine attempt-*production* failures (which a runtime | ||
| surfaces by raising, not by emitting an unscorable attempt). | ||
| """ | ||
| return "completed" if agent_ok else "partial" | ||
|
|
||
|
|
||
| def standard_evidence_descriptors( | ||
| *, | ||
| logs_dir: str | Path, | ||
| final_state_dir: str | Path, | ||
| trace_path: str | Path | None = None, | ||
| initial_state_ref: str | None = None, | ||
| verifier_logs_dir: str | Path | None = None, | ||
| primary_log: str | None = None, | ||
| ) -> dict[str, EvidenceDescriptor]: | ||
| """Build the documented evidence map for an agent-eval attempt. | ||
|
|
||
| Standard keys: ``initial_state`` (task input filesystem, when staged), | ||
| ``trace`` (trajectory, ATIF-normalized when available), ``logs`` (agent log | ||
| dir), ``final_state`` (workspace), and ``verifier_logs`` (only when present). | ||
| Callers may add their own extension keys to the returned mapping. | ||
| """ | ||
| descriptors: dict[str, EvidenceDescriptor] = {} | ||
|
|
||
| if initial_state_ref: | ||
| descriptors["initial_state"] = EvidenceDescriptor( | ||
| kind="filesystem", | ||
| format="dir", | ||
| ref=str(initial_state_ref), | ||
| metadata={"role": "initial_state"}, | ||
| ) | ||
|
|
||
| if trace_path is not None: | ||
| trace_name = Path(trace_path).name | ||
| descriptors["trace"] = EvidenceDescriptor( | ||
| kind="trace", | ||
| format="atif" if trace_name.startswith("atif") else "json", | ||
| ref=str(trace_path), | ||
| ) | ||
|
|
||
| logs_metadata = {"primary_log": primary_log} if primary_log else {} | ||
| descriptors["logs"] = EvidenceDescriptor( | ||
| kind="logs", | ||
| format="dir", | ||
| ref=str(logs_dir), | ||
| metadata=logs_metadata, | ||
| ) | ||
|
|
||
| descriptors["final_state"] = EvidenceDescriptor( | ||
| kind="filesystem", | ||
| format="dir", | ||
| ref=str(final_state_dir), | ||
| metadata={"role": "final_state"}, | ||
| ) | ||
|
|
||
| if verifier_logs_dir is not None and Path(verifier_logs_dir).exists(): | ||
| descriptors["verifier_logs"] = EvidenceDescriptor( | ||
| kind="logs", | ||
| format="dir", | ||
| ref=str(verifier_logs_dir), | ||
| metadata={"role": "verifier"}, | ||
| ) | ||
|
|
||
| return descriptors |
79 changes: 79 additions & 0 deletions
79
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/common_metrics.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,79 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Reusable agent-eval metrics. | ||
|
|
||
| ``AgentPhaseSuccessMetric`` reads the agent-phase outcome stamped on attempt | ||
| metadata. ``EvidencePresenceMetric`` is a genuine *metric-over-evidence*: it | ||
| scores by inspecting ``candidate.evidence`` (a filesystem evidence handle) | ||
| rather than a reward written into metadata — the value proposition of scoring | ||
| over evidence instead of trusting a verifier's stamped reward. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from nemo_evaluator_sdk.metrics.protocol import MetricInput, MetricOutput, MetricOutputSpec, MetricResult | ||
|
|
||
|
|
||
| class AgentPhaseSuccessMetric: | ||
| """Score 1.0 when the agent phase exited successfully, else 0.0. | ||
|
|
||
| The metric ``type`` is overridable via the ``metric_type`` class attribute so | ||
| callers can namespace it; the output name stays ``agent_phase_success`` (which | ||
| gating reads as a reward signal). | ||
| """ | ||
|
|
||
| metric_type: str = "agent_phase_success" | ||
|
|
||
| @property | ||
| def type(self) -> str: | ||
| return self.metric_type | ||
|
|
||
| def output_spec(self) -> list[MetricOutputSpec]: | ||
| return [MetricOutputSpec.continuous_score("agent_phase_success")] | ||
|
|
||
| async def compute_scores(self, input: MetricInput) -> MetricResult: | ||
| agent_ok = bool(input.candidate.metadata.get("agent_ok")) | ||
| return MetricResult(outputs=[MetricOutput(name="agent_phase_success", value=1.0 if agent_ok else 0.0)]) | ||
|
|
||
|
|
||
| class EvidencePresenceMetric: | ||
| """Score 1.0 when a named filesystem evidence directory exists (and is non-empty). | ||
|
|
||
| Reads ``candidate.evidence`` directly — the canonical metric-over-evidence | ||
| pattern — so the score reflects what the agent actually produced on disk, | ||
| not a reward stamped into metadata by a verifier. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| evidence_name: str = "final_state", | ||
| output_name: str = "evidence_present", | ||
| require_non_empty: bool = True, | ||
| ) -> None: | ||
| self._evidence_name = evidence_name | ||
| self._output_name = output_name | ||
| self._require_non_empty = require_non_empty | ||
|
|
||
| @property | ||
| def type(self) -> str: | ||
| return "evidence_presence" | ||
|
|
||
| def output_spec(self) -> list[MetricOutputSpec]: | ||
| return [MetricOutputSpec.continuous_score(self._output_name)] | ||
|
|
||
| async def compute_scores(self, input: MetricInput) -> MetricResult: | ||
| score = 0.0 | ||
| evidence = input.candidate.evidence | ||
| if evidence is not None and evidence.get(self._evidence_name) is not None: | ||
| try: | ||
| handle = await evidence.filesystem(self._evidence_name) | ||
| if await handle.exists(): | ||
| if self._require_non_empty: | ||
| score = 1.0 if await handle.iter_paths(recursive=True) else 0.0 | ||
| else: | ||
| score = 1.0 | ||
| except (KeyError, ValueError): | ||
| score = 0.0 | ||
|
Comment on lines
+77
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a log here so we can surface something more specific details on why there's a 0 result. |
||
| return MetricResult(outputs=[MetricOutput(name=self._output_name, value=score)]) | ||
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.
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.
Maybe
[MetricOutputSpec.boolean("agent_phase_success")]instead? We can then update the compute scores to:Same point with
EvidencePresenceMetricbelow.