Skip to content

feat: add --rerun flag to rerun optimization from stored trace - #1919

Merged
Saga4 merged 1 commit into
mainfrom
cf-feat-rerun-trace
Mar 29, 2026
Merged

feat: add --rerun flag to rerun optimization from stored trace#1919
Saga4 merged 1 commit into
mainfrom
cf-feat-rerun-trace

Conversation

@mohammedahmed18

Copy link
Copy Markdown
Contributor

Summary

  • Adds --rerun <trace_id> CLI flag that passes rerun_trace_id through all AI service client methods (optimize_code, optimize_python_code_line_profiler, generate_regression_tests, optimize_code_refinement, code_repair)
  • Companion to codeflash-ai/codeflash-internal#TBD which adds server-side handling

Test plan

  • Run codeflash --rerun <existing_trace_id> --file <path> --function <name> --server local against local aiservice with the companion PR deployed
  • Verify AI service returns stored results instantly (no LLM latency)
  • Verify full optimization pipeline still completes (discovery, test execution, benchmarking)

🤖 Generated with Claude Code

Adds --rerun <trace_id> CLI flag that passes rerun_trace_id through all
AI service client methods, allowing endpoints to return stored LLM results
instead of making new calls.

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

claude Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Claude finished @mohammedahmed18's task in 3m 12s —— View job


PR Review Summary

  • Triage PR size → SMALL (31 additions, 3 deletions across 4 files)
  • Run lint/typecheck (prek + mypy)
  • Resolve stale review threads → none found
  • Code review
  • Duplicate detection
  • Check codeflash-ai[bot] optimization PRs

Prek Checks

prek passed — no lint/format issues.

mypy reports 148 pre-existing errors in function_optimizer.py and one other file; none are introduced by this PR.


Code Review

Classification: SMALL — clean parameter threading, no complex logic.

Findings: No bugs, no security issues, no breaking API changes.

Observations:

  1. Consistent threadingrerun_trace_id is correctly passed through all five AI service call sites:

    • optimize_codegenerate_optimizations (function_optimizer.py:1867)
    • optimize_python_code_line_profilerdetermine_best_candidate (function_optimizer.py:1361)
    • generate_regression_testsverifier.py:74
    • optimize_code_refinementprocess_single_candidate (function_optimizer.py:1295)
    • code_repairrepair_optimization (function_optimizer.py:1491)
  2. Property design (function_optimizer.py:880) — using getattr(self.args, "rerun", None) if self.args else None safely handles both the args=None and attribute-missing cases. Clean approach.

  3. No tests — acceptable here since correctness depends on a companion server-side PR (codeflash-internal) and there's no mock surface to test against locally. The test plan correctly calls for integration testing against local aiservice.

Duplicate Detection

No duplicates detected. The rerun_trace_id parameter is a new cross-cutting concern applied consistently.

Test Coverage

Skipped (SMALL PR).


codeflash-ai[bot] Optimization PRs

PRs #1895, #1891, and #1890 all have CI failures (unit-tests, JS optimization tests, tracer-replay, java-tracer-e2e). The same checks fail identically across all three PRs targeting different base commits, indicating pre-existing failures on main. Left comments on each; keeping open until base branch CI is fixed.


Last updated: 2026-03-27T16:20Z

@Saga4
Saga4 merged commit 14dafe0 into main Mar 29, 2026
27 of 29 checks passed
@Saga4
Saga4 deleted the cf-feat-rerun-trace branch March 29, 2026 12:39
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