Skip to content

feat: set low effort and skip review/explanation in subagent mode#1685

Draft
aseembits93 wants to merge 9 commits intomainfrom
feat/subagent-low-effort-defaults
Draft

feat: set low effort and skip review/explanation in subagent mode#1685
aseembits93 wants to merge 9 commits intomainfrom
feat/subagent-low-effort-defaults

Conversation

@aseembits93
Copy link
Contributor

Summary

  • Defaults --effort to low when --subagent flag is used
  • Skips the explanation refinement API call (get_new_explanation) in subagent mode, falling back to the original candidate explanation
  • Skips the optimization review API call (get_optimization_review) in subagent mode

Test plan

  • Run with --subagent flag and verify effort is low
  • Confirm explanation refinement and review API calls are not made in subagent mode
  • Verify normal (non-subagent) mode is unaffected

🤖 Generated with Claude Code

Reduces latency for AI agent integrations by defaulting effort to low
and skipping the explanation refinement and optimization review API calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link
Contributor

claude bot commented Feb 27, 2026

Claude finished @aseembits93's task in 6m 10s —— View job


PR Review Summary

Prek Checks

Prek passed (ruff check + ruff format). Mypy has 160 pre-existing errors in console.py and function_optimizer.py — none introduced by this PR.

Code Review

The PR cleanly implements subagent mode optimizations. No bugs, security issues, or breaking API changes found.

Minor observations (non-blocking):

  1. args.effort = "low" overrides explicit user flags (cli.py:145): If a user passes --effort high --subagent, effort is silently overridden to "low". This is likely intentional for the subagent use case but worth noting. Could also use EffortLevel.LOW.value instead of the raw string for consistency with the existing enum.

  2. Duplicated subagent conditionals (function_optimizer.py): The TOTAL_LOOPING_TIME_EFFECTIVE / 2 if is_subagent_mode() pattern appears in both run_original_and_benchmarking (~line 2295) and run_candidate_and_benchmarking (~line 2511). Same for pytest_min_loops=3 if subagent else 5, pytest_max_loops=100 if subagent else 250 (lines ~2357 and ~2561). These two methods are parallel by design, so the duplication is understandable, but could be extracted to constants in config_consts.py if more subagent tunables are added later.

  3. Early return safety (function_optimizer.py:2022-2039): The early return correctly calls mark_optimization_success() before returning, and the skipped downstream code (PR creation, code revert) is appropriately unnecessary in subagent mode. Clean implementation.

  4. Ranking fallback (function_optimizer.py:1006-1025): When generate_ranking is skipped in subagent mode, ranking stays None and the else branch uses the lightweight local ranking (diff length + runtime). This is efficient — cheap local computation replaces an API call.

Duplicate Detection

No duplicates detected. The subagent_log_optimization_result call was moved from after the API calls to before them (as an early return), eliminating the previous call site cleanly.

Test Coverage

Coverage for changed files (pre-existing levels, not regressions from this PR):

File Stmts Miss Cover
codeflash/cli_cmds/cli.py 263 183 30%
codeflash/cli_cmds/console.py 271 220 19%
codeflash/optimization/function_optimizer.py 1078 877 19%

These are orchestration-heavy files with low unit test coverage — consistent with the existing codebase. No new regressions. One unrelated test failure: tests/test_tracer.py::TestTracer::test_tracer_initialization_normal.

Optimization PRs

Found 30 open codeflash-ai[bot] PRs. 3 have merge conflicts (#1656, #1646, #1645) and 2 are older than 7 days (#1610, #1606) — these should be closed as stale. Unable to close them due to tool permission restrictions. Most remaining PRs have CI failures on their target branches.


Last updated: 2026-03-02T23:45Z

aseembits93 and others added 8 commits February 27, 2026 17:31
Since review and explanation API calls are skipped in subagent mode,
update the action instructions to have the agent assess the optimization
itself before presenting it to the user.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Early-return from process_review using the original explanation object
directly, skipping all the unnecessary work: test formatting, coverage
message building, explanation refinement, review API call, and
new_explanation construction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Falls back to the local diff-length + runtime heuristic instead of
calling generate_ranking, reducing latency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant