Skip to content

feat(tier3): report token usage per case and agent - #427

Merged
rng1995 merged 25 commits into
naren/port-tier3-baseline-incomplete-reportingfrom
naren/port-tier3-token-usage-reporting
Nov 12, 2026
Merged

rng1995 merged 25 commits into
naren/port-tier3-baseline-incomplete-reportingfrom
naren/port-tier3-token-usage-reporting

Conversation

@rng1995

@rng1995 rng1995 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Stacked on fix(reporting): describe a failed Tier 3 arm as incomplete, not as not run #407 (naren/port-tier3-baseline-incomplete-reporting); merge that first. This PR reuses its incomplete_arms helper for failed arms.
  • New src/skillevaluator/tier3/token_usage.py sums each attempt's token counters per case, per agent arm and over all agents, with coverage:
    • total_tokens is prompt plus completion. Prompt counts include cached tokens, so cached tokens are never added again; uncached_prompt_tokens is prompt minus cached. A missing cache counter counts as 0, as in stats.uncached_tokens.
    • Counts are validated with resource_usage._is_measurement and must be whole numbers. An attempt with a missing or invalid counter (negative, bool, string, NaN, fraction, above 2^53 - 1, or cached above prompt) adds no tokens. Its arm is then partial or unavailable, and the totals cover only the measured attempts. Nothing is estimated, and invalid_counters names fields, never values.
    • A sum above 2^53 - 1, the largest integer JSON keeps exact, is unavailable with total_out_of_range and null totals.
    • Attempts that failed before scoring are counted (coverage.unscored_attempts). A timed-out attempt that a later attempt recovered counts as expected usage.
    • A change (delta.total_tokens, delta.total_tokens_change_percent) needs complete counts in both arms for the same cases and attempts, and both arms must have succeeded. Otherwise delta.reason_codes and delta.reason say why: <arm>_not_run, <arm>_tokens_incomplete (No baseline attempts were recorded. when the arm has none), <arm>_total_out_of_range, baseline_failed or with_skill_failed (worded like the coverage notice, for example No change: baseline incomplete (1 of 2 attempts scored).), <arm>_status_unknown for an arm that ran attempts without a recognized run status, case_scope_mismatch when both arms ran attempts for different cases or numbers of attempts per case, attempt_scope_mismatch, or agent_scope_mismatch for the sum over all agents. A zero-token baseline keeps the difference without a percentage (zero_baseline).
    • An arm is not_run when it was skipped, or when it has no attempts and either the payload mode leaves it out (with_skill_only, baseline_only, read as presentation.trial_coverage reads them) or the agent has no record of it. The BENCHMARK.md score tables show such a baseline as baseline not run, so the Token Usage section now says not run too instead of baseline 0/0.
    • A run that reused an earlier run's baseline (feat(tier3): reuse a compatible retained no-skill baseline #384's --reuse-baseline) copies that run's baseline trajectory.json files into the new run. token_usage then has baseline_reused: true. The sums and the change stay, because the copied rows are measurements like any other.
  • report_data.load_agent_data keeps usage_only_attempts and usage_only_attempts_baseline per agent:
    • an attempt without a usable reward.json (main skips it at report_data.py:866): its trajectory.json token counters, read as optional data. Its case is the task directory that its copied Harbor result.json (task_id.path, then config.task.path) or config.json (task.path) names. Without those files it is the trial name before Harbor's __<id> suffix (split from the right, because a case ID may contain __). The module then maps a stop-on-pass trial name (...-<with|without>-<case>-attemptNNN__...) or Harbor's 32-character cut of a case name back to the case when exactly one case matches.
    • the scored attempts of an arm whose status is not succeeded, whose rewards main clears at report_data.py:995.
    • rewards_complete, the cleared rewards, scores, pass@k and resources are unchanged.
  • build_agent_eval_payload builds token_usage (schema_version, scored: false, accounting, agents, dataset, and baseline_reused when the run config records a reused baseline) when any attempt was measured. It joins the payload after main's size budget has run. New tier3_report.fit_token_usage then keeps it only while the payload stays within the 2 MiB embedded budget and passes agent_eval_report_serialization_issue (100,000 JSON values, depth and text):
    • Its case rows go first (token_usage.case_rows_omitted, report_truncation.omitted.token_usage_case_rows), then the sums (report_truncation.omitted.token_usage).
    • If even that record does not fit, the token usage and its omission keys are removed, and a report_truncation that only they created goes too. The payload is then the same as without token usage.
    • Three steps write to a built payload: main's agent_eval_result_from_directory adds the run's next_steps when the run has a result.json, the tier3 evaluate report step adds its case findings and next steps (_apply_case_findings, up to 3 fixes), and validate adds applicability, reason_code and source_kind. fit_token_usage runs again after the last two, in render_agent_eval_html_report and in cli.py right after those three setdefault calls. Both run after the first write.
    • Read-only payloads (enforce_embedded_size=False) keep everything. Dashboards treat the two new omission keys as diagnostics, not as missing trials.
  • The Tier 3 report step also records the agent sums (no case rows) in the run's result.json, so tier3 evaluate can print them.
  • New src/skillevaluator/reporting/tier3_token_usage.py builds one set of table rows that every report renders, so the numbers and wording match:
    • BENCHMARK.md: a Token Usage section after Results at a Glance (and fix(reporting): describe a failed Tier 3 arm as incomplete, not as not run #407's Agent coverage list): one row per agent and one for all agents, the reasons a change is missing, and the case rows in a collapsed <details> table. The card has a 128 KiB gate limit, so it shows the first 50 case rows and says how many more are in the JSON payload.
    • Markdown report: the same table under its Tier 3 section.
    • HTML report: a "Token usage by case" table inside the existing Measured Agent Resources section, below the resources table. No second chart. The table reads the full Tier 3 data, not the bounded preview, and shows at most 64 case rows per agent with a line that says how many more are in the JSON payload. The bounded preview leaves token_usage out, so token rows can neither trigger the preview nor spend its budget.
    • Terminal: the full validate report (--verbose or -r cli) and tier3 evaluate --verbose print the agent rows only. They name the files that hold the case rows: the HTML, Markdown and JSON reports for validate, and report.html and tier3-benchmark.md in the run directory for tier3 evaluate.
    • When the payload left the case rows out, every report says how many.
    • When baseline_reused is set, every report adds one line under the table: the baseline tokens were used in the earlier run, not in this one.
    • Every table says the numbers are measured and not scored. Case names go through _md_cell in BENCHMARK.md and _markdown_untrusted_table_cell in the Markdown report, the HTML template autoescapes, and the terminal prints cells as Rich Text, never markup.
  • Docs: a new "Token usage" subsection in docs/reports.mdx after "Measured agent resources". CHANGELOG entry under Unreleased > Added.
  • Nothing on main reports token usage per case. The four related PRs have merged, and this branch now sits on their code:
  • Many open PRs also change the report modules, docs/reports.mdx or src/skillevaluator/cli.py. This PR adds 4 lines to cli.py, after the three setdefault calls in validate; no open PR head in the local clone changes lines near them.
  • git merge-tree of this branch with each open colleague PR head in the local clone:
  • fix(reporting): let default Tier 3 runs with a baseline pass publication #332, fix(tier1): scope ownership email policy and retain completeness diagnostics #333, feat(quality): configure Reliability error handling in the quality config #336, fix(reporting): stop validate from repeating its header in short terminals #368, feat(cli): show the wordmark in terminals narrower than 115 columns #369 and feat(datasets): record how a dataset was generated and show it on reports #405 were not checked against main d717f22; their heads are not in the local clone.
  • feat(reporting): add per-case expectation diagnostics #382, feat(tier3): reuse a compatible retained no-skill baseline #384, feat(tier3): compare a run against a prior skill version #387, feat(tier3): add a lift history view over retained runs #388 and feat(reports): name Skill Lift as the headline and label pass@k as supporting reliability #397 have merged, and this branch now sits on them.
  • This branch contains fix(reporting): describe a failed Tier 3 arm as incomplete, not as not run #407's branch (369a5d6), which contains main d717f22. git merge-tree --write-tree of this branch with main d717f22 is clean. Merging fix(reporting): describe a failed Tier 3 arm as incomplete, not as not run #407's branch conflicted in two files:
    • CHANGELOG.md: main's CI onboarding entry and this PR's entry both sat at the end of Unreleased > Added. Both are kept, this one last.
    • html.py, in _bounded_tier3_preview: main now builds a private copy of the payload and drops per-trial activation diagnostics before the preview budget. The copy is built from the payload without token_usage, so token rows still neither trigger the preview nor spend its budget.

Why

Token usage reached only the HTML report and the JSON payload, one total per agent and arm, and only when every attempt of the arm was scored and measured (resource_usage.py:98). The terminal, the Markdown report and BENCHMARK.md showed none, even though BENCHMARK.md calls token usage "reported separately" (benchmark.py:78). The loader also dropped the tokens of attempts that failed before scoring and of every attempt in a failed arm, so a timed-out baseline attempt that used 48,000 tokens left no trace. Readers could not see what a skill costs per case or per agent, and failed runs looked cheaper than they were.

A measurement must not change what the report says about scores. Each case row is about 36 JSON values. With the report tests' run fixture, two agents with 394 cases each fit main's report limits at 95,549 values, but the case rows would push the payload to 124,033 values, past the 100,000-value limit. The report would then show the score as N/A and say that publication completeness cannot be proven. So token usage only fills what the payload has left after main's budget, and its case rows are the first thing to go. Fields written after the build need the same room. With 2 agents × 316 cases and 95 of one agent's baseline trials without trajectory.json, token usage fills the payload to 99,963 values; the 3 fixes and next steps that the tier3 evaluate report step adds would then push it to 100,007 values and turn a Passed 0.90 report into Passed N/A. So token usage gives way again after the report step's case findings and next steps, and after validate's applicability fields.

Kept from public

  • Token usage is not scored. No metric, dimension (Efficiency included), overall score, verdict, gate, pass@k or token_efficiency statistic reads it.
  • The payload size budget runs exactly as on main, on the payload without token usage. Token usage never takes the place of failure reasons, comparison payloads, non-best agent details, trials or any other evidence, and never makes a payload fail the report limits that it passes on main, also after the next steps, the case findings and validate's applicability fields join it. A payload that fails the limits without token usage (for example 2 agents × 450 cases with the report tests' run fixture, 101,398 values) carries no token usage and no token omission record, and every report marks it as it would without this PR.
  • resource_comparison keeps its complete-only totals and deltas. With a timed-out baseline attempt, resources.tokens.baseline.total stays null while token_usage shows the measured baseline usage; on a complete run both report the same total and difference.
  • The loader still marks the arm incomplete, still clears a failed arm's rewards, and reads trajectories and Harbor files with public's bounded JSON reader. A failed attempt's trajectory, result.json and config.json are optional, so an unreadable or oversized file adds no report truncation notice. Main's case fallback for a reward without entry_id is unchanged.
  • Report trials keep public's rule that a logical attempt scored over several reward rows has no token counts; such attempts count as unmeasured.
  • Failed arms use fix(reporting): describe a failed Tier 3 arm as incomplete, not as not run #407's incomplete_arms and its wording, and the coverage notices stay as fix(reporting): describe a failed Tier 3 arm as incomplete, not as not run #407 built them.
  • BENCHMARK.md text goes through _md_cell and _agent_display_label. The public gate (scripts/ci/check_public_benchmarks.py) needs no change: a card with the new section has no offenders.
  • The existing token chart and resources table in the HTML report and the bounded preview of every other Tier 3 key are unchanged.
  • Main's dashboard test that prunes only the non-best agent's details now sizes its budget from the payload without token_usage, which keeps that intent.

