Paper commentary
Escaping Whack-a-Mole: Optimizing Documentation as Repo-Specific Playbooks for Coding Agents
DOCSEARCH orders documentation refinement across dependent entities to avoid regressions
- Problem Refining one entity's documentation can break the code of its callers. Repeated self-refinement therefore moves failures between entities instead of converging.
- Method DOCSEARCH orders entities callee-first and rejects any refinement that lowers another entity's pass rate. It generates several candidates from different error batches and keeps the first that causes no regressions.
- Results DOCSEARCH reached a 95.2% solve rate with Claude-4.5-Sonnet on the DEVEVAL+ benchmark, above the baselines.
Why iterative refinement oscillates
Agent-oriented documentation is judged by the code a coding agent writes from it, since that code is the only reliable signal. The authors define an entity's documentation quality as the fraction of its tests that the generated code passes, so the entity is solved when \(\phi_i(D)=1\).
The obstacle is output coupling, which makes an entity's code depend on what its callees actually contain, not only on their documentation. Changing a callee's documentation can yield a different but correct implementation, and that implementation can break a caller whose own documentation never changed. Repeated edits then move failures from one entity to another, which the authors call the whack-a-mole phenomenon.
Plain self-refinement makes this worse because it picks entities at random or by error count and ignores the call graph. The authors call the resulting damage refinement interference, meaning a refinement lowers the pass rate of another entity. Their Theorem 1 says that for every n of at least 2 there is an instance where self-refinement reaches \(|S|/|S^*| = O(1/n)\).
The authors prove this with an adversarial star-graph instance in their appendix, so it is a worst-case existence result.
The test cases are generated by an LLM, so the error messages they produce vary in quality. Some errors are informative, some carry no signal, and some point the refinement in the wrong direction. Conditioning every candidate on the same full error set tends to yield similar hypotheses that fail together.
How DOCSEARCH chooses and refines entities
DOCSEARCH begins by having an LLM write complete test functions, and it keeps only those that pass on the reference implementation. Each round then runs a loop from documentation to generated code to test failures and back to refined documentation.
The outer level is a priority search over the dependency DAG, and it decides which entity to refine next. An entity becomes eligible only after all its callees are finalized, meaning solved or marked intractable. Among eligible siblings, the one with fewer failing tests goes first, because the authors read fewer errors as a simpler knowledge gap.
Since callees are already stable, a refinement can't propagate down the call chain, so interference stays among siblings that share callees.
For the chosen entity, the inner level generates W candidates in parallel and commits the first one that meets the worthy condition. Each candidate is conditioned on a different error batch, which is how the inner level tries to escape local optima. Diversified sampling builds W distinct batches by subset selection and draws one refinement from each batch.
Uniform sampling instead conditions all W draws on the full failing set. Each candidate goes through a diagnosis step that finds root causes, followed by a prescription step that writes targeted edits.
A child node is worthy when no entity's pass rate falls below its parent's, written as \(\phi_e(D_v)\ge\phi_e(D_u)\) for all e. Along a worthy path the solved sets only grow, so once an entity is solved it stays solved. This check stops a repair in one place from undoing progress elsewhere.
For cycles, each strongly connected component is contracted into a meta-entity and refined jointly. For imprecise call graphs, a regression on a solved entity reveals a missing edge, which is added and the topological order is updated.
What the two theorems promise
Theorem 1 concerns the self-refinement baseline, not DOCSEARCH itself. It is an existence claim, so it shows the worst case can be poor but says nothing about typical runs on the benchmark.
Theorem 2 starts from \(q(e)\), the probability of a successful refinement conditioned on the error batch \(e\). Under Assumptions 1 to 5, which appear in the appendix, \(q(e^-) \ll q(e^+)\) for informative batches \(e^+\subseteq F^+\) and noisy batches \(e^-\subseteq F^-\). Mixing noisy errors into informative ones lowers success, so \(q(e^+\cup e^-)<q(e^+)\) when \(|e^-|>0\).
With W draws from one full set, uniform sampling succeeds at least once with probability \(1-(1-q(F))^W\). Diversified sampling spreads the draws over batches, so it can reach an informative-dominated batch without knowing the split \(F^+/F^-\). This is an argument about probabilities under the stated assumptions, not a measured effect.
Benchmark and evaluation protocol
Modules come from DevEval and extra GitHub repositories, chosen across domains such as finance, biological analysis and signal processing.
Average dependency depth is 4.2, and maximum depth is 9. The search runs on LLM-generated tests, while the ground-truth tests stay hidden from the search and are used only for the reported results.
Solve Rate is the fraction of entities with \(\phi_i=1\), and Pass Rate is \(\bar{\phi}=\frac{1}{n}\sum_i \phi_i\).
The baselines are static documentation generators, commercial coding agents and iterative refinement. Iterative refinement picks the next entity at random or in reverse topological order. Commercial agents were run under four configurations: base, +Topo, +Test and +Topo+Test.
Solve rates against the baselines
RepoAgent and DocAgent reached solve rates between 15.9% and 37.0% across the three base LLMs. The authors attribute this to documentation written for human readers, which LLMs read literally and resolve ambiguities unpredictably.
With Claude-4.5-Sonnet and +Topo+Test, Cursor reached 55.1% and Claude Code reached 64.8%. Neither commercial tool has GPT-4o results, since Cursor's listed models exclude it and Claude Code covers only Claude models. The authors argue these tools lack a worthy condition and a tree search, so they can't backtrack from early poor refinements.
Does the oscillation disappear?
Figure 1 sketches the pattern: iterative refinement oscillates around a 55% solve rate, while DOCSEARCH moves monotonically past 90%. The figure is a schematic, and the paper gives its numbers only in the caption.
Iterative+Topo fluctuates between 52% and 62%, and Iterative without ordering fluctuates between 43% and 58%. DOCSEARCH rises monotonically and converges above 90% pass rate. The authors attribute the oscillation to output coupling rather than random noise.
Table 2 removes one component at a time on a 10-module subset with GPT-4o. Each removal lowers solve rate, so each component helps in this setting, but the table doesn't show that any single component is sufficient.
The authors connect the largest drop to reverse order confining interference to siblings rather than the whole call chain. They explain the smaller worthy-condition drop by sibling conflicts, which the worthy condition resolves.
Exploration and token cost
DOCSEARCH reached 88% to 97% pass rate while exploring 15 to 25 variants per module. Iterative+Topo explored 1.5 to 2 times more variants and plateaued around 70% to 75%. Iterative without ordering needed 40 to 50 explorations for a 59% to 70% pass rate.
The authors give two sources for this: error-driven refinement targets a diagnosed deficiency, and reverse order avoids work that later downstream changes would undo.
Figure 5 plots cross-module average pass rate against cumulative output tokens for GPT-4o. At about 20k tokens DOCSEARCH reached 68.3%, above the 56.6% that Iterative reached at 200k tokens. The authors describe this as a 10 times efficiency gap. Because the search runs once offline, the optimized documentation is reused across later tasks without repeating it.
Transfer to Java and Go
The authors take documentation optimized for Python and ask whether GPT-4o can use it to generate Java or Go. Test harnesses were rewritten by hand in the target language while keeping the original input-output pairs. Java was tested on 10 modules and Go on 5.
Doc+Source reached 79.3% on Java and 72.1% on Go, the highest of the three configurations.
The authors explain the gap by representation: source code shows how to compute with Python idioms, while documentation says what the function computes. The authors take the same ordering on two different paradigms as evidence that the optimized documentation isn't tied to one target.
Human ratings of documentation
The authors took 30 entities from 6 modules where the documentation changed substantively, using GPT-4o with B=50. Five annotators with computer-science backgrounds rated each pair blind to version, on five 1-to-5 Likert dimensions.
Krippendorff's ordinal α was 0.71 or higher on every dimension. The authors read the agreement as evidence that the gains aren't artifacts of annotator subjectivity. The rating measures documentation quality on 30 entities, not readability across the whole benchmark.
Limitations
The evaluation uses one benchmark, DEVEVAL+ with 20 Python modules, and three base LLMs. Cursor and Claude Code have results only for Claude or Gemini models.
Cross-language transfer covers only Java and Go, on 10 and 5 modules. The human study covers 30 entities from 6 modules.
The search depends on LLM-generated tests, and the authors treat their informativeness as variable.
Paper info
- Authors
- Yutong Cheng, Haifeng Chen, Wenchao Yu, Xujiang Zhao, Peng Gao, Wei Cheng
- Venue
- International Conference on Machine Learning · Published
- First published
- 2026-9-29
- Added
- 2026-11-26
- Original paper terms
- Check in the original ↗
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Yutong Cheng, Haifeng Chen, Wenchao Yu, Xujiang Zhao, Peng Gao, Wei Cheng (2026). Escaping Whack-a-Mole: Optimizing Documentation as Repo-Specific Playbooks for Coding Agents. International Conference on Machine Learning. https://proceedings.mlr.press/v306/cheng26c.html
BibTeX
@article{cheng2026escaping,
title = {{Escaping Whack-a-Mole: Optimizing Documentation as Repo-Specific Playbooks for Coding Agents}},
author = {Yutong Cheng and Haifeng Chen and Wenchao Yu and Xujiang Zhao and Peng Gao and Wei Cheng},
year = {2026},
journal = {International Conference on Machine Learning},
url = {https://proceedings.mlr.press/v306/cheng26c.html}
}