acceptodds
Under review as a conference paper at ICLR 2027

CoSPlay: Cooperative Self-Play at Test-Time with Self-Generated Code and Unit Test

Abstract

Reinforcement Learning with Verifiable Rewards (RLVR) and Test-Time Scaling (TTS) have advanced LLM code generation through executable verification, yet both hinge on Ground-Truth Unit Tests (GT UTs), which are expensive to annotate at scale. GT-free methods instead rely on self-generated UTs to verify and refine codes, but these UTs are often noisy, and so are the codes they check. Treating either side as ground truth to improve the other thus only propagates its errors. The key challenge is therefore: with no external reference, how can each side extract usable signals from the other, turning error propagation into mutual error reduction? We present CoSPlay, a GT-free framework that co-evolves codes and UTs through cooperative self-play at inference time. Although neither side is reliable alone, we show theoretically and empirically that pass counts on the Code-UT execution matrix correlate positively with correctness and can thus, to some extent, tell trustworthy codes and UTs from unreliable ones. Building on this signal, CoSPlay first derives discriminative UT ideas from the failure modes of diverse solution ideas. It then alternately updates the two pools, keeping the codes and UTs with higher support counts and using them to fix or regenerate the rest. Finally, such a signal indicates the model does not lean toward any particular wrong behaviors in expectation, so the correct behavior dominates the top codes, whose ties CoSPlay breaks by unsupervised clustering of output signatures on a few random inputs. On four challenging benchmarks, CoSPlay improves the average Best-of-N (BoN) accuracy of Qwen2.5-7B-Instruct from 22.1% to 33.2% and its UT accuracy from 14.6% to 78.3%. Without any GT UTs, this matches or surpasses CURE-7B, an RLVR model on the same base, trained on 4.5k samples with GT-UT rewards for both code and UT generation, and CoSPlay further improves CURE-7B itself by 5.7% BoN. CoSPlay also generalizes across diverse backbones and achieves higher average accuracy than GT-free TTS baselines under comparable token budgets. By letting codes and UTs improve each other without any GT, CoSPlay offers not only a scalable inference strategy but also a new perspective on recursive self-improvement for verifiable problems without external supervision.

Primary area:
foundation or frontier models, including LLMs
Keywords:
Code generation, test time scaling, self-play, automated Unit Test Generation

Reviews

Among:
Shape:
1234this paper, Top 15%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 3.00 over 3 reviews, above 85% of the others.
Reviewer_cNSQOpenReview ↗
Rating
3(+1)
Confidence
3
Informativeness
2
Presentation
1
Soundness
2
Read review
Paper summary

This paper presents CoSPlay, a test-time unit test generation framework that aims to improve code generation quality with self-generated tests. The proposed method uses a self-play iterative loop to select higher-quality tests, and use those against the generated code to improve its quality. Evaluations on multiple code generation models across four coding benchmarks show improvements compared to the base models.

Critical strengths
  1. The idea of self-generating unit tests is sound, and improving code quality with unit test quality at test time is a well-motivated research question. The abstract and introduction are also well written to motivate it.

  2. The proposed method operates at test time, saving the cost and effort of training a better unit test generator.

Critical weaknesses
  1. The idea of generating unit tests feels like UTGen [1]. Although it is cited in the paper, there is less discussion of the distinction and comparison with this work. The consensus selection part is especially similar to what UTGen uses to select better unit tests. They have also clearly defined the Attack Rate, which reads similarly to "Failure-oriented UT attack idea exploration" in lines 146-152.

  2. The proposed pipeline has many design choices. Although the authors did a good job of justifying them with empirical results, it feels bloated and complicated. It is not clear to me how much it costs, compared to using Claude Opus 5.5 or GPT6 to generate the tests. There are also open-source models like UTGen that can serve this purpose.

  3. The main results largely compare different models, but there is less focus on different ways of generating unit tests. This is connected to the point above -- how much better is the proposed method at doing unit test generation compared to other methods?

  4. The token count analysis for efficiency is great, but it focuses on test-time scaling and doesn't answer points (2) and (3), which is how much cost it saves when compared to other unit test generation methods.

[1] https://arxiv.org/abs/2502.01619

