Skip to content

Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.

fix(tier3): leave inferred timing N/A when a tool step is not followed by an agent step (#365)

Narendran Raghavandb62830c42af
diff --git a/docs/reports.mdx b/docs/reports.mdx
index cfdccfac..77095985 100644
--- a/docs/reports.mdx
+++ b/docs/reports.mdx
@@ -555,19 +555,24 @@ Inference covers trajectories whose tool calls are all Codex shell tools
`shell_command`) or `apply_patch`, each with a recorded wall time. A trial that
also calls a tool with no recorded duration, such as web search,
`update_plan`, or an MCP tool, or whose step timestamps are missing, lack a UTC
-offset, or run backwards, has no LLM or tool time. Agents without native timing
-or Codex `Wall time` headers are timed only when their trajectory has no tool
-calls.
+offset, or run backwards, has no LLM or tool time. Inferred timing also needs
+the agent's next step right after each tool step: a user or system step there
+can follow idle or user time, so the trial has no timing. Agents without native
+timing or Codex `Wall time` headers are timed only when their trajectory has no
+tool calls.
+
Each step of a multi-step task is timed on its own, so the time between Harbor
steps is not counted. Steps marked `is_copied_context` repeat context from an
earlier trajectory and are not timed; a copied step after new steps leaves the
trial without timing. Copied timestamps do not show when the first new response
started, so inferred timing also leaves the trial without timing when the new
-steps after copied context start with an agent step. Trials whose `trajectory.json` was omitted (too large, or
-redaction or validation failed) and multi-step trials scored per step have no
-timing. Missing timing stays `N/A` (`null` in JSON), never zero, and follows the
-same complete-arm and matching-case rules as tokens. Timing is diagnostic and
-does not change scores, verdicts, or gates.
+steps after copied context start with an agent step.
+
+Trials whose `trajectory.json` was omitted (too large, or redaction or
+validation failed) and multi-step trials scored per step have no timing.
+Missing timing stays `N/A` (`null` in JSON), never zero, and follows the same
+complete-arm and matching-case rules as tokens. Timing is diagnostic and does
+not change scores, verdicts, or gates.
### Failure reasons and per-trial rows
diff --git a/src/skillevaluator/tier3/harbor/trajectory_timing.py b/src/skillevaluator/tier3/harbor/trajectory_timing.py
index 007641d4..15db68bd 100644
--- a/src/skillevaluator/tier3/harbor/trajectory_timing.py
+++ b/src/skillevaluator/tier3/harbor/trajectory_timing.py
@@ -20,7 +20,9 @@ Two sources are used, never mixed within one trajectory:
which also includes harness and queue time, is LLM time. A trajectory with
any other tool call (``update_plan``, web search, MCP tools ...), or a call
whose output has no such header, has no measured duration for that call, so
- nothing is inferred.
+ nothing is inferred. Nor is anything inferred when a tool step is not
+ followed by an agent step, since a user or system step there can follow idle
+ or user time.
Each step of a merged multi-step trajectory is timed on its own, so the gap
between Harbor steps (verifier and setup time) is never counted. Steps marked
@@ -317,7 +319,9 @@ def _segment_timing_ms(steps: list[dict[str, Any]]) -> tuple[float, float] | Non
llm_ms += timestamp - stamped[index - 1][1]
has_tools = bool(durations)
if has_tools:
- if index + 1 == len(stamped):
+ # Only the agent's next step shows when the model finished with the tool
+ # output; a user or system step there can follow idle or user time.
+ if index + 1 == len(stamped) or stamped[index + 1][0].get("source") != "agent":
return None
gap_ms = stamped[index + 1][1] - timestamp
step_tool_ms = max(durations) * 1000.0
diff --git a/tests/tier3/test_trajectory_timing.py b/tests/tier3/test_trajectory_timing.py
index 411c0d3b..dfcb2b9f 100644
--- a/tests/tier3/test_trajectory_timing.py
+++ b/tests/tier3/test_trajectory_timing.py
@@ -222,6 +222,18 @@ def test_trailing_tool_step_without_a_later_timestamp_is_rejected() -> None:
assert trajectory_timing({"steps": [_user(), _tool_step(3, [1.0])]}) is None
[email protected]("source", ["user", "system"])
+def test_tool_step_followed_by_a_user_or_system_step_is_unmeasured(source: str) -> None:
+ interjection = {"source": source, "timestamp": "2026-01-01T00:00:40+00:00"}
+ # The 38 s after the 1 s tool call may be idle or user time, not model time; counting it
+ # would report 42.0 LLM seconds (39.0 when the interjection is the last step).
+ assert trajectory_timing({"steps": [_user(), _tool_step(2, [1.0]), interjection, _agent(43)]}) is None
+ assert trajectory_timing({"steps": [_user(), _tool_step(2, [1.0]), interjection]}) is None
+ # With the agent's reply to the tool output first, the gap before the interjection is not counted.
+ steps = [_user(), _tool_step(2, [1.0]), _agent(5), interjection, _agent(43)]
+ assert trajectory_timing({"steps": steps}) == _inferred(7.0, 1.0)
+
+
def test_measured_zero_tool_duration_is_preserved() -> None:
trajectory = {"steps": [_user(), _tool_step(3, [0.0]), _agent(10)]}
assert trajectory_timing(trajectory) == _inferred(10.0, 0.0)