Skip to content

fix: use correct subagent flag in checkpoint guard#1665

Merged
KRRT7 merged 4 commits intomainfrom
fix/checkpoint-subagent-flag
Feb 25, 2026
Merged

fix: use correct subagent flag in checkpoint guard#1665
KRRT7 merged 4 commits intomainfrom
fix/checkpoint-subagent-flag

Conversation

@aseembits93
Copy link
Contributor

Summary

  • The checkpoint guard in optimizer.py referenced args.agent, which is never defined on the CLI args namespace — the actual flag is --subagent (args.subagent).
  • Since getattr(self.args, "agent", False) always returned False, the condition was effectively just self.args.all, meaning checkpointing was never skipped in subagent mode as intended.

Test plan

  • Verify --all --subagent skips checkpoint creation
  • Verify --all without --subagent still creates checkpoint

🤖 Generated with Claude Code

aseembits93 and others added 3 commits February 25, 2026 22:02
The checkpoint guard referenced `args.agent` which is never set — the
actual CLI flag is `--subagent`. The old check always evaluated to False,
making the condition equivalent to just `self.args.all`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aseembits93 aseembits93 requested a review from KRRT7 February 25, 2026 17:01
@claude
Copy link
Contributor

claude bot commented Feb 25, 2026

PR Review Summary

Prek Checks

✅ All checks pass — ruff check and ruff format both passed with no issues.

Mypy

⚠️ 22 pre-existing mypy errors in optimizer.py — none introduced by this PR. All errors exist on main as well (type variance issues, unreachable code, Path | None mismatches, etc.).

Code Review

No issues found. This is a clean, correct 1-line fix:

  • Before: getattr(self.args, "agent", False)agent attribute never exists on args, so getattr always returns False, making the checkpoint guard effectively just self.args.all
  • After: self.args.subagent — correctly references the --subagent CLI flag defined at cli_cmds/cli.py:134
  • Consistent with existing usage in checkpoint.py:144 which already uses getattr(args, "subagent", False)
  • The fix ensures checkpointing is properly skipped when running in subagent mode with --all --subagent

Test Coverage

File Stmts Miss Cover
codeflash/optimization/optimizer.py 451 365 19%
  • The changed line (607) is not covered by unit tests — it falls within the run() method (lines 528-715) which is integration-level orchestration code
  • This is pre-existing — the same line was uncovered on main (just with the old getattr call)
  • No coverage regression — this is a 1-line attribute name fix that doesn't change the coverage profile
  • 8 test failures observed in tests/test_tracer.py — these are pre-existing and unrelated to this PR (tracer API changes)

Overall Assessment

LGTM — Straightforward bug fix. The old code silently failed (always returned False), this correctly references the actual CLI flag.


Last updated: 2026-02-25

Copy link
Collaborator

@KRRT7 KRRT7 left a comment

Choose a reason for hiding this comment

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

@aseembits93 you're bumping the benchmark package, not codeflash here

@aseembits93
Copy link
Contributor Author

@KRRT7 fixed

@KRRT7
Copy link
Collaborator

KRRT7 commented Feb 25, 2026

@aseembits93 big jump?

@aseembits93
Copy link
Contributor Author

@aseembits93 big jump?

i only see a single line of change, i think it was out of sync with main before?

@KRRT7
Copy link
Collaborator

KRRT7 commented Feb 25, 2026

oops, I misread the update

@KRRT7 KRRT7 merged commit d284be5 into main Feb 25, 2026
24 of 28 checks passed
@KRRT7 KRRT7 deleted the fix/checkpoint-subagent-flag branch February 25, 2026 18:58
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.

2 participants