Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Claude Code and Cline log reconstruction skips non-object JSON events and
Cline tool payloads instead of discarding valid surrounding evidence with an exception.
- Malformed optional trajectory `final_metrics` leave condition usage unavailable
and no longer abort fresh or reused Tier 3 result collection.
- Allow GitHub all-tier CI to opt out of deployment records while retaining
Expand Down
9 changes: 9 additions & 0 deletions src/skillevaluator/tier3/eval_core/log_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def synthetic_trajectory_from_claude_stream_jsonl(text: str) -> dict[str, Any] |
except json.JSONDecodeError:
continue

if not isinstance(evt, dict):
continue

et = evt.get("type")
if et == "assistant":
msg = evt.get("message")
Expand Down Expand Up @@ -290,6 +293,9 @@ def synthetic_trajectory_from_cline_cli(text: str) -> dict[str, Any] | None:
except json.JSONDecodeError:
continue

if not isinstance(evt, dict):
continue

say = evt.get("say", "")
ask = evt.get("ask", "")
evt_text = evt.get("text", "")
Expand All @@ -300,6 +306,9 @@ def synthetic_trajectory_from_cline_cli(text: str) -> dict[str, Any] | None:
except (json.JSONDecodeError, TypeError):
tool_data = {}

if not isinstance(tool_data, dict):
continue

tool_name = tool_data.get("tool", "")
if tool_name == "useSkill":
path = tool_data.get("path", "")
Expand Down
75 changes: 75 additions & 0 deletions tests/tier3/test_log_event_shapes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Non-event JSON values must not discard valid surrounding agent evidence."""

import json
from pathlib import Path

import pytest

from skillevaluator.tier3.eval_core.log_converters import (
load_trajectory_with_fallback,
synthetic_trajectory_from_claude_stream_jsonl,
synthetic_trajectory_from_cline_cli,
)

CLAUDE_EVENTS = [
{
"type": "assistant",
"message": {"content": [{"type": "tool_use", "id": "t1", "name": "Bash", "input": {"command": "echo kept"}}]},
},
{"type": "user", "message": {"content": [{"type": "tool_result", "tool_use_id": "t1", "content": "kept"}]}},
{"type": "assistant", "message": {"content": "finished"}},
]
CLINE_EVENTS = [
{"say": "command", "text": "echo kept"},
{"ask": "command_output", "text": "kept"},
{"say": "completion_result", "text": "finished"},
]
NON_EVENTS = [None, [], False, 7, "noise"]


def _jsonl(events: list[object]) -> str:
return "\n".join(json.dumps(event) for event in events)


@pytest.mark.parametrize("noise", NON_EVENTS)
@pytest.mark.parametrize(
("parser", "events"),
[
(synthetic_trajectory_from_claude_stream_jsonl, CLAUDE_EVENTS),
(synthetic_trajectory_from_cline_cli, CLINE_EVENTS),
],
)
def test_non_object_events_preserve_surrounding_tool_evidence(parser, events, noise) -> None:
clean = parser(_jsonl(events))
assert clean is not None

assert parser(_jsonl([noise, events[0], noise, *events[1:], noise])) == clean
assert parser(_jsonl([noise])) is None


@pytest.mark.parametrize("payload", NON_EVENTS)
def test_cline_non_object_tool_payload_preserves_surrounding_events(payload) -> None:
malformed_tool = {"say": "tool", "text": json.dumps(payload)}

assert synthetic_trajectory_from_cline_cli(
_jsonl([CLINE_EVENTS[0], malformed_tool, *CLINE_EVENTS[1:]])
) == synthetic_trajectory_from_cline_cli(_jsonl(CLINE_EVENTS))


@pytest.mark.parametrize(
("filename", "parser", "events"),
[
("claude-code.txt", synthetic_trajectory_from_claude_stream_jsonl, CLAUDE_EVENTS),
("cline.txt", synthetic_trajectory_from_cline_cli, CLINE_EVENTS),
],
)
def test_fallback_recovers_valid_evidence_around_non_events(tmp_path: Path, filename, parser, events) -> None:
(tmp_path / filename).write_text(_jsonl([*NON_EVENTS, *events, *NON_EVENTS]), encoding="utf-8")

trajectory, metadata = load_trajectory_with_fallback(tmp_path / "trajectory.json", tmp_path)

assert trajectory == parser(_jsonl(events))
assert metadata["source"] == filename
Loading