Tests

  • New tests/tier3/test_token_usage.py (49 tests):
    • counters: cached tokens are part of the prompt; an omitted cache counter is 0 and ATIF names are read; invalid prompt, completion and cached values (18 cases) and cached above prompt are rejected and named without their values (21)
    • sums: per case, per agent and over all agents; a failed attempt counts as unscored usage; a cut Harbor trial name and a stop-on-pass trial name map to their case; partial coverage sums only measured attempts; an attempt that never ran and a planned case without attempts leave the arm or case partial or unavailable; attempts skipped after a pass are not missing; a recovered timeout attempt is expected usage (9)
    • change: the percentage at every scope (3); a zero-token baseline; a skipped baseline is not_run with baseline_not_run as its one reason; a baseline with no record and no attempts is not_run in a run of both arms and in a with_skill_only run (2); an arm the payload mode leaves out is not_run, while the same arm in a run of both arms says No baseline attempts were recorded.; absent baseline evidence is not called not run and gets that one reason; different cases or attempt counts; one agent without a change blocks the change over all agents; a failed baseline keeps its usage but gets no change at agent and case level; an arm with an unknown, unrecognized or missing status gets no change (3); arm sums above 2^53 - 1 and an all-agent sum above it are total_out_of_range (2); no measured attempt gives no token_usage (18)
    • reused baseline (1): baseline_reused marks the result and changes nothing else
  • New tests/reporting/test_tier3_token_usage_reports.py (27 tests), mostly from a run directory where Claude Code's baseline times out on one case and Codex completes:
    • loader and payload (14): the loader keeps the failed arm's scored attempt and the timed-out attempt as usage, and still clears the rewards; an unscored attempt of case auth__login stays in that case; a stop-on-pass unscored attempt takes its case from its Harbor result.json or config.json (Windows path included); the payload counts them while resources stays complete-only and scores are unchanged; no token_usage without token counts; under the byte budget, token case rows go and every trial, failure reason and other agent's details stay as without token usage; under the node limit, with room for the sums, for only the truncation record, or for nothing, the payload passes the serialization check, keeps its publication status and is otherwise identical to the payload without token usage (3); dashboards read the new omission keys as diagnostics; with the node limit one value above the full payload:
      • render_agent_eval_html_report with an engine result whose agent fails 3 with-skill cases: the case findings add 3 fixes and next steps, the 12 token case rows go with a note, the payload passes the serialization check and equals the run without token usage apart from token_usage and report_truncation, and the HTML hero verdict matches that run (Passed)
      • validate --tier3 with that payload, and again with a run result.json whose next steps the loader adds after the build and push the payload past the limit: the applicability fields are added, the 12 token case rows go with a note, the payload passes the serialization check, and the HTML, JSON and BENCHMARK.md reports name no payload limit (2)
      • a payload that a later write pushes past the limit even without token usage keeps no token usage and no token record
    • no baseline (1): in a run with no baseline directory, token_usage calls the baseline not_run with the one reason The baseline did not run., and the BENCHMARK.md Token Usage row says not run without 0 of 0, a status or a case mismatch
    • reused baseline (1): with a run config that records a reused baseline, token_usage has baseline_reused, and the validate and tier3 evaluate terminal output, the Markdown report, BENCHMARK.md and the HTML report all say that the baseline tokens were used in the earlier run
    • terminal (3): validate full report rows, notes and pointer; tier3 evaluate prints the agent sums the report step recorded and its own pointer; agent names print as text, not markup
    • reports (7): BENCHMARK.md section against the golden file tests/golden/benchmark_token_usage/TOKEN_USAGE.md; the card passes the public gate; the Markdown table; the HTML rows under Measured Agent Resources; with 2 agents × 70 cases, a payload above the 256 KiB preview trigger keeps whole HTML rows (complete totals, change, case names) and shows 64 case rows per agent plus "12 more case row(s)"; hostile case names are escaped in HTML, Markdown and BENCHMARK.md; the Markdown tables cap case rows at 50 and say where the rest are
    • docs (1): docs/reports.mdx and the CHANGELOG entry name the payload fields, omission keys and reason codes, the case findings and applicability fields, baseline_not_run, baseline_reused and --reuse-baseline, and the case where token usage is left out without a record
  • Fail-before:
    • Against src/ of 6cd5b7f (before the reused-baseline label) with the final tests, both reused-baseline tests fail.
    • Against 603db9e (its src/, docs and CHANGELOG, before the last review round's fixes) with the 73 tests of 606c42f, 10 fail: the skipped baseline, no record (2), run mode and absent evidence tests in the module, and the case findings, validate, over-the-limit, no-baseline run and docs tests in the report module. The case findings and validate tests fail with The Tier 3 payload exceeds the 2,722-node report limit.
    • With the tests of 606c42f and the whole earlier base tree (c9ed61c, src/ and docs) plus only the two new modules, the 48 module tests pass (they test the module itself) and 23 of the 25 report tests fail. The 2 that pass pin behavior the base already has: no token_usage without token counts, and the public gate on a card without the section. With this branch's docs and CHANGELOG instead of the base ones, the docs test passes too, so 22 of 25 fail.
  • Size probes on this branch, built with the report tests' run fixture. In the first five, the payload is the same as the one built without token usage, apart from token_usage and its omission keys:
    • 2 agents × 300 cases: 73,647 values without token usage, 95,363 with all 600 token case rows.
    • 2 agents × 394 cases: the 788 token case rows go, leaving 95,667 values and no serialization issue.
    • 3 agents × 300 cases: the 900 token case rows go, leaving 92,476 values and no serialization issue.
    • 2 agents × 450 cases: 101,398 values without token usage, past the limit on its own, so no token_usage and no token record.
    • 12 agents × 200 cases: main's budget drops 3,001 dataset and trial items and leaves 5,779 values; token usage then adds all 2,400 case rows (92,655 values) within the limits.
    • 2 agents × 316 cases with 95 of one agent's baseline trials missing trajectory.json: the payload keeps all 632 token case rows at 99,963 values. Rendered through render_agent_eval_html_report with 3 failed with-skill cases, the case findings bring it to 100,007 values, the token case rows go (77,542 values), and report.html reads Passed 0.90. Without that last fit it reads Passed N/A.
    • A run with only codex/with-skill, with no without-skill directory or with a skipped one: the baseline is not_run and the change reason is only The baseline did not run.
  • The full suite, run with -n 6: 27,487 passed, 35 skipped. The 7 failures are environment-only on the test machine and fail the same way on main: the CI bootstrap and feedback launcher isolation tests (3), the secure Docker sidecar tests (2), a Bedrock preflight probe test and a Harbor process timeout test.
  • feat(reporting): add per-case expectation diagnostics #382, feat(tier3): reuse a compatible retained no-skill baseline #384, feat(tier3): add run budget limits with admission control and partial results #404 and feat(reports): show how many cases and attempts each score rests on #406 have merged, so their tests now run in the full suite with this branch.
  • ruff check and ruff format --check are clean on the changed Python files, and scripts/check_oss_boundary.py passed.

🤖 Generated with Claude Code

rng1995 and others added 19 commits November 9, 2026 10:27
New skillevaluator.tier3.token_usage sums each attempt's token counters
per case, per agent arm and over all agents, with coverage. Cached
tokens are part of the prompt and are never added again. Missing or
invalid counters add nothing and leave the arm partial; nothing is
estimated. Attempts that failed before scoring count as unscored usage.
A change needs complete counts for the same attempts in both arms and
no failed arm. It is a measurement only and changes no score.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The report loader skipped attempts without a usable reward.json and
cleared the rewards of an arm whose scores it withholds, so their tokens
were lost. It now keeps, per arm, usage_only_attempts: the trajectory
token counters of each unscored attempt and of each scored attempt of a
failed or unknown arm. Scores, pass@k, rewards_complete and resource
totals do not read them.

The token usage module counts these attempts, matches an unscored
attempt's trial-name prefix to its case (Harbor cuts task names to 32
characters), and adds recovered timeout attempts to the expected count.
It also gains helpers to drop per-case rows and to keep only the agent
sums.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
build_agent_eval_payload adds a token_usage object (per agent arm, per
case and over all agents) when any attempt has token counts. The
payload budget drops its per-case rows together with the trials they
summarize. The Tier 3 report step also records the per-agent sums in
the run result for the terminal summary. resources keeps its own
complete-only totals.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
New reporting/tier3_token_usage.py turns the token_usage payload into
table rows that every report shares, so the numbers and wording match:

