Skip to content
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Include schema-valid ATIF message content parts in final answers, conversation
summaries, and judge evidence references in the host and Harbor verifier.
Image and audio parts use markers without exposing their source paths.
- Brought the published documentation in line with 0.5.0. It now covers how
standard grading builds judge evidence and rebuilds trajectories from
OpenCode and Codex logs, structured judge output and retries, the evidence
Expand Down
16 changes: 8 additions & 8 deletions src/skillevaluator/tier3/eval_core/atif_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def get_agent_text(traj: dict[str, Any]) -> str:
parts: list[str] = []
for step in traj.get("steps", []):
if step.get("source") == "agent":
msg = step.get("message") or ""
if isinstance(msg, str) and msg.strip():
msg = atif_content_text(step.get("message"))
if msg.strip():
parts.append(msg)
return "\n".join(parts)

Expand All @@ -108,8 +108,8 @@ def get_final_response(traj: dict[str, Any]) -> str:
"""Get the last non-empty agent message from the trajectory."""
for step in reversed(traj.get("steps", [])):
if step.get("source") == "agent":
msg = step.get("message") or ""
if isinstance(msg, str) and msg.strip():
msg = atif_content_text(step.get("message"))
if msg.strip():
Comment thread
rng1995 marked this conversation as resolved.
Resolved
return msg
return ""

Expand Down Expand Up @@ -153,8 +153,8 @@ def build_conversation_summary(traj: dict[str, Any], question: str) -> str:
if content:
parts.append(f"Tool returned: {content[:400]}")

msg = step.get("message") or ""
if msg and isinstance(msg, str) and msg.strip() and not step.get("tool_calls"):
msg = atif_content_text(step.get("message"))
if msg.strip() and not step.get("tool_calls"):
parts.append(f"Agent: {msg[:1500]}")

final = get_final_response(traj)
Expand Down Expand Up @@ -502,8 +502,8 @@ def _final_response_ref(traj: dict[str, Any]) -> list[dict[str, Any]]:
step = steps[step_idx]
if step.get("source") != "agent":
continue
msg = step.get("message") or ""
if isinstance(msg, str) and msg.strip():
msg = atif_content_text(step.get("message"))
if msg.strip():
return [
_evidence_ref(
source="trajectory.json",
Expand Down
16 changes: 8 additions & 8 deletions src/skillevaluator/tier3/harbor/templates/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ def get_agent_text(traj):
parts = []
for step in traj.get("steps", []):
if step.get("source") == "agent":
msg = step.get("message") or ""
if isinstance(msg, str) and msg.strip():
msg = atif_content_text(step.get("message"))
if msg.strip():
parts.append(msg)
return "\n".join(parts)

Expand Down Expand Up @@ -472,8 +472,8 @@ def build_conversation_summary(traj, question):
content = atif_content_text(r.get("content"))
if content:
parts.append(f"Tool returned: {content[:400]}")
msg = step.get("message") or ""
if msg and isinstance(msg, str) and msg.strip() and not step.get("tool_calls"):
msg = atif_content_text(step.get("message"))
if msg.strip() and not step.get("tool_calls"):
parts.append(f"Agent: {msg[:1500]}")
return "\n".join(parts)

Expand Down Expand Up @@ -534,8 +534,8 @@ def _behavior_check_budget():
def _get_final_response(traj):
for step in reversed(traj.get("steps", [])):
if step.get("source") == "agent":
msg = step.get("message") or ""
if isinstance(msg, str) and msg.strip():
msg = atif_content_text(step.get("message"))
if msg.strip():
return msg
return ""

Expand Down Expand Up @@ -797,8 +797,8 @@ def _final_response_ref(traj):
step = steps[step_idx]
if step.get("source") != "agent":
continue
msg = step.get("message") or ""
if isinstance(msg, str) and msg.strip():
msg = atif_content_text(step.get("message"))
if msg.strip():
return [
_evidence_ref(
source="trajectory.json",
Expand Down
97 changes: 97 additions & 0 deletions tests/tier3/test_atif_message_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Schema-valid ATIF message parts must reach judge evidence and references."""

from __future__ import annotations

import json
from types import ModuleType

import pytest

from skillevaluator.tier3.eval_core import atif_helpers


def _trajectory(messages: list) -> dict:
from harbor.models.trajectories.trajectory import Trajectory

return Trajectory.model_validate(
{
"schema_version": "ATIF-v1.8",
"agent": {"name": "test-agent", "version": "test"},
"steps": [
{"step_id": index, "source": "agent", "message": message}
for index, message in enumerate(messages, start=1)
],
}
).to_json_dict()


@pytest.mark.parametrize(
("message", "expected"),
[
("The answer is 4.", "The answer is 4."),
([{"type": "text", "text": "The answer is 4."}], "The answer is 4."),
(
[{"type": "text", "text": "First line."}, {"type": "text", "text": "Second line."}],
"First line.\nSecond line.",
),
([], ""),
([{"type": "text", "text": " "}], ""),
],
)
def test_message_content_reaches_all_text_extractors(
harbor_eval_template: ModuleType,
message: str | list,
expected: str,
) -> None:
trajectory = _trajectory([message])

assert atif_helpers.get_agent_text(trajectory) == expected
assert atif_helpers.get_final_response(trajectory) == expected
assert harbor_eval_template.get_agent_text(trajectory) == expected
assert harbor_eval_template._get_final_response(trajectory) == expected
assert atif_helpers.build_conversation_summary(trajectory, "question") == (
harbor_eval_template.build_conversation_summary(trajectory, "question")
)


def test_last_nonempty_structured_answer_reaches_all_judges_and_refs(harbor_eval_template: ModuleType) -> None:
trajectory = _trajectory(["Earlier answer.", [{"type": "text", "text": "The answer is 4."}], []])

assert atif_helpers.get_final_response(trajectory) == "The answer is 4."
assert harbor_eval_template._get_final_response(trajectory) == "The answer is 4."
assert atif_helpers.get_agent_text(trajectory) == "Earlier answer.\nThe answer is 4."
assert "Agent: The answer is 4." in atif_helpers.build_conversation_summary(trajectory, "What is 2+2?")
shared = atif_helpers.build_metric_evidence_bundles(trajectory, "What is 2+2?", ground_truth="4")
verifier = harbor_eval_template.build_metric_evidence_bundles(trajectory, "What is 2+2?", ground_truth="4")
assert shared == verifier
for bundle in shared.values():
assert "The answer is 4." in bundle["prompt_evidence"]
final_refs = [ref for ref in bundle["evidence_refs"] if ref["kind"] == "final_response"]
assert len(final_refs) == 1
assert final_refs[0]["json_pointer"] == "/steps/1"
assert final_refs[0]["excerpt"] == "The answer is 4."


def test_multimodal_answer_uses_markers_without_media_paths(harbor_eval_template: ModuleType) -> None:
trajectory = _trajectory(
[
[
{"type": "text", "text": "Result attached."},
{"type": "image", "source": {"media_type": "image/png", "path": "/private/image-result.png"}},
{"type": "audio", "source": {"media_type": "audio/wav", "path": "/private/audio-result.wav"}},
]
]
)
expected = "Result attached.\n[image]\n[audio]"

assert atif_helpers.get_final_response(trajectory) == expected
assert harbor_eval_template._get_final_response(trajectory) == expected
shared = atif_helpers.build_metric_evidence_bundles(trajectory, "question")
verifier = harbor_eval_template.build_metric_evidence_bundles(trajectory, "question")
assert shared == verifier
for bundle in shared.values():
assert expected in bundle["prompt_evidence"]
assert "/private/" not in json.dumps(bundle)