Remove misleading total_tokens: 0 from logs summary#42722
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
total_tokens: 0 from logs summary
|
✅ Test Quality Sentinel completed test quality analysis. |
|
🧠 Matt Pocock Skills Reviewer failed during the skills-based review. |
|
✅ PR Code Quality Reviewer completed the code quality review. |
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #42722 does not have the 'implementation' label and has only 15 new lines of code in business logic directories (threshold: 100). |
There was a problem hiding this comment.
Pull request overview
Removes the misleading total_tokens aggregate from gh aw logs summaries and related renderers/tests, since token totals are not available without downloading agent artifacts and were consistently reported as zero.
Changes:
- Removes
TotalTokensfromLogsSummaryand stops accumulatingtotalTokensinbuildLogsData. - Updates compact and TSV summary lines to omit
tokens=.... - Updates affected tests to stop asserting
total_tokenspresence/value in the logs summary.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/logs_report.go | Drops LogsSummary.TotalTokens and removes token aggregation from buildLogsData. |
| pkg/cli/logs_format_compact.go | Removes tokens= from compact/verbose compact summary output. |
| pkg/cli/logs_format_tsv.go | Removes token count from TSV summary header line and updates format docs accordingly. |
| pkg/cli/mcp_schema_test.go | Updates schema validation fixture data to match LogsSummary without TotalTokens. |
| pkg/cli/logs_summary_file_test.go | Removes TotalTokens from summary file fixtures/assertions. |
| pkg/cli/logs_report_test.go | Updates console rendering test fixtures to omit TotalTokens. |
| pkg/cli/logs_json_test.go | Removes TotalTokens assertions from logs summary-related JSON tests. |
| pkg/cli/logs_json_clean_test.go | Updates “field exists” assertions to avoid total_tokens in summary. |
| pkg/cli/logs_empty_runs_test.go | Removes “summary total_tokens exists/is zero” expectations for empty runs. |
| pkg/cli/logs_ci_scenario_test.go | Updates required/expected summary fields lists to remove total_tokens. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 10/10 changed files
- Comments generated: 2
- Review effort level: Low
| // Verify the summary contains required fields | ||
| if _, exists := summary["total_runs"]; !exists { | ||
| t.Errorf("Expected total_runs field in summary. Summary: %+v", summary) | ||
| } |
🧪 Test Quality Sentinel Report✅ Test Quality Score: 83/100 — Excellent
📊 Metrics (12 modified tests)
|
There was a problem hiding this comment.
Non-blocking observations
The fix is directionally correct — surfacing total_tokens: 0 alongside a non-zero total_aic was genuinely confusing. Two concerns worth addressing before this lands:
🔍 Findings summary
-
--artifacts agentregression (logs_report.go):TotalTokensis dropped entirely rather than madeomitempty. When users run with--artifacts agent, per-runRunData.TokenUsagefields are non-zero — but the summary now never aggregates them. Usingomitemptywould hide the field in the default (zero) case while preserving it for artifact-download mode. -
Silent TSV positional breakage (
logs_format_tsv.go): The# N runs | T duration | ...header line loses one positional field. Scripts that parse this positionally will silently misread subsequent fields. No test covers the exact TSV summary header format.
🔎 Code quality review by PR Code Quality Reviewer · 112.2 AIC · ⌖ 9.59 AIC · ⊞ 1.6K
Comment /review to run again
| @@ -191,7 +189,6 @@ func buildLogsData(processedRuns []ProcessedRun, outputDir string, continuation | |||
| if run.Duration > 0 { | |||
There was a problem hiding this comment.
--artifacts agent mode loses token summary: removing TotalTokens entirely drops the aggregate even when per-run token_usage fields are non-zero (populated by the agent artifact).
💡 Suggested fix
The PR's stated rationale is that the field is "always zero without --artifacts agent" — which is true. But when --artifacts agent IS used, run.TokenUsage (RunData.TokenUsage, line 109) is populated with real non-zero counts, and totalTokens += run.TokenUsage was the only place those were aggregated into the summary.
A less destructive fix: keep the field but suppress it when zero:
// In LogsSummary struct:
TotalTokens int `json:"total_tokens,omitempty" console:"header:Total Tokens,format:number,omitempty"`This makes total_tokens absent from JSON in the default mode (matches the stated goal) while preserving the aggregate for users who download agent artifacts. The current change silently regresses --artifacts agent users who relied on the summary token count.
There was a problem hiding this comment.
Review: Remove misleading total_tokens: 0 from logs summary
The changes are correct and well-reasoned. The total_tokens field in LogsSummary was always 0 in normal usage because token data requires the --artifacts agent flag, while the logs command only downloads the usage artifact (providing total_aic). Emitting a persistent total_tokens: 0 alongside a real total_aic value was genuinely misleading.
What was reviewed
logs_report.go—TotalTokensfield removed fromLogsSummary;totalTokensaccumulator dropped frombuildLogsData. The remaining per-runrun.TokenUsagefield onRunDatais intentionally kept.logs_format_compact.go/logs_format_tsv.go—tokens=removed from summary output lines. TSV doc comment updated to match.- 7 test files —
TotalTokens/total_tokensassertions removed. Field-existence checks previously assertingtotal_tokensis present are correctly replaced with checks on fields that are actually populated.
Observations
EpisodeMetadata.TotalTokens(inlogs_episode.go) is untouched — correct, episodes aggregaterun.TokenUsagewhich CAN be non-zero when the agent artifact is present.health_metrics.goandaudit_cross_run*.goretain theirTotalTokensfields — correct, different data paths unaffected by this change.cost-management.mddocumentstotal_tokensas an episode field (episodes[].total_tokens), which is unaffected by this change.total_aichasomitemptyin JSON tags and would be0in the no-runs test, so its absence from the mandatoryexpectedFieldslist is intentional and correct.
No issues found. Clean, targeted removal with consistent test updates.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 56.4 AIC · ⌖ 6.52 AIC · ⊞ 4.9K
|
@copilot run pr-finisher skill |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs — one blocking issue: a test file was not updated alongside the others.
📋 Key Themes & Highlights
Blocking Issue
logs_json_stderr_order_test.gonot updated: This file still has 4 assertions checking fortotal_tokens(lines 106–107, 230–231, 236–237). Since the field was removed fromLogsSummary, these will fail. It was not included in the PR's list of changed files.
Positive Highlights
- ✅ Root cause is correctly identified and fixed —
TotalTokenswas never meaningful without--artifacts agent; removing it is the right call. - ✅ Per-run
token_usageonRunData(line 109) is intentionally preserved — it remains useful when the agent artifact is downloaded. - ✅ TSV format doc comment updated to match the new output format.
- ✅ Comprehensive sweep across 7 test files — only one was missed.
- ✅ Using
omitemptyontotal_aicmeans it stays absent from JSON when zero, keeping the fix consistent.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 123.8 AIC · ⌖ 9.47 AIC · ⊞ 6.6K
Comment /matt to run again
|
@copilot please run the
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in ddd6ce3. I updated the leftover logs summary assertions and the compiler action-pin selection that let a stale cached |
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed on this branch in e70416f. I kept |
|
🎉 This pull request is included in a new release. Release: |
logssummary always reportedtotal_tokens: 0because token counts require the agent artifact (not downloaded by default), while only AIC cost is available from the usage artifact. This created a confusingtotal_tokens: 0/total_aic: 445.247inconsistency.Changes
LogsSummary: RemoveTotalTokensfield entirely — always zero without--artifacts agent, never meaningful in the summary contextbuildLogsData: DroptotalTokensaccumulation variabletokens=from summary output lines in both formatsTotalTokens/total_tokensassertions fromLogsSummaryacross 7 test files; replace field-existence checks that were assertingtotal_tokensis present with equivalent checks on fields that are actually populated