fix: resolve LLM returning wrong file paths in multi-file optimization#1772
fix: resolve LLM returning wrong file paths in multi-file optimization#1772
Conversation
…ename fallback The LLM sometimes returns code blocks tagged with context file paths instead of the target file. Two fixes: - Reorder code_strings to put the target file first in the markdown - Add basename fallback in get_optimized_code_for_module when exact path lookup fails
|
Claude finished @KRRT7's task in 4m 12s —— View job PR Review SummaryTasks
Prek ChecksAll checks passed — no linting or formatting issues. mypy: no issues found in changed source files. Code ReviewOverall: The approach is sound — putting the target file first in the read-writable context is a clean preventive fix, and the basename fallback in Minor observations:
Duplicate DetectionNo duplicates detected. Test CoverageAll 11 new unit tests pass. Coverage for the changed function path:
The 17 test failures in Optimization PRsNo open optimization PRs from |
Co-authored-by: Kevin Turcios <undefined@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
⚡️ Codeflash found optimizations for this PR📄 33% (0.33x) speedup for
|
Summary
get_optimized_code_for_modulewhen exact path lookup failsFixes a warning seen in CI where the LLM returns code blocks tagged with context file paths (e.g.
console.py,aiservice.py) instead of the target file (version.py).Companion backend PR: codeflash-ai/codeflash-internal#2469
Test plan
get_optimized_code_for_module— exact match, None fallback, basename fallback, ambiguous, empty, CI reproduction