- BENCHMARK.md: a Token Usage section after Results at a Glance, with
  agent and all-agent rows, notes on why a change is missing, and the
  first 50 case rows in a collapsed table.
- Markdown report: the same table under the Tier 3 section.
- HTML report: a table of every case under Measured Agent Resources.
- Terminal: the full validate report and tier3 evaluate --verbose print
  the agent rows.

Each table says the numbers are measured and not scored. Case and agent
names are escaped for each format.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe the token_usage payload, its coverage and change rules, and
where each report shows it. Add a CHANGELOG entry under Unreleased >
Added and a test that keeps the docs and the entry in step with the
payload fields.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…report uses it

Open pull requests add their own imports right below the run_status
import of markdown.py. Importing inside the Tier 3 block leaves that
line alone, so those branches merge without a conflict.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e are

BENCHMARK.md and the Markdown report now point at the JSON payload's
token_usage for case rows past the first 50. The HTML report bounds its
Tier 3 lists for large payloads, so the docs say it shows at most 64
case rows per agent then, and that the payload keeps every case unless
the size budget drops them with the trials.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A sibling branch adds its own helper right after
_trajectory_token_counter. Keeping the usage helpers just above
load_agent_data leaves that spot alone, so both branches merge cleanly.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The cap counts case rows across all agents, not cases.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nsafe changes

