Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a116126
fix(tier3): count edits, searches and MCP calls as productive in tool…
rng1995 Nov 7, 2026
a19d290
docs(tier3): describe the tool efficiency classes
rng1995 Nov 7, 2026
9c86f94
Merge main into naren/port-tier3-tool-productivity-classes
rng1995 Nov 8, 2026
bcf866c
fix(tier3): score a trial with only planning calls 0.0 for tool effic…
rng1995 Nov 8, 2026
07cb952
fix(tier3): leave Claude Code task lists and Codex wait out of tool e…
rng1995 Nov 8, 2026
d5a080d
fix(tier3): classify text sent to a shell session and MCP root listings
rng1995 Nov 8, 2026
5078593
fix(tier3): read argv list words as literal in the root-search check
rng1995 Nov 8, 2026
87145e0
docs(tier3): scope tool efficiency docs to what the classifier does
rng1995 Nov 8, 2026
8377cff
test(tier3): apply ruff format to the tool productivity tests
rng1995 Nov 8, 2026
77bdc7d
fix(tier3): count an MCP call on / as a root search only for filesyst…
rng1995 Nov 9, 2026
3ff424d
fix(tier3): match help, version and install words in commands only
rng1995 Nov 9, 2026
d8b4d57
fix(tier3): count OpenCode list as a productive directory listing
rng1995 Nov 9, 2026
5edc6b7
docs(tier3): describe the MCP, OpenCode and command-text tool efficie…
rng1995 Nov 9, 2026
958f140
docs(changelog): name the background-shell calls whose trials drop to…
rng1995 Nov 9, 2026
24fa4ed
Merge main into naren/port-tier3-tool-productivity-classes
rng1995 Nov 9, 2026
53cae2a
Merge main into naren/port-tier3-tool-productivity-classes
rng1995 Nov 10, 2026
204013c
Merge commit 'ce52a09887c36edc0223441700298a9f4e30ed09' into HEAD
rng1995 Nov 12, 2026
5ff9f47
docs: use published navigation routes
rng1995 Nov 12, 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
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,31 @@ All notable changes to SkillEvaluator are documented in this file.
2 can wait for readiness while authored image healthchecks remain suppressed.
Keep custom service healthchecks and their readiness dependencies intact.

- Tier 3 tool efficiency counts writing, editing and patching files, scoped
native searches and listings (`Grep`, `Glob`, `LS`, OpenCode `list`, Codex
`list_dir` and `grep_files`) and MCP tools named `mcp__server__tool` (Claude
Code) as productive. An MCP filesystem search or listing whose `path` or
`dir_path` is `/` is a root search and counts as waste. Most of these
counted as wasted before, so a with-skill trial that read the skill, edited
four files and ran the tests scored tool efficiency 0.33. Codex and OpenCode
MCP calls, which are recorded under the bare tool name or as `server_tool`,
are not recognized as MCP calls yet. Codex names with a namespace, such as
`functions.apply_patch`, are classified by the bare name. Planning and
bookkeeping calls (`TodoWrite`, `update_plan`, `TaskCreate` and
`TaskUpdate`, background-shell polling such as `BashOutput`, and sub-agent
calls) are left out of the score, and the reason says how many were not
counted. A trial with only such calls scores 0.0, so a trial whose only
calls were `BashOutput` or `KillShell` drops from 1.0 to 0.0. Polling a
background shell no longer counts as running a command, while a command
typed into a Codex `write_stdin` session or run by `Monitor` is classified
like any other command. Help, version and install words are matched in
commands only, so a file path or patch text that mentions `pip install` is
not waste. Efficiency scores rise for write-, edit-, patch-, search- and
MCP-heavy runs. Root searches in commands recorded as an argument list, such
as Codex `["bash", "-lc", "find / -name x"]`, now count as waste, and so do
help, version and install commands recorded that way, like the same command
written as text.

### Documentation

- The 0.8.0 entry for refused `claude-code` attempts said the arm reports its
Expand Down
47 changes: 42 additions & 5 deletions docs/reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -705,12 +705,49 @@ dimensions, each answering one question:
| Effectiveness | Did the skill help complete the task? | `goal_accuracy` from an LLM judge; `behavior_check` from its judge and directly evaluated declared checks (checks-only cases make no judge call) |
| Efficiency | Did it avoid wasted tool or skill usage? | `skill_efficiency`, from deterministic trajectory checks |

