Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c4f2850
fix(tier3): preserve native Codex MCP server identity
Afloat16 Nov 17, 2026
aace134
Merge branch 'main' into fix/preserve-codex-mcp-identity
chrisknvidia Nov 17, 2026
f4e613d
Preserve structured Codex MCP identity through scoring
Afloat16 Nov 17, 2026
88ef7f7
Merge main and retain both release notes
Afloat16 Nov 17, 2026
0840873
Merge upstream main after documentation reorganization
Afloat16 Nov 17, 2026
a3f7797
Merge branch 'main' into fix/preserve-codex-mcp-identity
rng1995 Nov 17, 2026
be53ef1
fix(tier3): validate complete MCP identities before display limits
Afloat16 Nov 17, 2026
541663c
Merge main and preserve pending changelog entry
Afloat16 Nov 17, 2026
ec91d2e
fix(tier3): bound recorded MCP names and clarify reconstruction scope
Afloat16 Nov 18, 2026
6f8fcc3
Merge branch 'main' into fix/preserve-codex-mcp-identity
rng1995 Nov 18, 2026
e7b163b
Merge upstream main and preserve unreleased notes
Afloat16 Nov 18, 2026
feef312
Merge main and retain independent Unreleased changelog entries
Afloat16 Nov 19, 2026
e3c4320
chore: merge upstream main and resolve changelog conflict
Afloat16 Nov 19, 2026
4a078c6
chore: integrate latest SkillSpector diagnostics from main
Afloat16 Nov 19, 2026
3e192dd
chore: merge main and preserve the PR release note
Afloat16 Nov 20, 2026
5f0a971
Merge main into fix/preserve-codex-mcp-identity
rng1995 Nov 20, 2026
f3bc6d6
docs(tier3): cover every neutral name and add regression tests for re…
rng1995 Nov 20, 2026
0492749
Merge main into afloat/pr-731
rng1995 Nov 21, 2026
46d4833
Merge main into afloat/pr-731
rng1995 Nov 21, 2026
054eeb3
fix(trace-import): retain MCP tools in bounded candidate labels
Afloat16 Nov 21, 2026
44e6f07
Merge branch 'main' into fix/preserve-codex-mcp-identity
rng1995 Nov 23, 2026
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Codex JSONL reconstruction preserves recorded MCP server and tool names as
`mcp__server__tool`, allowing tool efficiency to recognize MCP work and apply
the existing filesystem-root search policy. Their separately recorded identity
also keeps server names containing `__` intact for scoring and plugin reports.

- Direct Tier 1 validates the target, selected checks and LLM configuration before
preparing scanners, so configuration errors do not trigger downloads or stdout noise.
- Documentation-only CI follows imports through collected test modules and
Expand Down
8 changes: 5 additions & 3 deletions docs/reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,11 @@ tool names, these calls are productive: reading, searching, listing, writing,
editing or patching files (`Write`, `Edit`, `MultiEdit`, `apply_patch`, `LS`,
OpenCode `list`, Codex `list_dir` and `grep_files`, and similar), running
commands and activating a skill. MCP tools named `mcp__server__tool`, as Claude
Code records them, are productive too. Codex records an MCP call under the bare
tool name and OpenCode as `server_tool`, so these calls are classified by their
name like any other tool, and most such names count as wasted. A Codex name
Code records them, are productive too. When reconstructing native Codex JSONL,
the recorded `server` and `tool` fields produce the same MCP name and remain
separate, so `__` inside a server name does not change its identity. Codex records
without server identity and OpenCode names such as `server_tool` are classified
by their name like any other tool, and most such names count as wasted. A Codex name
with a namespace, such as `functions.apply_patch`, is classified by the part
after the last dot. Help, version and install commands are wasted, whether
written as text or recorded as an argument list, as is any tool outside these
Expand Down
5 changes: 3 additions & 2 deletions docs/tier3-live-evaluation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1302,8 +1302,9 @@ none of them.
scored tool calls that did productive work. For Claude Code, Codex and OpenCode
tool names, reading, searching, listing, writing, editing or patching files,
running commands and activating a skill are productive, and so are MCP tools
named `mcp__server__tool` (Claude Code). Codex and OpenCode MCP calls are not
recognized as MCP calls yet, so most of them count as wasted. Help, version and
named `mcp__server__tool` (Claude Code and reconstructed native Codex JSONL with
recorded server identity, including names containing `__`). Codex records without server identity and OpenCode
MCP calls are classified by their tool name, so most count as wasted. Help, version and
install commands and searches rooted at `/` are wasted. Planning and
bookkeeping calls, such as `TodoWrite`, `update_plan`, task lists,
background-shell polling and sub-agent calls, are not counted, and a trial with
Expand Down
4 changes: 4 additions & 0 deletions src/skillevaluator/tier3/eval_core/atif_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
atif_content_text,
normalized_tool_call_error_flag,
normalized_tool_call_is_error,
recorded_mcp_identity,
)
from skillevaluator.tier3.eval_core.codex_tool_call_normalizer import (
iter_normalized_tool_calls as iter_tool_calls,
Expand All @@ -41,6 +42,7 @@
atif_content_text,
normalized_tool_call_error_flag,
normalized_tool_call_is_error,
recorded_mcp_identity,
)
from codex_tool_call_normalizer import (
iter_normalized_tool_calls as iter_tool_calls,
Expand Down Expand Up @@ -1424,6 +1426,8 @@ def extract_tool_calls_as_dicts(traj: dict[str, Any]) -> list[dict[str, Any]]:
"action_input": tc.get("arguments") or {},
"observation": _tool_call_observation(step, tc),
}
if identity := recorded_mcp_identity(call["action"], tc.get("extra")):
call["extra"] = {"mcp_server": identity[0], "mcp_tool": identity[1]}
# Keep Harbor's explicit success flag too: Claude Code results that
# exited 0 carry no exit status line.
if (is_error := normalized_tool_call_error_flag(step, tc)) is not None:
Expand Down
16 changes: 13 additions & 3 deletions src/skillevaluator/tier3/eval_core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
AMBIGUOUS_OUTER_EXEC_OBSERVATION,
UNOBSERVED_INNER_CALL,
UNSUPPORTED_NATIVE_CODEX_EXEC,
recorded_mcp_identity,
)
from skillevaluator.tier3.eval_core.secret_redaction import redact_secrets_in_log_line
else: # Standalone verifier: all dependencies are staged siblings.
Expand All @@ -43,6 +44,7 @@
AMBIGUOUS_OUTER_EXEC_OBSERVATION,
UNOBSERVED_INNER_CALL,
UNSUPPORTED_NATIVE_CODEX_EXEC,
recorded_mcp_identity,
)
from secret_redaction import redact_secrets_in_log_line

