Qodo Blog Author Ravid Cohen: When Agent Outputs Are Unstable, Run Twice Before Optimizing Prompts
Qodo blog author Ravid Cohen describes their method for adapting the GEPA algorithm to optimize system prompts for a code review recommendation agent. The core approach involves running the agent twice on each training sample and comparing full execution traces to identify unstable points in evidence gathering and decision-making; all structured analyses are then aggregated into a single high-reasoning LLM call to find cross-sample patterns. Starting from a minimal 43-word prompt, they performed a single wide-step optimization, which outperformed multiple rounds of minor tweaks to an already manually optimized production prompt. In a production A/B test at Qodo, the miss rate dropped from 7.83% to 4.46%, cost per instance was halved, and latency decreased by 25%.
Noise in AI code review is often attributed to false positives—the model flagging issues that shouldn't be reported. However, Qodo blog author Ravid Cohen points to another type of noise: when the same agent runs twice on the same pull request (PR), it may assign different judgment labels. Their recommendation agent predicts whether a team is likely to adopt a specific review finding, but on an evaluation set of 200 PRs, 20.7% of labels soft-flipped between 'yes' and 'maybe' or 'maybe' and 'no', while 4.3% hard-flipped directly between 'yes' and 'no'. This inconsistency indicates instability in the agent's evidence gathering or decision logic, rather than merely a need to tighten judgment criteria.
Standard GEPA (an algorithm that iteratively improves prompts by analyzing agent outputs and evaluation feedback) faces a structural difficulty with such noisy agents: the agent's full execution trace is long, and the reflector can only inspect a limited number of samples at once. If lessons are extracted using only small batches, a single accidental unstable output might be misread as a general pattern. Therefore, the Cohen team adapted GEPA by adding two steps: first, run the agent twice for each training sample, allowing an LLM to compare the two full traces and output a structured analysis detailing where different evidence was collected, where different decisions were made, and what might explain these differences; second, aggregate all structured analyses across the entire training set into a single high-reasoning-effort LLM call, enabling it to find patterns across samples without processing every full trace individually.