Contrastive Reflection for Iterative Prompt Optimization

Derek Koh, Jinghui Mo, Benjamin H. Le, Jiening Zhan, Baofen Zheng +5 more
6/29/2026
cs.AI

No confident code implementation found for this paper.

Abstract

LLM agents are becoming central to information retrieval: they issue retrieval queries, synthesize answers, and increasingly serve as judges for IR evaluation. Improving the prompts that control these agents is an optimization problem, but in applied IR settings it often looks less like blind search and more like debugging. Engineers need to know which behavior failed, which nearby behavior still worked, what distinguishes the two, and whether a prompt edit improves held-out quality without introducing regressions. We present Contrastive Reflection, an iterative prompt-optimization framework for agentic IR workflows. The framework starts from a task-centric quality definition: QA agents expose retrieval or reasoning traces, and grading agents expose dimension-level scores and rationales. These structured traces are used to identify error-anchored behavioral slices, add nearby successful examples from the same region, and ask a Teacher LLM to propose a targeted prompt edit. Candidate edits are accepted only when validation performance improves, optionally subject to regression checks. We instantiate the framework with a tree-based slice selector, but the contribution is the contrastive reflection loop rather than the tree itself. On a public HotpotQA retrieval-augmented QA setup, one tree-selected contrastive repair improves held-out exact-match accuracy from 51.4% to 60.4%. Failure-only and random-evidence variants improve less and break more previously correct examples. A light instruction-only comparison places the method near modern prompt optimizers: MIPROv2 reaches 59.4% and GEPA 57.0%. The result is an interpretable optimization loop for IR agents, aimed at making prompt repair more inspectable and validation-driven.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{koh2026contrastive,
  title  = {Contrastive Reflection for Iterative Prompt Optimization},
  author = {Derek Koh and Jinghui Mo and Benjamin H. Le and Jiening Zhan and Baofen Zheng and Kevin Bevis and Nathaniel C. Owen and Lauren Elizabeth Charney and Wenqiong Liu and Jingwei Wu},
  year   = {2026},
  eprint = {2606.30840},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2606.30840v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2606.30840.svg)](https://codeofpaper.com/paper/2606.30840)

Discussion