Skip to content

Commit ee4b231

Browse files
committed
fix(eval): ignore malformed telemetry tool names
1 parent 3772318 commit ee4b231

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/jacobian/eval/telemetry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ def _mcp_resource_link_uris(item: Mapping[str, Any]) -> tuple[str, ...]:
213213
def _mcp_resource_read_uri(item: Mapping[str, Any]) -> str | None:
214214
item_type = item.get("type")
215215
tool = item.get("tool")
216-
if item_type != "mcp_resource_read" and tool not in _RESOURCE_READ_TOOL_NAMES:
216+
if item_type != "mcp_resource_read" and (
217+
not isinstance(tool, str) or tool not in _RESOURCE_READ_TOOL_NAMES
218+
):
217219
return None
218220
for key in ("arguments", "params", "input"):
219221
value = item.get(key)

tests/unit/tooling/test_eval_telemetry.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,24 @@ def test_agent_telemetry_ignores_non_string_mcp_status(tmp_path: Path) -> None:
172172
assert telemetry["mcp_resource_read_successes"] == 1
173173

174174

175+
def test_agent_telemetry_ignores_non_string_mcp_tool(tmp_path: Path) -> None:
176+
event = {
177+
"type": "item.completed",
178+
"item": {
179+
"type": "not_resource_read",
180+
"tool": [],
181+
"arguments": {"uri": "artifact://sha256/" + ("a" * 64)},
182+
},
183+
}
184+
transcript = tmp_path / "transcript.jsonl"
185+
transcript.write_text(json.dumps(event) + "\n", encoding="utf-8")
186+
187+
telemetry = parse_agent_transcript(transcript)
188+
189+
assert telemetry["mcp_calls"] == []
190+
assert telemetry["mcp_resource_read_attempts"] == 0
191+
192+
175193
def test_agent_telemetry_reports_reasoning_protocol_without_summary_text(
176194
tmp_path: Path,
177195
) -> None:

0 commit comments

Comments
 (0)