test: add pure-active session output-token double-count coverage (#1155)#1159
Open
test: add pure-active session output-token double-count coverage (#1155)#1159
Conversation
Add two tests verifying that _render_aggregate_stats and render_session_detail display the correct (non-doubled) output token count for pure-active sessions (is_active=True, has_shutdown_metrics=False). - TestRenderAggregateStatsDirect: direct unit test asserting 800 tokens shown, not 1600 - TestRenderSessionDetailActivePeriod: integration test asserting 500 tokens shown, not 1000 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds regression tests around output-token accounting for pure-active sessions so the reporting/rendering layer continues to avoid double-counting active tokens in session summaries.
Changes:
- Adds a direct test for
_render_aggregate_statscovering a pure-active session with mirroredmodel_metrics/active_output_tokens. - Adds an end-to-end
render_session_detailtest intended to verify the Aggregate Stats panel for a pure-active session. - Extends existing test coverage in the reporting/render-detail test suites without changing production code.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/copilot_usage/test_report.py |
Adds a direct regression test for aggregate token rendering in a pure-active session. |
tests/copilot_usage/test_render_detail.py |
Adds an integration-style session detail test for pure-active token totals. |
Comment on lines
+880
to
+882
| assert "Aggregate Stats" in output | ||
| assert "500" in output | ||
| assert "1000" not in output # double-count must not appear |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1155
Summary
Adds two tests covering the missing pure-active session output-token verification in
_render_aggregate_statsandrender_session_detail.Tests added
TestRenderAggregateStatsDirect.test_pure_active_session_output_tokens_not_double_counted(test_report.py)_render_aggregate_statswith a pure-active session (is_active=True,has_shutdown_metrics=False)800tokens (frommodel_metrics), not1600(double-count)TestRenderSessionDetailActivePeriod.test_pure_active_session_aggregate_stats_token_count(test_render_detail.py)render_session_detailend-to-end500tokens, not1000Regression scenario covered
If
total_output_tokensis refactored to unconditionally addactive_output_tokensto the baseline, these tests will fail — catching the double-count before it reaches users.Warning
The following domains were blocked by the firewall during workflow execution:
astral.shindex.crates.iopypi.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.