Skip to content

fix: remove dead code in _build_active_summary (#1202)#1203

Open
microsasa wants to merge 1 commit intomainfrom
fix/1202-remove-dead-code-active-summary-469c2b1ef3a002f6
Open

fix: remove dead code in _build_active_summary (#1202)#1203
microsasa wants to merge 1 commit intomainfrom
fix/1202-remove-dead-code-active-summary-469c2b1ef3a002f6

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #1202

Summary

Removes two instances of dead/misleading code in parser.py where fp.model is referenced in the active-session path, but is invariably None (since it's only set during SESSION_SHUTDOWN processing).

Changes

1. _build_active_summary (line 979)

# Before
model = fp.model or fp.tool_model

# After
model = fp.tool_model

2. _build_session_summary_with_meta (line 1058)

# Before
used_config = fp.model is None and fp.tool_model is None

# After
used_config = fp.tool_model is None

Testing

Added test_active_summary_uses_tool_model_directly_without_fp_model which:

  • Builds a session with TOOL_EXECUTION_COMPLETE (setting fp.tool_model) but no SESSION_SHUTDOWN
  • Asserts that fp.model is None and fp.all_shutdowns == ()
  • Confirms that SessionSummary.model matches the tool model directly

Warning

⚠️ Firewall blocked 3 domains

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

  • astral.sh
  • pypi.org
  • releaseassets.githubusercontent.com

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

network:
  allowed:
    - defaults
    - "astral.sh"
    - "pypi.org"
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by Issue Implementer · ● 12.3M ·

Remove two instances of dead/misleading code in parser.py:

1. _build_active_summary line 979: simplified
   'model = fp.model or fp.tool_model' to 'model = fp.tool_model'
   since fp.model is invariably None in the active-session path.

2. _build_session_summary_with_meta line 1058: simplified
   'used_config = fp.model is None and fp.tool_model is None' to
   'used_config = fp.tool_model is None' since fp.model is always
   None when no shutdowns exist.

Added a unit test that explicitly documents the invariant: fp.model
is None when no SESSION_SHUTDOWN events exist, and the summary model
is resolved from fp.tool_model directly.

Closes #1202

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 6, 2026 21:18
@microsasa microsasa added the aw Created by agentic workflow label May 6, 2026
@microsasa microsasa enabled auto-merge May 6, 2026 21:18
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 removes two pieces of dead/misleading model-resolution logic in the session parser by relying on the correct invariant: for sessions without shutdown events, _first_pass.model is never populated, so the active-session path should use tool_model (and then config fallback) exclusively.

Changes:

  • Simplified _build_active_summary to use fp.tool_model directly (instead of fp.model or fp.tool_model).
  • Simplified _build_session_summary_with_meta’s used_config_fallback calculation to depend only on whether fp.tool_model is present.
  • Added a unit test asserting the invariant (fp.model is None when no shutdown exists) and verifying the resulting SessionSummary.model matches the tool model.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/copilot_usage/parser.py Removes dead references to fp.model in the no-shutdown (active session) summary path.
tests/copilot_usage/test_parser.py Adds regression coverage ensuring active sessions resolve the model from tool_model without relying on fp.model.

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

Development

Successfully merging this pull request may close these issues.

[aw][code health] _build_active_summary contains dead code: fp.model is always None in the active-session path

2 participants