An attempt without a usable reward now takes its case from the task
directory its copied Harbor result.json or config.json names. Without
those files it uses the trial name before Harbor's "__<id>" suffix
(rsplit, since a case ID may contain "__"), then a stop-on-pass trial
name (...-<with|without>-<case>-attemptNNN__...), then Harbor's
32-character cut. A case such as auth__login no longer gets a phantom
"auth" row, and a timed-out stop-on-pass attempt no longer adds a row
named after its job.

A change also needs both arms to have succeeded: an arm that ran with an
unrecognized run status, whose scores the report withholds, now blocks it
with <arm>_status_unknown. A sum above 2**53 - 1 is unavailable with
total_out_of_range and null totals, and blocks the change with
<arm>_total_out_of_range, instead of turning null after the payload is
sanitized while its status still said complete.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aces score evidence

Token usage used to join the payload before the size budget, which only
measured bytes and dropped its case rows only in the stage that also
drops every trial. Its case rows (about 45 JSON values each per agent)
could push a run that is valid on main past the 100,000-node report
limit, so a PASS run read as Tier 3 Incomplete in the HTML report and
BENCHMARK.md. Under the byte budget they also cost the non-best agents'
details and, for large runs, the best agent's trials.

The budget now runs on the payload without token usage, exactly as on
main. Token usage is added afterwards only while the payload stays within
the embedded size budget and passes agent_eval_report_serialization_issue.
Otherwise its case rows go first (token_usage.case_rows_omitted and
report_truncation.omitted.token_usage_case_rows), then the sums
(report_truncation.omitted.token_usage). If even that record does not
fit, the payload stays exactly as the budget left it. Read-only payloads
(enforce_embedded_size=False) keep everything, as before.

Dashboards treat the two new omission keys as diagnostics, so dropped
token rows never mark trial coverage truncated. Main's retained-run
dashboard test now sizes its budget from the payload without token
usage, which keeps its intent: only the non-best agent's details go.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The HTML token table read the bounded Tier 3 preview. Above 256 KiB the
preview walk spends its character budget in key order and reaches
token_usage last, so it blanked coverage.status, delta.status and
entry_id: complete rows printed "(partial)", changes printed N/A, and
case rows were named "unknown".

The table now reads the full display payload, like the steps-by-case
chart, and shows at most 64 case rows per agent with a line that says how
many more are in the JSON payload. (This supersedes the "a table of every
case" wording in 2db3fa8.) The bounded preview leaves token_usage out, so
token rows can neither trigger the preview nor spend its budget.

When the payload dropped the case rows to stay within its limits, the
HTML table, the Markdown report, BENCHMARK.md and the terminal say how
many. The terminal names the files that hold the case rows for each
command: the HTML, Markdown and JSON reports for validate, and
report.html and tier3-benchmark.md in the run directory for
tier3 evaluate. BENCHMARK.md is not one of them.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t limits

docs/reports.mdx now says that token usage joins the payload after the
size budget and never displaces score evidence, which fields record
dropped case rows or sums, that a change needs both arms to have
succeeded (baseline_status_unknown), that a sum above 2^53 - 1 is
total_out_of_range, where an unscored attempt's case comes from, that
the HTML table reads the full data with at most 64 case rows per agent,
and which files each terminal command points to. The CHANGELOG entry and
the docs test follow.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… function

The preview call in HTMLReporter.render_all is back to main's single
line, and _bounded_tier3_preview itself drops token_usage before it
measures the payload. The behavior is the same; the call line stays free
for the open PR that adds lines right after it.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…load writes

Token usage filled the payload up to the report limits when it was built.
Two steps then write to the same payload: the tier3 evaluate report step adds
its case findings, and validate adds its applicability fields. Either could
push a payload with token usage past the 100,000-value limit, so a passing
run read as Tier 3 Incomplete although the same run passes without token
usage.

fit_token_usage now runs after the build and again after each of those
writes. It drops the token case rows, then the sums, and records each drop
in report_truncation. If even that record does not fit, it removes the token
usage and its records, which leaves the payload as it is without token usage.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A run with no baseline arm for an agent reads as baseline not run in the
score tables. Its token usage said baseline 0/0, "Baseline token counts
cover 0 of 0 attempts", "baseline status unknown" and "The arms ran
different cases", three reasons for one cause.

An arm without attempts is now not_run when the payload mode leaves it out
(with_skill_only or baseline_only) or the agent has no record of it. An
arm without attempts no longer gets a status-unknown reason, and its
incomplete reason says that no attempts were recorded. A case scope
mismatch needs attempts in both arms.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Token usage section said token_usage appears whenever an attempt
recorded token counts, and that a drop is recorded in report_truncation.
When the payload cannot carry even that record, for example because it
already exceeds the report limits without token usage, token_usage is left
out without a record. The section now says so.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The case findings regression test read the verdict after the hidden
"Tier 3 verdict:" label, which only some template versions carry. It now
reads the hero's verdict chip, incomplete reason and score, so it does not
depend on that label.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 marked this pull request as ready for review November 9, 2026 19:50
rng1995 and others added 4 commits November 9, 2026 19:30
…ting

The base branch merged main, so this branch now takes main's changes
through it. CHANGELOG.md is the only conflict; both sides' entries are
kept under Unreleased > Added.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ting

The base branch (naren/port-tier3-baseline-incomplete-reporting) now
contains main d717f22.

Conflicts:
- CHANGELOG.md: main and this branch both added an entry at the end of
  Unreleased > Added. Kept both: main's CI onboarding entry first, then
  this branch's token usage entry.
- src/skillevaluator/reporting/html.py (_bounded_tier3_preview): main
  now works on a private copy of the payload and drops per-trial
  activation diagnostics before the preview budget. This branch left
  token_usage out of the preview. Kept main's copy and activation
  stripping, and build the copy from the payload without token_usage, so
  token rows still neither trigger the preview nor spend its budget.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ext steps

Main now adds the run's next steps to a built Tier 3 payload: the loader
reads them from the run's result.json, and the report step adds them with
its case findings. Both writes happen before fit_token_usage runs in the
report step and in validate, so no code change is needed. The validate
test now also runs with a result.json whose next steps push the payload
past the node limit after the build, and the report step test checks
that its payload carries next steps. The docs and CHANGELOG name the next
steps among the later writes.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's --reuse-baseline (#384) copies the reused run's baseline
reward.json, trajectory.json and result.json files into the new run, so
token_usage counted their tokens as this run's baseline usage. When the
run config records a reused baseline, token_usage now carries
baseline_reused: true, and every token usage table (validate and
tier3 evaluate terminal output, the Markdown report, BENCHMARK.md and
the HTML report) says that the baseline tokens were used in the earlier
run, not in this one. Sums and the change stay as they were: the copied
rows are measurements like any other.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a telemetry-validation gap in the new usage-only attempt loader.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full production diff and token-accounting/report consumers. Fixed invalid cached telemetry being published as complete zero-cache usage in 361f402. The inline thread is resolved. Regression evidence: five cases failed before the fix, 242 affected tests passed after it, and the five cases passed again with locked dependencies. make lint and pinned Fern check passed; sdist and wheel built successfully (build tooling installed in the local review environment). Updated the stack with #407/current main without conflicts. Merge #407 before this PR; this PR remains open.

@rng1995
rng1995 merged commit 05e4b11 into naren/port-tier3-baseline-incomplete-reporting Nov 12, 2026
25 checks passed
@rng1995
rng1995 deleted the naren/port-tier3-token-usage-reporting branch November 12, 2026 19:54
rng1995 added a commit that referenced this pull request Nov 12, 2026
…t run (#407)

* fix(reporting): describe a failed Tier 3 arm as incomplete, not as not run

When one attempt of an agent's no-skill baseline fails, for example on the
agent timeout, the baseline arm fails while the with-skill arm keeps its
scores. BENCHMARK.md then printed "baseline not run; uplift unavailable"
for a baseline that ran, and no report said which arm was missing.

- The canonical payload gains coverage_notices: one entry per arm whose
  recorded execution_status is failed, with its scored and expected
  attempts, the first Harbor exception type in words, and a message.
- BENCHMARK.md cells read "baseline incomplete (s of e attempts scored)"
  or "baseline unavailable" when nothing scored; a skipped baseline still
  reads "baseline not run". An Agent coverage list under the table names
  each failed arm, and the Tier 3 evidence cell names the agent and arm.
- The HTML report shows the notices under Agent coverage notes, and the
  terminal prints them in the Tier 3 block.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): document incomplete Tier 3 arms and coverage notices

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(reporting): keep Tier 3 coverage notes whole and visible in every report

- HTML: the display sanitizer keeps only coverage notices that are objects
  with a non-empty message, so a malformed `coverage_notices` value (a
  number, a boolean, a single object) no longer breaks the report. The key
  is walked right after `execution_status`, so the bounded preview of a
  payload above 256 KiB keeps every message whole instead of cutting it to
  an empty bullet. The template also drops empty messages.
- Terminal: `validate` runs Tier 3 non-blocking by default, and a failed
  non-blocking result has errors but no findings, so its Tier 3 block was
  never printed. A non-blocking result that carries coverage notes is now
  rendered with the non-blocking findings, so the notes show without
  `--block-on-agent-eval`.
- First failure: an acronym keeps its trailing digits
  (`S3UploadFailedError` gives `s3 upload failed error`, `HTTP2Error` gives
  `http2 error`), and the collector's case-coverage diagnostics, which list
  case IDs, are skipped so a case ID shaped like an exception type is never
  named as the failure.
- The notice code is `baseline_failed` or `with_skill_failed`: the arm whose
  recorded status is `failed`, distinct from any notice for an agent that
  stays scored. When the agent itself is marked failed, the message says the
  agent and the Tier 3 run are marked failed.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): list the coverage notice fields and where they print