Expand Down Expand Up @@ -8300,7 +8302,9 @@ def _session_input_is_text(value: Any) -> bool:
return isinstance(value, str) and any(char.isprintable() and not char.isspace() for char in value)


def _mcp_call_targets_root(name: str, args: dict[str, Any]) -> bool:
def _mcp_call_targets_root(
name: str, args: dict[str, Any], identity: tuple[str, str] | None = None
) -> bool:
"""Whether an MCP call searches or lists the whole filesystem.

Only filesystem tools count: a tool of a server whose name contains
Expand All @@ -8310,7 +8314,10 @@ def _mcp_call_targets_root(name: str, args: dict[str, Any]) -> bool:
"""
if not name.startswith("mcp__"):
return False
server, _, tool = name[len("mcp__") :].partition("__")
if identity is None:
server, _, tool = name[len("mcp__") :].partition("__")
else:
server, tool = (part.casefold() for part in identity)
if "filesystem" not in server and not any(word in tool for word in _MCP_FILESYSTEM_SEARCH_WORDS):
return False
return any(
Expand All @@ -8335,7 +8342,10 @@ def _tool_call_productivity(tc: dict[str, Any], expected_skill: Any, expected_sc
search_action = "exec_command"
cmd = _tool_efficiency_text(target)
# A search rooted at "/" is waste even when it names the expected skill or script.
if _tool_searches_root(search_action, args, cmd, argv=_is_argv(target)) or _mcp_call_targets_root(name, args):
mcp_identity = recorded_mcp_identity(tc["action"], tc.get("extra"))
if _tool_searches_root(search_action, args, cmd, argv=_is_argv(target)) or _mcp_call_targets_root(
name, args, mcp_identity
):
return "wasted"
if ("read" in name and expected_skill and expected_skill in cmd) or (
runs_command and expected_script and expected_script in cmd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Dependency-free normalization for native Codex ``tools.exec`` wrappers."""
"""Dependency-free normalization for native Codex tool calls."""

from __future__ import annotations

Expand All @@ -21,6 +21,20 @@
_MAX_TOOL_CALLS = 128


def recorded_mcp_identity(function_name: str, extra: Any) -> tuple[str, str] | None:
"""Return a recorded MCP server/tool pair consistent with its display name.

The display name alone is ambiguous when either component contains ``__``.
Ignore incomplete or inconsistent metadata on other ATIF calls.
"""
if not isinstance(extra, dict):
return None
server, tool = extra.get("mcp_server"), extra.get("mcp_tool")
if not isinstance(server, str) or not server or not isinstance(tool, str) or not tool:
return None
return (server, tool) if function_name == f"mcp__{server}__{tool}" else None


def atif_content_text(content: object) -> str:
"""Return the text of an ATIF message or observation content value.

Expand Down
8 changes: 8 additions & 0 deletions src/skillevaluator/tier3/eval_core/log_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,12 @@ def synthetic_trajectory_from_codex_json(text: str) -> dict[str, Any] | None:

if item_type == "mcp_tool_call":
tool = str(item.get("tool") or "mcp_tool")
server = item.get("server")
mcp_extra = {}
if isinstance(server, str) and server:
bare_tool = tool.removeprefix(f"mcp__{server}__")
mcp_extra = {"mcp_server": server, "mcp_tool": bare_tool}
tool = f"mcp__{server}__{bare_tool}"
Comment thread
chrisknvidia marked this conversation as resolved.
Resolved
arguments = item.get("arguments")
if not isinstance(arguments, dict):
arguments = {}
Expand All @@ -924,6 +930,8 @@ def synthetic_trajectory_from_codex_json(text: str) -> dict[str, Any] | None:
],
"observation": {"results": []},
}
if mcp_extra:
step["tool_calls"][0]["extra"] = mcp_extra
observation = _codex_mcp_observation(item)
if observation:
step["observation"]["results"].append(
Expand Down
9 changes: 6 additions & 3 deletions src/skillevaluator/tier3/eval_core/plugin_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
from skillevaluator.tier3.eval_core.codex_tool_call_normalizer import (
MAPPED_OUTER_EXEC_OBSERVATION,
normalize_tool_call,
recorded_mcp_identity,
)
from skillevaluator.tier3.plugin_native import OPENCODE_BUILTIN_AGENTS
from skillevaluator.tier3.runtime_arms import ARM_LOOSE_PARTS, ARM_SUM_OF_PARTS, ARM_WITH, ARM_WITHOUT
Expand Down Expand Up @@ -2808,9 +2809,11 @@ def _persistable_name(name: str, members: Sequence[str]) -> bool:
return any(member.casefold() == folded for member in members)


def _mcp_ident(fn: str, mcp_names: _McpNames, *, agent: str) -> _Ident | None:
def _mcp_ident(
fn: str, mcp_names: _McpNames, *, agent: str, recorded: tuple[str, str] | None = None
) -> _Ident | None:
"""The MCP identity of a call named ``fn``, labeled ``mcp__<server>__<tool>`` (see :meth:`_McpNames.identity`)."""
identity = mcp_names.identity(fn, agent=agent)
identity = (mcp_names.match(recorded[0]) or recorded[0], recorded[1]) if recorded else mcp_names.identity(fn, agent=agent)
Comment thread
Afloat16 marked this conversation as resolved.
Resolved
if identity is None:
return None
server, tool = identity
Expand Down Expand Up @@ -2971,7 +2974,7 @@ def _identify_call(
fn = str(tool_call.get("function_name") or "")[:_MAX_LABEL_CHARS]
args = tool_call.get("arguments")
args = args if isinstance(args, dict) else {}
mcp = _mcp_ident(fn, mcp_names, agent=agent)
mcp = _mcp_ident(fn, mcp_names, agent=agent, recorded=recorded_mcp_identity(fn, tool_call.get("extra")))
Comment thread
Afloat16 marked this conversation as resolved.
Resolved
fn_base = _base_tool_name(mcp.tool if mcp is not None and mcp.tool else fn)
manifest = _manifest_reads(fn_base, args, declared.get(COMPONENT_SKILL) or (), is_mcp=mcp is not None)
named = {
Expand Down
145 changes: 145 additions & 0 deletions tests/tier3/test_codex_mcp_identity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Retain native Codex MCP server identity for downstream checks."""

import json

import pytest

from skillevaluator.tier3.eval_core.atif_helpers import extract_tool_calls_as_dicts
from skillevaluator.tier3.eval_core.checks import check_tool_efficiency
from skillevaluator.tier3.eval_core.log_converters import (
load_trajectory_with_fallback,
synthetic_trajectory_from_codex_txt,
)
from skillevaluator.tier3.eval_core.plugin_signals import compute_plugin_signals


def _call(server, tool="lookup", arguments=None):
event = {
"type": "item.completed",
"item": {
"type": "mcp_tool_call",
"id": "mcp-1",
"server": server,
"tool": tool,
"arguments": arguments or {},
"result": {"content": [{"type": "text", "text": "recorded result"}]},
"status": "completed",
},
}
trajectory = synthetic_trajectory_from_codex_txt(json.dumps(event))
assert trajectory is not None
return extract_tool_calls_as_dicts(trajectory)[0]


@pytest.mark.parametrize("server", ["reference", "project.docs"])
@pytest.mark.parametrize("tool", ["lookup", "task"])
def test_codex_mcp_server_and_tool_are_preserved_and_counted(server, tool):
call = _call(server, tool, {"query": "requirements"})

assert call["action"] == f"mcp__{server}__{tool}"
assert call["action_input"] == {"query": "requirements"}
assert "recorded result" in call["observation"]
result = check_tool_efficiency([call])
assert result["score"] == 1.0
assert result["details"]["productive"] == 1
assert result["details"]["neutral"] == 0


@pytest.mark.parametrize(
("server", "tool", "path", "expected"),
[
("filesystem", "inspect", "/", 0.0),
("files", "list_directory", "/", 0.0),
("filesystem", "inspect", "/workspace/project", 1.0),
("github", "get_file_contents", "/", 1.0),
],
)
def test_codex_mcp_identity_retains_existing_root_search_policy(server, tool, path, expected):
assert check_tool_efficiency([_call(server, tool, {"path": path})])["score"] == expected


@pytest.mark.parametrize("server", [None, "", 5])
def test_missing_or_invalid_server_does_not_invent_identity(server):
assert _call(server)["action"] == "lookup"


def test_already_qualified_tool_name_is_not_prefixed_twice():
assert _call("docs", "mcp__docs__lookup")["action"] == "mcp__docs__lookup"


def test_tool_name_cannot_replace_its_recorded_server_identity():
call = _call("filesystem", "mcp__docs__lookup", {"path": "/"})

assert call["action"] == "mcp__filesystem__mcp__docs__lookup"
assert check_tool_efficiency([call])["score"] == 0.0


def _load_native_mcp_log(tmp_path, server, tool, path):
logs = tmp_path / "agent"
logs.mkdir()
event = {
"type": "item.completed",
"item": {
"type": "mcp_tool_call",
"id": "mcp-1",
"server": server,
"tool": tool,
"arguments": {"path": path},
"result": {"content": [{"type": "text", "text": "recorded result"}]},
"status": "completed",
},
}
(logs / "codex.txt").write_text(json.dumps(event) + "\n", encoding="utf-8")
trajectory, metadata = load_trajectory_with_fallback(logs / "trajectory.json", logs)
assert trajectory is not None
assert metadata["source"] == "codex.txt"
return trajectory


@pytest.mark.parametrize(
("server", "tool", "path", "expected"),
[
("project__filesystem", "inspect", "/", 0.0),
("project.filesystem", "inspect", "/", 0.0),
("project__filesystem", "mcp__project__filesystem__inspect", "/", 0.0),
("project__filesystem", "mcp__docs__inspect", "/", 0.0),
("project__filesystem", "inspect", "/workspace/project", 1.0),
("project", "filesystem__inspect", "/", 1.0),
("project__docs", "inspect__list_directory", "/", 0.0),
],
)
def test_native_log_keeps_server_boundaries_for_efficiency(tmp_path, server, tool, path, expected):
trajectory = _load_native_mcp_log(tmp_path, server, tool, path)
calls = extract_tool_calls_as_dicts(trajectory)
result = check_tool_efficiency(calls)

assert result["score"] == expected
assert result["details"]["wasted"] == int(expected == 0)
assert result["details"]["productive"] == int(expected == 1)


@pytest.mark.parametrize(
("server", "tool"), [("project__filesystem", "inspect"), ("project", "filesystem__inspect")]
)
def test_native_log_keeps_ambiguous_labels_attributed_to_recorded_server(tmp_path, server, tool):
trajectory = _load_native_mcp_log(tmp_path, server, tool, "/")
calls = extract_tool_calls_as_dicts(trajectory)
assert calls[0]["action"] == "mcp__project__filesystem__inspect"

signals = compute_plugin_signals(trajectory, {}, declared={"mcp": ["project", "project__filesystem"]})
assert signals["activations"][0]["server"] == server
assert signals["activations"][0]["name"] == server
assert calls[0]["extra"] == {"mcp_server": server, "mcp_tool": tool}


@pytest.mark.parametrize(
"extra",
[None, [], {}, {"mcp_server": 7, "mcp_tool": "inspect"}, {"mcp_server": "docs", "mcp_tool": "inspect"}],
)
def test_invalid_or_mismatched_mcp_metadata_preserves_legacy_name_policy(extra):
call = {"action": "mcp__filesystem__inspect", "action_input": {"path": "/"}, "extra": extra}

assert check_tool_efficiency([call])["score"] == 0.0
2 changes: 1 addition & 1 deletion tests/tier3/test_log_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def test_codex_mcp_tool_call_preserves_result():
assert traj is not None
tcs = extract_tool_calls_as_dicts(traj)
assert len(tcs) == 1
assert tcs[0]["action"] == "lookup"
assert tcs[0]["action"] == "mcp__demo__lookup"
assert "found skill" in tcs[0]["observation"]


Expand Down