Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ All notable changes to SkillEvaluator are documented in this file.

### Fixed

- Trajectories rebuilt from native Codex logs preserve recorded MCP server and
tool names, including server names containing `__`, for scoring and plugin
reports. Full identities are checked before display-label truncation, and
oversized names and names containing control characters are not trusted for
identity matching.
In rebuilt logs, MCP tools count as MCP work rather than neutral planning even
when their bare name is one of the neutral planning or bookkeeping names (for
example `task`, `update_plan`, `spawn_agent`, `wait`, `agent`, or `todowrite`);
an MCP tool named `skill` no longer produces a false Skill-tool activation.
Codex `tier3 import-traces` candidates also use `mcp__server__tool` labels.
Harbor-provided Codex trajectories and their existing MCP classification are
unchanged.
- Bedrock preflight and host inference now sign requests with IAM credentials
when `AWS_BEARER_TOKEN_BEDROCK` is empty or whitespace-only, for example when
a CI job exports an unset secret. Previously the Tier 3 preflight sent a blank
Expand Down
17 changes: 14 additions & 3 deletions docs/reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,12 @@ 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 a missing or empty Harbor trajectory
is rebuilt from `codex.txt`, 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 MCP calls in Harbor's existing graded trajectory are not yet
recognized as MCP; their bare names and OpenCode names such as `server_tool` are
classified 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 All @@ -980,6 +983,14 @@ reason names how many calls were not counted. A trial whose only calls are
neutral did no work: it scores tool efficiency 0.0, so its `skill_efficiency`
is 0.0, the same as a trial with no tool calls.

In rebuilt Codex logs, MCP tools count as MCP work instead of neutral planning
even when their bare name is a neutral planning or bookkeeping name, such as
`task`, `update_plan`, `spawn_agent`, `wait`, `agent` or `todowrite`. An MCP
tool named `skill` also remains an MCP call; it does not count as a Skill-tool
activation. These rules do not change Harbor-provided Codex trajectories.
Candidates created by `tier3 import-traces` from Codex exports likewise retain
the recorded MCP identity in `mcp__server__tool` labels.

Tool-efficiency checks classify explicit searches rooted at `/` as wasted work,
whether or not the command names the expected skill or script. This includes
native `Grep`, `Glob`, `LS`, OpenCode `list`, Codex `list_dir` and `grep_files`
Expand Down
8 changes: 6 additions & 2 deletions docs/tier3-grading.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ 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`, as Claude Code records them. When a missing or empty
Harbor trajectory is rebuilt from `codex.txt`, the recorded MCP server and tool
fields produce that name too, preserving server names containing `__`.
Codex MCP calls in Harbor's existing graded trajectory are not yet recognized
as MCP: their bare tool names, and OpenCode MCP names, are classified like other
tool names, 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
14 changes: 11 additions & 3 deletions src/skillevaluator/tier3/eval_core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 @@ -46,6 +47,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 @@ -15443,7 +15445,7 @@ 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 @@ -15453,7 +15455,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 @@ -15478,7 +15483,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 @@ -19,6 +19,27 @@
_MAX_OBJECT_NESTING = 64
_MAX_STATEMENTS = 256
_MAX_TOOL_CALLS = 128
_MAX_RECORDED_MCP_NAME_CHARS = 1024


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, inconsistent, or malformed metadata on other ATIF calls.
Bound names before downstream matching can expand plugin-prefixed aliases.
"""
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
if any(
len(name) > _MAX_RECORDED_MCP_NAME_CHARS or re.search(r"[\x00-\x1f\x7f-\x9f]", name) is not None
for name in (server, tool)
):
return None
return (server, tool) if function_name == f"mcp__{server}__{tool}" else None


def atif_content_text(content: object) -> str:
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 @@ -908,6 +908,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 @@ -926,6 +932,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
18 changes: 12 additions & 6 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 @@ -1741,7 +1742,7 @@ def _tool_name(tool_call: Mapping[str, Any]) -> str:
for key in ("function_name", "name", "tool_name"):
value = tool_call.get(key)
if isinstance(value, str) and value.strip():
return value.strip()[:_MAX_LABEL_CHARS]
return value.strip()
return ""


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)
)
if identity is None:
return None
server, tool = identity
Expand Down Expand Up @@ -2934,7 +2937,7 @@ def _expanded_tool_calls(raw: Mapping[str, Any], outer_id: str, mcp_call_servers
server = mcp_call_servers.get(outer_id) if outer_id else None
if server and name and not name.casefold().startswith(_MCP_PREFIX):
# The harness log names the server this bare MCP tool name came from (Codex).
name = f"mcp__{server}__{name}"[:_MAX_LABEL_CHARS]
name = f"mcp__{server}__{name}"
prepared = {**raw, "function_name": name, "arguments": _arguments(raw)}
try:
return normalize_tool_call(prepared)
Expand Down Expand Up @@ -2968,10 +2971,13 @@ def _identify_call(
lsp_extensions: Mapping[str, str] | None = None,
) -> _Call:
"""A normalized tool call with its identities and outcome (its subagent fields are filled in later)."""
fn = str(tool_call.get("function_name") or "")[:_MAX_LABEL_CHARS]
full_name = str(tool_call.get("function_name") or "")
# Validate the complete identity before limiting display labels.
recorded = recorded_mcp_identity(full_name, tool_call.get("extra"))
fn = full_name[:_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)
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
26 changes: 26 additions & 0 deletions tests/test_trace_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,32 @@ def test_reconstruct_log_and_unknown_agent():
assert doc["candidates"][0]["observed"]["tool_calls"] == []


@pytest.mark.parametrize(
("server", "label"),
[("docs", "mcp__docs__lookup"), ("project__docs", "mcp__project__docs__lookup")],
)
def test_codex_mcp_candidates_use_qualified_tool_labels(server, label):
event = {
"type": "item.completed",
"item": {
"type": "mcp_tool_call",
"id": "mcp-1",
"server": server,
"tool": "lookup",
"arguments": {"query": "requirements"},
"result": {"content": [{"type": "text", "text": "recorded result"}]},
"status": "completed",
},
}
doc, _ = build_candidates(
json.dumps(session(agent="codex", agent_log=json.dumps(event))).encode(), "export", "sample"
)

observed = doc["candidates"][0]["observed"]
assert observed["trajectory_source"] == "codex log"
assert observed["tool_calls"] == [f'{label}: {{"query": "requirements"}}']


def test_prompt_recovered_from_trajectory():
doc, _ = build_candidates(
json.dumps(
Expand Down
Loading