Document each `coverage_notices` field, including `code` and the null
counts with state `failed` when an arm's counters are unusable, the
`baseline failed` cell, and that `validate` prints the notes also when
Tier 3 is non-blocking.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): say that only the full terminal report prints coverage notes

A plain `validate` shows the compact pipeline view and drops the `cli`
reporter, so the Tier 3 coverage notes print only with `validate --verbose`
or an explicit `-r cli`. The docs and the CHANGELOG entry said `validate`
prints them. They now say the compact default view leaves them to the HTML
and JSON reports and `BENCHMARK.md`. A new test pins that behavior and the
wording.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): say that HTML agent details label a failed baseline as missing

An agent whose baseline arm ran and failed gets the same per-agent HTML
labels as a skipped baseline: `no baseline` and `baseline N/A`. Only the
Agent coverage notes callout tells the two apart. The **no baseline**
definition now covers a failed baseline arm and points to the callout, and
the callout paragraph names the shared labels. A new test pins the labels,
the callout and the wording. The labels themselves are unchanged.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(reporting): read only the score rows of Results at a Glance

Main now adds Required checks passed, Goals met and Security clean rows
to the BENCHMARK.md Results at a Glance table. They compare counts, not a
baseline score, and read N/A for a failed baseline arm. The incomplete-arm
tests now read only the Overall and dimension rows, and the reports guide
says those are the cells that name an incomplete baseline.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(reporting): pin where the terminal prints non-blocking coverage notes

Main now prints the agent tables of a Tier 3 result that is in neither
the Failure Details nor the Non-blocking Findings section, so the notes
of a non-blocking failed result would print even without this branch's
wider non-blocking condition, as a bare table above both sections. The
test now checks that the notes print once, under Non-blocking Findings,
with the result's errors. It fails if that condition is dropped.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(tier3): report token usage per case and agent (#427)

* feat(tier3): add token usage accounting per case, agent and run

New skillevaluator.tier3.token_usage sums each attempt's token counters
per case, per agent arm and over all agents, with coverage. Cached
tokens are part of the prompt and are never added again. Missing or
invalid counters add nothing and leave the arm partial; nothing is
estimated. Attempts that failed before scoring count as unscored usage.
A change needs complete counts for the same attempts in both arms and
no failed arm. It is a measurement only and changes no score.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(tier3): keep the token usage of attempts that scores never read

The report loader skipped attempts without a usable reward.json and
cleared the rewards of an arm whose scores it withholds, so their tokens
were lost. It now keeps, per arm, usage_only_attempts: the trajectory
token counters of each unscored attempt and of each scored attempt of a
failed or unknown arm. Scores, pass@k, rewards_complete and resource
totals do not read them.

The token usage module counts these attempts, matches an unscored
attempt's trial-name prefix to its case (Harbor cuts task names to 32
characters), and adds recovered timeout attempts to the expected count.
It also gains helpers to drop per-case rows and to keep only the agent
sums.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(reporting): add token_usage to the canonical Tier 3 payload

build_agent_eval_payload adds a token_usage object (per agent arm, per
case and over all agents) when any attempt has token counts. The
payload budget drops its per-case rows together with the trials they
summarize. The Tier 3 report step also records the per-agent sums in
the run result for the terminal summary. resources keeps its own
complete-only totals.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(reporting): show Tier 3 token usage in every report

New reporting/tier3_token_usage.py turns the token_usage payload into
table rows that every report shares, so the numbers and wording match:

- BENCHMARK.md: a Token Usage section after Results at a Glance, with
  agent and all-agent rows, notes on why a change is missing, and the
  first 50 case rows in a collapsed table.
- Markdown report: the same table under the Tier 3 section.
- HTML report: a table of every case under Measured Agent Resources.
- Terminal: the full validate report and tier3 evaluate --verbose print
  the agent rows.

Each table says the numbers are measured and not scored. Case and agent
names are escaped for each format.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): document Tier 3 token usage

Describe the token_usage payload, its coverage and change rules, and
where each report shows it. Add a CHANGELOG entry under Unreleased >
Added and a test that keeps the docs and the entry in step with the
payload fields.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(reporting): import the token usage table where the Markdown report uses it

Open pull requests add their own imports right below the run_status
import of markdown.py. Importing inside the Tier 3 block leaves that
line alone, so those branches merge without a conflict.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): say where Tier 3 token usage case rows beyond the table are

BENCHMARK.md and the Markdown report now point at the JSON payload's
token_usage for case rows past the first 50. The HTML report bounds its
Tier 3 lists for large payloads, so the docs say it shows at most 64
case rows per agent then, and that the payload keeps every case unless
the size budget drops them with the trials.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(tier3): define the usage loader helpers next to load_agent_data

A sibling branch adds its own helper right after
_trajectory_token_counter. Keeping the usage helpers just above
load_agent_data leaves that spot alone, so both branches merge cleanly.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reporting): say the JSON payload keeps every token usage case row

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): say BENCHMARK.md shows the first 50 token usage case rows

The cap counts case rows across all agents, not cases.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): attribute unscored token usage to its case and withhold unsafe changes

An attempt without a usable reward now takes its case from the task
directory its copied Harbor result.json or config.json names. Without
those files it uses the trial name before Harbor's "__<id>" suffix
(rsplit, since a case ID may contain "__"), then a stop-on-pass trial
name (...-<with|without>-<case>-attemptNNN__...), then Harbor's
32-character cut. A case such as auth__login no longer gets a phantom
"auth" row, and a timed-out stop-on-pass attempt no longer adds a row
named after its job.

