Skip to content
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ All notable changes to SkillEvaluator are documented in this file.
JSON report lists the files in `semgrep_unparsed_files` (up to 1,000, with
`semgrep_unparsed_files_omitted` counting the rest); other Semgrep errors are
reported as before.
- Failed native skill lookups no longer count as activation when the tool reports
that the skill was not found or unavailable without explicit error metadata.
- Tier 3 terminal, JSON, HTML, and benchmark reports now retain declarative-check
coverage per agent and arm, including passed/failed counts, judgments,
not-checked reasons, and the behavior-score denominators.
Expand Down
29 changes: 18 additions & 11 deletions src/skillevaluator/tier3/eval_core/codex_tool_call_normalizer.py
Comment thread
chrisknvidia marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ def normalized_tool_call_observation(step: dict[str, Any], tool_call: dict[str,


def normalized_tool_call_error_flag(step: dict[str, Any], tool_call: dict[str, Any]) -> bool | None:
"""Return an attributable tool result's explicit ``tool_result_is_error`` flag.
"""Return an attributable result's error flag, including metadata-free skill lookup failures.

``True`` if any attributable result reports an error, ``False`` if they
explicitly report success, and ``None`` when none carries the flag.
explicitly report success, and ``None`` when neither metadata nor a lookup failure is present.
"""
if tool_call.get("_atif_observation_status") not in (None, MAPPED_OUTER_EXEC_OBSERVATION):
return None
Expand All @@ -113,6 +113,16 @@ def normalized_tool_call_error_flag(step: dict[str, Any], tool_call: dict[str, A
# Unscoped observations cannot prove that this particular call failed.
if not tool_call_id or source_call_id != tool_call_id:
continue
if str(tool_call.get("function_name", "")).lower() == "skill":
observation = atif_content_text(result.get("content")).strip()
if re.match(
r"^(?:error:\s*)?(?:skill\s+(?:(?:[\"'`][^\"'`\n]+[\"'`]|[\w./-]+)\s+)?"
r"(?:is\s+)?(?:not found|not available|unavailable)\b|unknown skill\b"
r"|(?:could not|unable to|cannot|can't)\s+(?:find|load|access)\s+(?:the\s+)?skill\b)",
observation,
re.IGNORECASE,
):
return True
extra = result.get("extra") or {}
if not isinstance(extra, dict):
continue
Expand All @@ -124,7 +134,7 @@ def normalized_tool_call_error_flag(step: dict[str, Any], tool_call: dict[str, A


def normalized_tool_call_is_error(step: dict[str, Any], tool_call: dict[str, Any]) -> bool:
"""Preserve explicit failure metadata only for an attributable tool result."""
"""Reject attributable failed tool results, including unsuccessful skill lookups."""
return normalized_tool_call_error_flag(step, tool_call) is True


Expand Down Expand Up @@ -1376,7 +1386,9 @@ def _normalize_tool_call_with_records(tool_call: dict[str, Any]) -> list[dict[st
"""Unwrap proven native Codex calls, adding the inline and allSettled forms of #235."""
normalized = _upstream_normalize_tool_call(tool_call)
arguments = tool_call.get("arguments")
source = arguments.get("input") if tool_call.get("function_name") == "exec" and isinstance(arguments, dict) else None
source = (
arguments.get("input") if tool_call.get("function_name") == "exec" and isinstance(arguments, dict) else None
)
parsed = _extended_codex_program(source) if isinstance(source, str) and len(source) <= _MAX_SOURCE_CHARS else None
if parsed is None:
if "_atif_inner_tool_index" in normalized[0] and _has_non_js_space(source):
Expand Down Expand Up @@ -1469,14 +1481,9 @@ def _normalized_tool_call_observation_with_records(step: dict[str, Any], tool_ca
return _upstream_normalized_tool_call_observation(step, tool_call)


def _normalized_tool_call_error_flag_with_records(
step: dict[str, Any], tool_call: dict[str, Any]
) -> bool | None:
def _normalized_tool_call_error_flag_with_records(step: dict[str, Any], tool_call: dict[str, Any]) -> bool | None:
"""Report a call's own record outcome, which may be unknown, before the upstream flag."""
if (
tool_call.get("_atif_observation_status") == MAPPED_OUTER_EXEC_OBSERVATION
and _RECORD_IS_ERROR in tool_call
):
if tool_call.get("_atif_observation_status") == MAPPED_OUTER_EXEC_OBSERVATION and _RECORD_IS_ERROR in tool_call:
return tool_call[_RECORD_IS_ERROR]
return _upstream_normalized_tool_call_error_flag(step, tool_call)

Expand Down
57 changes: 57 additions & 0 deletions tests/tier3/test_failed_skill_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,63 @@ def test_failed_native_skill_call_is_not_activation(grader) -> None:
assert scorer.check_routing(calls, "demo-skill", skill_tool_names=[])["score"] == 0.0


@pytest.mark.parametrize(
"content",
[
'Skill "demo-skill" not found. Available skills: other',
"Skill not found",
"Error: Skill demo-skill is unavailable",
"Skill 'demo-skill' not available",
"Unknown skill: demo-skill",
"Unable to load skill demo-skill",
],
)
@pytest.mark.parametrize("name", ["Skill", "skill"])
@pytest.mark.parametrize("error_metadata", [None, False])
def test_failed_skill_lookup_is_not_activation(grader, content, name, error_metadata) -> None:
extractor, scorer = grader
trajectory = _claude_tool_result(name=name, arguments={"name": "demo-skill"}, is_error=False, content=content)
for step in trajectory["steps"]:
for result in (step.get("observation") or {}).get("results", []):
if error_metadata is None:
result.pop("extra", None)
else:
result["extra"] = {"tool_result_is_error": error_metadata}
calls = extractor.extract_tool_calls_as_dicts(trajectory)
names = extractor.get_skill_tool_calls(trajectory)
assert names == []
assert calls[0]["is_error"] is True
assert scorer.check_activation(calls, "demo-skill", skill_tool_names=names)["score"] == 0.0
assert scorer.check_routing(calls, "demo-skill", skill_tool_names=names)["score"] == 0.0


@pytest.mark.parametrize("content", ["", "Launching skill: demo-skill", "# Demo skill\nSkill not found: retry it."])
def test_successful_or_unobserved_skill_lookup_is_preserved(grader, content) -> None:
extractor, scorer = grader
trajectory = _claude_tool_result(name="Skill", arguments={"skill": "demo-skill"}, is_error=False, content=content)
names = extractor.get_skill_tool_calls(trajectory)
assert names == ["demo-skill"]
calls = extractor.extract_tool_calls_as_dicts(trajectory)
assert scorer.check_activation(calls, "demo-skill", skill_tool_names=names)["score"] == 1.0


@pytest.mark.parametrize("source_call_id", [None, "unrelated-call"])
def test_unrelated_lookup_failure_does_not_reject_successful_skill_call(grader, source_call_id) -> None:
extractor, scorer = grader
trajectory = _claude_tool_result(
name="Skill", arguments={"skill": "demo-skill"}, is_error=False, content="Launching skill: demo-skill"
)
for step in trajectory["steps"]:
results = (step.get("observation") or {}).get("results")
if results:
results.insert(0, {"source_call_id": source_call_id, "content": "Skill not found\n"})
calls = extractor.extract_tool_calls_as_dicts(trajectory)
names = extractor.get_skill_tool_calls(trajectory)
assert names == ["demo-skill"]
assert calls[0].get("is_error") is not True
assert scorer.check_activation(calls, "demo-skill", skill_tool_names=names)["score"] == 1.0


def test_opencode_failed_read_is_marked_as_error(grader) -> None:
from skillevaluator.tier3.eval_core.log_converters import synthetic_trajectory_from_opencode_json

Expand Down
Loading