Conversation
Add --agent CLI flag for AI agent integrations that skips all interactive prompts. In agent mode, checkpoint resume is skipped entirely so each run starts fresh. Also gates the existing checkpoint prompt behind --yes.
In agent mode, disable all Rich output (panels, spinners, progress bars, syntax highlighting) and use a plain StreamHandler for logging. Optimization results with explanation and unified diff are written to stdout. A log filter strips LSP prefixes and drops noisy test/file-path messages. Also skip checkpoint creation and suppress Python warnings in agent mode.
…oncolic tests - --agent now implies --no-pr and --worktree so source files stay clean - Output uses structured XML (codeflash-optimization) with optimized-code for the consuming agent to apply via Edit/Write - Skip concolic test generation in agent mode - Skip patch file creation in worktree + agent mode
|
why dont you use the word --subagent? agent mode within codeflash means something else |
codeflash/cli_cmds/console.py
Outdated
| ) | ||
|
|
||
| if is_agent_mode(): | ||
| return |
There was a problem hiding this comment.
Nit: The is_agent_mode() early return is placed after all the computation (building the summary string, counting callees, etc.). Consider moving this check to the top of the function, alongside the if not total_functions: return guard, to avoid wasted work in agent mode.
| return | |
| if is_agent_mode(): | |
| return | |
| if is_LSP_enabled(): |
| if is_agent_mode(): | ||
| agent_log_optimization_result( | ||
| function_name=new_explanation.function_name, | ||
| file_path=new_explanation.file_path, | ||
| perf_improvement_line=new_explanation.perf_improvement_line, | ||
| original_runtime_ns=new_explanation.original_runtime_ns, | ||
| best_runtime_ns=new_explanation.best_runtime_ns, | ||
| raw_explanation=new_explanation.raw_explanation_message, | ||
| original_code=original_code_combined, | ||
| new_code=new_code_combined, | ||
| review=opt_review_result.review, | ||
| ) |
There was a problem hiding this comment.
Note: When is_agent_mode() is true, the function writes the XML result to stdout and then falls through to the raise_pr / staging_review logic below. Since --agent implies --no-pr, the PR logic is skipped in practice. But if a future change decouples --agent from --no-pr, this could lead to both an XML output and a PR being created. Consider adding an explicit return or a comment documenting this dependency.
⚡️ Codeflash found optimizations for this PR📄 71% (0.71x) speedup for
|
PR Review SummaryPrek Checks✅ Passed after auto-fix. One formatting issue in Mypy: 189 errors found across changed files, but all are pre-existing (primarily Code ReviewNo critical bugs or security issues found. Two minor observations left as inline comments:
Overall: The implementation is well-structured. The pattern of setting Test Coverage
Analysis: No new files were added — all changes modify existing files. The new agent-mode code paths (console suppression, XML output, concolic test skip) are not covered by unit tests, which matches the existing pattern for LSP-mode paths in the same files. The overall suite coverage (78.4%) is unaffected. Test failures (8 in Last updated: 2026-02-20 |
Rename the CLI flag, env var (CODEFLASH_SUBAGENT_MODE), helper (is_subagent_mode), and related symbols to avoid confusion with CodeFlash's own agent terminology.
Avoids computing the full summary (callee counts, string formatting) only to discard it when running in subagent mode.
Include a <verification> block with per-test-type pass/fail counts in the XML emitted by subagent_log_optimization_result, matching the correctness table shown in GitHub PR comments.
Summary
--agentCLI flag for Claude / agents: suppresses Rich UI, emits plain-text/XML output, skips checkpoint and concolic tests, implies--no-prand--worktree.