A change also needs both arms to have succeeded: an arm that ran with an
unrecognized run status, whose scores the report withholds, now blocks it
with <arm>_status_unknown. A sum above 2**53 - 1 is unavailable with
total_out_of_range and null totals, and blocks the change with
<arm>_total_out_of_range, instead of turning null after the payload is
sanitized while its status still said complete.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): add token usage after the report budget so it never displaces score evidence

Token usage used to join the payload before the size budget, which only
measured bytes and dropped its case rows only in the stage that also
drops every trial. Its case rows (about 45 JSON values each per agent)
could push a run that is valid on main past the 100,000-node report
limit, so a PASS run read as Tier 3 Incomplete in the HTML report and
BENCHMARK.md. Under the byte budget they also cost the non-best agents'
details and, for large runs, the best agent's trials.

The budget now runs on the payload without token usage, exactly as on
main. Token usage is added afterwards only while the payload stays within
the embedded size budget and passes agent_eval_report_serialization_issue.
Otherwise its case rows go first (token_usage.case_rows_omitted and
report_truncation.omitted.token_usage_case_rows), then the sums
(report_truncation.omitted.token_usage). If even that record does not
fit, the payload stays exactly as the budget left it. Read-only payloads
(enforce_embedded_size=False) keep everything, as before.

Dashboards treat the two new omission keys as diagnostics, so dropped
token rows never mark trial coverage truncated. Main's retained-run
dashboard test now sizes its budget from the payload without token
usage, which keeps its intent: only the non-best agent's details go.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(reporting): read the HTML token table from the full Tier 3 data

The HTML token table read the bounded Tier 3 preview. Above 256 KiB the
preview walk spends its character budget in key order and reaches
token_usage last, so it blanked coverage.status, delta.status and
entry_id: complete rows printed "(partial)", changes printed N/A, and
case rows were named "unknown".

The table now reads the full display payload, like the steps-by-case
chart, and shows at most 64 case rows per agent with a line that says how
many more are in the JSON payload. (This supersedes the "a table of every
case" wording in 2db3fa8.) The bounded preview leaves token_usage out, so
token rows can neither trigger the preview nor spend its budget.

When the payload dropped the case rows to stay within its limits, the
HTML table, the Markdown report, BENCHMARK.md and the terminal say how
many. The terminal names the files that hold the case rows for each
command: the HTML, Markdown and JSON reports for validate, and
report.html and tier3-benchmark.md in the run directory for
tier3 evaluate. BENCHMARK.md is not one of them.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): document how Tier 3 token usage stays within the report limits

docs/reports.mdx now says that token usage joins the payload after the
size budget and never displaces score evidence, which fields record
dropped case rows or sums, that a change needs both arms to have
succeeded (baseline_status_unknown), that a sum above 2^53 - 1 is
total_out_of_range, where an unscored attempt's case comes from, that
the HTML table reads the full data with at most 64 case rows per agent,
and which files each terminal command points to. The CHANGELOG entry and
the docs test follow.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor(reporting): leave token usage out inside the bounded preview function

The preview call in HTMLReporter.render_all is back to main's single
line, and _bounded_tier3_preview itself drops token_usage before it
measures the payload. The behavior is the same; the call line stays free
for the open PR that adds lines right after it.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): keep token usage within the report limits after later payload writes

Token usage filled the payload up to the report limits when it was built.
Two steps then write to the same payload: the tier3 evaluate report step adds
its case findings, and validate adds its applicability fields. Either could
push a payload with token usage past the 100,000-value limit, so a passing
run read as Tier 3 Incomplete although the same run passes without token
usage.

fit_token_usage now runs after the build and again after each of those
writes. It drops the token case rows, then the sums, and records each drop
in report_truncation. If even that record does not fit, it removes the token
usage and its records, which leaves the payload as it is without token usage.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): show token usage of a baseline that did not run as not run

A run with no baseline arm for an agent reads as baseline not run in the
score tables. Its token usage said baseline 0/0, "Baseline token counts
cover 0 of 0 attempts", "baseline status unknown" and "The arms ran
different cases", three reasons for one cause.

An arm without attempts is now not_run when the payload mode leaves it out
(with_skill_only or baseline_only) or the agent has no record of it. An
arm without attempts no longer gets a status-unknown reason, and its
incomplete reason says that no attempts were recorded. A case scope
mismatch needs attempts in both arms.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reports): say when Tier 3 token usage is left out without a record

The Token usage section said token_usage appears whenever an attempt
recorded token counts, and that a drop is recorded in report_truncation.
When the payload cannot carry even that record, for example because it
already exceeds the report limits without token usage, token_usage is left
out without a record. The section now says so.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(reporting): read the Tier 3 verdict from the HTML hero chip

The case findings regression test read the verdict after the hidden
"Tier 3 verdict:" label, which only some template versions carry. It now
reads the hero's verdict chip, incomplete reason and score, so it does not
depend on that label.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(tier3): keep token usage within the report limits after main's next steps

Main now adds the run's next steps to a built Tier 3 payload: the loader
reads them from the run's result.json, and the report step adds them with
its case findings. Both writes happen before fit_token_usage runs in the
report step and in validate, so no code change is needed. The validate
test now also runs with a result.json whose next steps push the payload
past the node limit after the build, and the report step test checks
that its payload carries next steps. The docs and CHANGELOG name the next
steps among the later writes.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(tier3): label a reused baseline's token usage

Main's --reuse-baseline (#384) copies the reused run's baseline
reward.json, trajectory.json and result.json files into the new run, so
token_usage counted their tokens as this run's baseline usage. When the
run config records a reused baseline, token_usage now carries
baseline_reused: true, and every token usage table (validate and
tier3 evaluate terminal output, the Markdown report, BENCHMARK.md and
the HTML report) says that the baseline tokens were used in the earlier
run, not in this one. Sums and the change stay as they were: the copied
rows are measurements like any other.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): reject invalid cache counters in usage-only attempts

Signed-off-by: Narendran Raghavan <[email protected]>