`skill_efficiency` averages skill routing with tool efficiency, the share of
scored tool calls that did productive work. For Claude Code, Codex and OpenCode
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
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
classes. Only commands are checked for help, version and install words, so a
file path or patch text that mentions `pip install` is not waste.

Planning and bookkeeping calls are neutral and left out of the score:
`TodoWrite`, `update_plan`, task lists (`TaskCreate`, `TaskUpdate`, `TaskList`,
`TaskGet`), `EnterPlanMode` and `ExitPlanMode`, background-shell polling such
as `BashOutput` and `KillShell`, `TaskStop`, `ToolSearch`, and sub-agent calls
such as `Task` and Codex `spawn_agent`, `wait` or `wait_agent`. Codex
`write_stdin` with no input, or only Enter or Ctrl-C, polls its session and is
neutral, as is a `Monitor` watch with no command. A command typed with
`write_stdin` or run by `Monitor` is classified like any other command. The
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.

Tool-efficiency checks classify explicit searches rooted at `/` as wasted work,
whether or not the command names the expected skill or script. Scoped searches
and `/` used as a search pattern retain their existing classification. This rule
recognizes common search commands, including ones with redirections or wrapped in
`sh -c`; it does not interpret expansions, comments, here-documents or other
dynamically constructed shell programs.
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`
calls on `/`, MCP filesystem searches and listings whose `path` or `dir_path`
is `/`, and commands recorded as an argument list, such as Codex
`["bash", "-lc", "find / -name x"]`, which are read as the command they run.
An MCP call counts as a filesystem search or listing when its tool name
contains `search`, `list`, `tree`, `find`, `glob`, `grep` or `directory`, or
when its server name contains `filesystem`. Other MCP tools use `path` for
other things: `/` in a GitHub `get_file_contents` call is the repository root,
and that call is productive. Scoped searches and `/` used as a search pattern
are productive. This rule recognizes common search commands, including ones with
redirections or wrapped in `sh -c`; it does not interpret expansions, comments,
here-documents or other dynamically constructed shell programs. An argument
list runs without a shell, so `$`, backticks and `#` in its own words are
literal.


Every evaluator and dimension score is on a 0.0 to 1.0 scale. The generated
Expand Down
11 changes: 11 additions & 0 deletions docs/tier3-live-evaluation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,17 @@ grades each trial after the agent finishes. `security`, `skill_execution`, and
checks; a checks-only case makes no behavior judge call. `custom_only` runs
none of them.

`skill_efficiency` averages skill routing with tool efficiency, the share of
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
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
only such calls scores 0.0. [Reports](/skills/skillevaluator/reports) lists the tool classes.

The three LLM judges return verdicts only, and the verifier computes the
scores. A `score` field in a judge reply is ignored.

Expand Down
237 changes: 192 additions & 45 deletions src/skillevaluator/tier3/eval_core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5201,13 +5201,15 @@ def _mask_non_assignment_equals(text: str) -> str:
return "".join(out)


def _tool_searches_root(action: str, args: dict, text: str, depth: int = 0) -> bool:
def _tool_searches_root(action: str, args: dict, text: str, depth: int = 0, *, argv: bool = False) -> bool:
"""Recognize explicit root search operands, not '/' inside a pattern.

This is bounded top-level command classification. It does not execute or
interpret dynamically constructed shell programs.
interpret dynamically constructed shell programs. ``argv`` marks text
joined from an argument list, which runs without a shell: its own words
are literal, while a ``sh -c`` payload inside it is still shell text.
"""
if action in {"grep", "glob", "grep_files", "list_dir", "ls"}:
if action in {"grep", "glob", "grep_files", "list_dir", "ls", "list"}:
for key in ("path", "dir_path"):
value = args.get(key)
if isinstance(value, str) and _search_path_is_root(value.strip()):
Expand All @@ -5222,7 +5224,7 @@ def _tool_searches_root(action: str, args: dict, text: str, depth: int = 0) -> b
# Without a shell AST, comments, expansions, here-documents and process
# substitutions cannot be classified reliably. Keep their prior score
# instead of inventing a path.
if any(char in text for char in "$`#"):
if not argv and any(char in text for char in "$`#"):
return False
tokens = _shell_tokens(text)
if any(_is_heredoc_redirect(token) or token in {"<(", ">("} for token in tokens):
Expand Down Expand Up @@ -5414,12 +5416,175 @@ def _tool_searches_root(action: str, args: dict, text: str, depth: int = 0) -> b
return False