Questions for authors
  1. Not really a question but more of a suggestion: there is a lot of negative space throughout the paper, making the layout crowded and hard to read. Figure 2 also has a lot of text. Overall, making more space will improve readability.

  2. Figure 3 is not informative and takes up some space within the middle of the method, making it harder to follow. It is not clear to me what Figure 3 wants to convey. The text itself is already self-contained.

  3. The method section is overwhelming with a lot of notations, in-line math symbols, and reduced vspace. The connections to figures are also interleaved, so readers have to switch between figure 2,3,4 and equations back and forth.

  4. I can't really read anything from Figure 9 (b). It is way too crowded.

Reviewer_y4gKOpenReview ↗
Rating
3
Confidence
3
Informativeness
2
Presentation
2
Soundness
3
Read review
Paper summary

This paper investigates how to improve code generation during TTS via the co-evolution of code and self-generated unit tests in the absence of Ground-Truth Unit Tests (GT UTs). The authors propose CoSPlay, which leverages the execution matrix between code candidates and tests, along with bidirectional pass counts, to identify more reliable candidates. It then performs optimization through iterative updates and output consensus clustering.

Critical strengths

The research problem is important and holds clear practical significance. Existing code generation methods based on verifiable rewards typically rely on high-quality test cases, while manually constructing or generating GT UTs can be costly. This paper directly addresses test-time optimization without GT UTs, attempting to simultaneously improve both code solutions and unit tests rather than assuming one is reliable and using it as a supervision signal for the other. The overall method design is thorough and backed by theoretical analysis. And extensive evaluations across multiple benchmarks demonstrate the effectiveness of the proposed CoSPlay framework.

Critical weaknesses
  1. Although CoSPlay does not rely on GT UTs, the clustering selection in Stage 3 still depends on inputs generated by an external LLM, meaning that it still requires an external signal. If the LLM fails to generate representative or sufficiently discriminative inputs, different incorrect codes may be erroneously clustered together.
  2. The final unit tests in CoSPlay are generated based on both the problem and a plan, followed by multiple rounds of refinement. In contrast, the baseline models and CURE generate unit tests in a single pass directly from the problem description. Could the authors analyze whether this difference in the UT generation and refinement process affects the fairness and comparability of the reported metrics?
Questions for authors

Please refer to the weaknesses above.

Reviewer_XYbwOpenReview ↗
Rating
3
Confidence
2
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

This paper proposes CoSPlay, a test-time framework that jointly refines generated programs and unit tests without ground-truth tests or additional training. It uses pass counts in a code–test execution matrix to guide regeneration and repair, then resolves ties among top programs through agreement on randomly generated inputs.

Critical strengths
  1. The paper addresses an important failure mode of self-generated tests: an incorrect expected output can reward an incorrect program and misdirect subsequent repair. Treating test quality as something to improve during inference is a worthwhile contribution.

  2. The empirical study is fairly thorough. On the full four-benchmark evaluation, CoSPlay raises Qwen2.5-7B-Instruct’s final accuracy from 22.1% to 33.2% and also improves CURE-7B. I particularly appreciated the separate measurements of test accuracy, verifier accuracy, and code accuracy; the coverage-versus-selection analysis helps explain where the final gains come from.

Critical weaknesses
  1. The theoretical analysis establishes when pass counts are informative under independent sampling, but the proposed procedure repeatedly updates codes and tests using one another. These dependencies, and the possibility that many candidates share the same wrong behavior, are central to the method yet fall outside the analysis. The largest-cluster argument also requires an additional assumption that the correct behavior is more common than any particular incorrect behavior.

  2. The practical cost deserves more emphasis. The full 7B configuration averages roughly 682K generated tokens and 776 model calls per problem. The paper compares token and execution budgets, but those figures alone do not establish the latency of the full procedure. Also, the 33.2% versus 32.9% comparison with CURE-7B is too close to support a strong claim of superiority.

Questions for authors
  1. The paper reports aggregate evidence that pass counts correlate with correctness. How often does this relationship fail for an individual problem or deteriorate over self-play rounds, and what do those failures look like?
  2. Could the authors report wall-clock cost alongside accuracy for the full and lightweight variants? This would clarify how much of the gain from later refinement steps is useful in a practical inference setting.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.