---------

Signed-off-by: Narendran Raghavan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

---------

Signed-off-by: Narendran Raghavan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
rng1995 added a commit that referenced this pull request Nov 14, 2026
…l token notes accurate (#546)

* fix(tier3): expect only the attempts a case planned in its token usage

A case's expected attempts came from pass@k's k minus the attempts
skipped after a pass. Under a run budget the collector plans fewer than
k attempts for a case and records the refused ones as neither skipped
nor missing, so the case row read as partial with missing attempts
while its agent row was complete.

Take a case's expected attempts from its pass@k counters instead:
scored plus recovered plus missing attempts, which leave out attempts
skipped after a pass and attempts the budget refused. A record without
those counters still gives k minus the skipped attempts.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(tier3): format the token usage tests

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): keep an invalid cache counter of a scored attempt out of token usage

The loader reads a trajectory's counters into each reward's token
summary, where an invalid value becomes absent, the same as the cache
counter Harbor leaves out when it is zero. Token usage then read an
invalid cache counter of a scored attempt as 0 and counted the attempt
as measured, both in a succeeded arm and in an arm whose scores are
withheld. Only attempts without a reward were left unmeasured.

The loader now names the counters a trajectory recorded with an invalid
value, never their values. A report trial lists them in
invalid_token_counters next to its unchanged tokens, and usage-only
attempts carry the same field. Token usage counts such an attempt as
unmeasured with the invalid_token_counters reason. The resources totals,
which read only prompt and completion, are unchanged.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): attribute an unscored native task attempt to its case

An attempt without a scored reward took its token usage case from the
task directory its Harbor result names. A native task may set its own
[metadata] entry_id, so its directory is not its case ID, and its
unscored attempts landed in a separate case row. The arms then looked
like they ran different cases, and a case row left out the attempt's
tokens.

The collector maps each Harbor task to its case with the run's trusted
selector mapping. It now records that case in the unscored attempt's
failure.json as entry_id, and the report loader prefers it. Runs
without the record keep the directory and trial name fallback.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(reporting): say no report has token case rows once the payload dropped them

When the report payload has to make room, it drops the token usage
case rows of every agent, and every report reads that payload. The
validate and tier3 evaluate terminal tables still pointed readers at
the reports for the case rows and then said the rows were left out
of "this report", which contradicts itself.

Once the payload dropped the case rows, the terminal tables now say
that they were left out of every report and that the agent sums cover
every attempt, instead of naming the report files.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): print token usage for a run whose arms all failed

tier3 evaluate printed the token usage table only with the score
tables, which a run without a usable arm never shows. A run whose
every attempt hit the agent timeout used tokens like any other, and
the report step recorded its sums, but the terminal showed only the
panel that says the evaluation did not complete.

Print the agent token sums for such a run too, after that panel and
under the same rule as the score tables: always when there is no case
summary to show.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): record the case of an unscored trial that has only its config

The collector read an unscored trial's case only from its Harbor
result.json. A trial that stopped before Harbor wrote its result still
has its config.json, which names the same task, so the collector now
falls back to it. Without the record, a native task attempt whose
directory differs from its entry_id landed in a case row of its own.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: describe the Tier 3 token usage fixes in the changelog

Add a Fixed entry for the token usage fixes that follow up #427, say in
the reports reference that a case expects only the attempts its pass@k
record planned, and reflow the invalid counter paragraph.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: say plain tier3 evaluate prints the token sums of a failed run

The Fixed changelog entry said `tier3 evaluate --verbose` prints the
agent token sums for a run whose arms all failed. A run without a usable
arm never shows a case summary, so the table prints with or without
--verbose, as docs/reports.mdx already says. The entry now names plain
`tier3 evaluate`, and its lead sentence says each attempt is counted in
the case it belongs to rather than "in its own case", which read like
the separate row the fix removes.

Rewrap the token usage bullet in docs/reports.mdx that had one line of
96 characters. The docs and changelog contract test now checks the
entry's wording and that no line of the token usage section is wider
than 80 characters.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): name invalid token counters only from the trajectory

The loader marks the token counters that a scored attempt's trajectory
recorded with an invalid value under an internal reward key. It never
cleared that key from the reward.json it loaded, so a results directory
whose reward.json held it kept the file's list whenever the trajectory
was valid. A list that mixed types made loading fail on sorting it, and
a list of names marked a valid attempt unmeasured or put any name the
file held into the report trial's invalid_token_counters.

The loader now drops the key from each loaded reward before it reads the
trajectory. Report trials and usage-only attempts keep only names of
token counters, in prompt, completion and cached order, so both list
the same counters the same way.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): record the case of an unscored attempt without a selector map

The collector recorded the case of an unscored attempt in failure.json
only when the run passed the trusted task selector map. The NeMo Gym
backend collects without that map, so an unscored attempt of a native
task whose [metadata] entry_id differs from its directory still took
the task directory as its case: token usage split the case into two
rows and left the attempt's tokens out of the real case row.

Without the selector map, the collector now resolves the case of an
unscored trial from its result.json or config.json with the arm's
suffix and staged task entry IDs, the same way it resolves a scored
trial, and records it only when that case is authoritative. The
reader keeps its task directory fallback otherwise.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(reporting): find the token usage Fixed entry in any release section

The CHANGELOG check of the token usage contract read the Fixed entry
only from the first release section. Once Unreleased becomes a numbered
release, a new Unreleased section without a Fixed subsection raises
IndexError, and one with a Fixed subsection that lacks this entry fails
the single-entry unpack. Search the Fixed subsection of every release
section instead, as the Added check in the same test already does, and
keep the content assertions on the entry it finds.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(tier3): format the token usage tests

Drop the blank line at the end of the token usage test module so that
ruff format --check passes on it.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): name only the reports a run wrote in the token usage pointer

The tier3 evaluate token table always said the case rows are in report.html
and tier3-benchmark.md. Only the Harbor runner writes the benchmark; a NeMo
Gym run writes report.html alone, and a run whose report step failed writes
neither. The pointer now follows the paths the runner recorded:
benchmark_path names both files, report_path alone names report.html, and
without either no file is named.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Signed-off-by: Narendran Raghavan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant