Skip to content

test: add pure-active session output-token double-count coverage (#1155)#1159

Open
microsasa wants to merge 1 commit intomainfrom
fix/1155-pure-active-output-token-test-061e23ace9fc5832
Open

test: add pure-active session output-token double-count coverage (#1155)#1159
microsasa wants to merge 1 commit intomainfrom
fix/1155-pure-active-output-token-test-061e23ace9fc5832

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #1155

Summary

Adds two tests covering the missing pure-active session output-token verification in _render_aggregate_stats and render_session_detail.

Tests added

  1. TestRenderAggregateStatsDirect.test_pure_active_session_output_tokens_not_double_counted (test_report.py)

    • Direct unit test for _render_aggregate_stats with a pure-active session (is_active=True, has_shutdown_metrics=False)
    • Asserts output shows 800 tokens (from model_metrics), not 1600 (double-count)
  2. TestRenderSessionDetailActivePeriod.test_pure_active_session_aggregate_stats_token_count (test_render_detail.py)

    • Integration test calling render_session_detail end-to-end
    • Asserts Aggregate Stats panel shows 500 tokens, not 1000

Regression scenario covered

If total_output_tokens is refactored to unconditionally add active_output_tokens to the baseline, these tests will fail — catching the double-count before it reaches users.

Warning

⚠️ Firewall blocked 3 domains

The following domains were blocked by the firewall during workflow execution:

  • astral.sh
  • index.crates.io
  • pypi.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"
    - "index.crates.io"
    - "pypi.org"

See Network Configuration for more information.

Generated by Issue Implementer · ● 9.8M ·

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>
Copilot AI review requested due to automatic review settings May 2, 2026 09:59
@microsasa microsasa added the aw Created by agentic workflow label May 2, 2026
@microsasa microsasa enabled auto-merge May 2, 2026 09:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_stats covering a pure-active session with mirrored model_metrics / active_output_tokens.
  • Adds an end-to-end render_session_detail test 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow

Projects

None yet

2 participants