# Tool productivity classes for check_tool_efficiency. Neutral calls (planning,
# background-shell control, tool discovery and sub-agents) are left out of the
# score. Reading, searching, writing, patching, running commands and MCP tools
# count as productive work.
_NEUTRAL_TOOL_NAMES = frozenset(
{
"todowrite",
"todoread",
"update_plan",
"bashoutput",
"killshell",
"killbash",
"kill_shell",
"taskstop",
"taskoutput",
"toolsearch",
"task",
"agent",
# Claude Code task lists and plan mode.
"taskcreate",
"taskget",
"tasklist",
"taskupdate",
"enterplanmode",
"exitplanmode",
# Codex multi-agent tools.
"spawn_agent",
"wait",
"wait_agent",
"close_agent",
"send_input",
"resume_agent",
}
)
_PRODUCTIVE_TOOL_NAMES = frozenset(
{
"skill",
"ls",
# OpenCode's directory listing.
"list",
"list_dir",
"grep",
"grep_files",
"glob",
"write",
"edit",
"multiedit",
"notebookedit",
"write_file",
"edit_file",
"apply_patch",
"applypatch",
}
)
# Tools that send text to a running shell session (Codex write_stdin) or start
# a background watch (Claude Code Monitor), and the argument with that text.
# Without text they only poll or watch and are neutral; with text they run it,
# and it is classified like any other command.
_SESSION_INPUT_TOOL_ARGS = {"write_stdin": "chars", "monitor": "command"}
# Words in an MCP tool's own name that mark a filesystem search or listing.
_MCP_FILESYSTEM_SEARCH_WORDS = ("search", "list", "tree", "find", "glob", "grep", "directory")


def _tool_efficiency_args(tool_call: dict[str, Any]) -> dict[str, Any]:
args = tool_call.get("action_input")
return args if isinstance(args, dict) else {}


def _tool_efficiency_target(name: str, args: dict[str, Any]) -> Any:
"""The command, code or path a tool call acts on, as recorded."""
if name in _SESSION_INPUT_TOOL_ARGS:
return args.get(_SESSION_INPUT_TOOL_ARGS[name], "")
return (
args.get("command", "")
or args.get("cmd", "")
or args.get("code", "")
or args.get("file_path", "")
or args.get("path", "")
or args.get("raw", "")
)


def _is_argv(target: Any) -> bool:
return isinstance(target, list) and bool(target) and all(isinstance(item, str) for item in target)


def _tool_efficiency_text(target: Any) -> str:
"""Shell text for a tool call target.

Codex records some shell calls as an argv list such as
``["bash", "-lc", "find / -name x"]``. Joining it the way a shell reads it
lets the root-search and expected-script checks see the command instead of
a Python list repr.
"""
if _is_argv(target):
return shlex.join(target)
return str(target)


def _tool_efficiency_name(action: Any) -> str:
"""Lowercased tool name without a Codex namespace such as ``functions.``.

MCP tool names keep every part, so ``mcp__tasks__task`` stays an MCP call.
"""
name = str(action).lower()
return name if name.startswith("mcp__") else name.rsplit(".", 1)[-1]


def _session_input_is_text(value: Any) -> bool:
"""Whether session input types something; Enter or Ctrl-C alone only polls or interrupts."""
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:
"""Whether an MCP call searches or lists the whole filesystem.

Only filesystem tools count: a tool of a server whose name contains
``filesystem``, or a tool whose own name says it searches or lists
(``_MCP_FILESYSTEM_SEARCH_WORDS``). Other servers use ``path`` for other
things, such as a file in a repository, where "/" is the repository root.
"""
if not name.startswith("mcp__"):
return False
server, _, tool = name[len("mcp__") :].partition("__")
if "filesystem" not in server and not any(word in tool for word in _MCP_FILESYSTEM_SEARCH_WORDS):
return False
return any(
isinstance(args.get(key), str) and _search_path_is_root(args[key].strip()) for key in ("path", "dir_path")
)


def _tool_call_productivity(tc: dict[str, Any], expected_skill: Any, expected_script: Any) -> str:
"""Classify one tool call as ``productive``, ``wasted`` or ``neutral`` (not scored)."""
name = _tool_efficiency_name(tc["action"])
if name in _NEUTRAL_TOOL_NAMES:
return "neutral"
args = _tool_efficiency_args(tc)
target = _tool_efficiency_target(name, args)
runs_command = _is_execution_action(name)
search_action = name
if name in _SESSION_INPUT_TOOL_ARGS:
if not _session_input_is_text(target):
return "neutral"
# The text is a command typed into a shell or run as a watch script.
runs_command = True
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):
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
):
return "productive"
# Help, version and install commands are waste. Only a command is checked:
# the path, content or patch text of any other tool is data, not a command.
if runs_command and any(waste in f"{name} {cmd}".lower() for waste in WASTE_INDICATORS):
return "wasted"
if "read" in name or name in _PRODUCTIVE_TOOL_NAMES or name.startswith("mcp__") or runs_command:
return "productive"
return "wasted"


def check_tool_efficiency(
tool_calls: list[dict[str, Any]],
expected_skill: str | None = None,
expected_script: str | None = None,
) -> dict[str, Any]:
"""Measure what fraction of tool calls were productive vs wasted."""
"""Measure what fraction of scored tool calls were productive (planning calls are not scored)."""
expected_script = normalize_optional_reference(expected_script)
if not tool_calls:
return {"passed": True, "score": 1.0, "reason": "No tool calls", "details": {}}
Expand All @@ -5429,55 +5594,37 @@ def check_tool_efficiency(
"Tool efficiency could not be evaluated because a native Codex exec wrapper was unsupported"
)

productive = 0
wasted = 0
counts = {"productive": 0, "wasted": 0, "neutral": 0}
wasted_details: list[str] = []

for tc in tool_calls:
action = tc["action"].lower()
args = tc.get("action_input", {}) if isinstance(tc.get("action_input"), dict) else {}
cmd = str(
args.get("command", "")
or args.get("cmd", "")
or args.get("code", "")
or args.get("file_path", "")
or args.get("path", "")
or args.get("raw", "")
)
full_text = f"{action} {cmd}".lower()

is_productive = False

if _tool_searches_root(action, args, cmd):
is_productive = False
elif ("read" in action and expected_skill and expected_skill in cmd) or (
_is_execution_action(action) and expected_script and expected_script in cmd
):
is_productive = True
elif any(waste in full_text for waste in WASTE_INDICATORS):
is_productive = False
elif "read" in action or _is_execution_action(action) or action.lower() == "skill":
is_productive = True

if is_productive:
productive += 1
else:
wasted += 1
wasted_details.append(f"{tc['action']}({cmd[:60]})")
kind = _tool_call_productivity(tc, expected_skill, expected_script)
counts[kind] += 1
if kind == "wasted":
label = str(_tool_efficiency_target(_tool_efficiency_name(tc["action"]), _tool_efficiency_args(tc)))
wasted_details.append(f"{tc['action']}({label[:60]})")

productive, wasted, neutral = counts["productive"], counts["wasted"], counts["neutral"]
total = productive + wasted
score = productive / total if total > 0 else 1.0
details = {
"productive": productive,
"wasted": wasted,
"neutral": neutral,
"total": total,
"wasted_calls": wasted_details[:5],
}
not_counted = f"; {neutral} planning or bookkeeping call(s) not counted" if neutral else ""
if total == 0:
# Only planning or bookkeeping calls: no work was done, so score 0.0.
# skill_efficiency then matches a trajectory with no tool calls (0.0).
return {"passed": False, "score": 0.0, "reason": f"No scored tool calls{not_counted}", "details": details}

score = productive / total
return {
"passed": score >= 0.5,
"score": round(score, 4),
"reason": f"{productive}/{total} productive calls ({score:.0%})",
"details": {
"productive": productive,
"wasted": wasted,
"total": total,
"wasted_calls": wasted_details[:5],
},
"reason": f"{productive}/{total} productive calls ({score:.0%}){not_counted}",
"details": details,
}


Expand Down
Loading
Loading