Agentic Reverse Engineering: From I/O to Code with Discovery Agent

Yihong Dong, Jiaru Qian, Haoran Zhang, Peixu Wang, Binhua Li, Zhi Jin, Yongbin Li, Ge Li, Xiaokang Yang, Xue JiangNeurIPS 2026

TL;DR

Give an LLM a clear prompt, and it writes great code; give it only a handful of input-output examples with zero explanation, and it usually memorizes a brittle lookup table or gets lost in spaghetti logic. DIO-Agent solves this "reverse engineering" problem by pairing LLM-driven evolutionary search with a classic human software engineering discipline: start with the simplest possible code, and only add complexity—like if statements or while loops—when the data forces your hand.

What Problem Does This Paper Address?

Modern code generation (NL2Code) thrives because LLMs learned to map human descriptions to familiar code patterns during pretraining. What happens when there is no description? Whether you are reverse-engineering a black-box API, migrating legacy systems with lost source code, or distilling scientific laws from raw data, you have to deduce the underlying rule strictly from behavior. The authors call this IO2Code.

Figure 1: Illustration of IO2Code, where the mainstream NL2Code task evaluates the composition and reuse ability of LLMs, while the IO2Code task evaluates the induction and discovery ability.

IO2Code is a treacherous search problem with two classic failure modes:

  1. The Overfitting Trap: Without natural language nudging the model toward a general algorithm, the easiest way to pass visible tests is to write a giant if/elif lookup table—which immediately collapses on unseen inputs.
  2. The Blind Mutation Trap: If you use evolutionary search to randomly tweak code, the LLM quickly wanders into syntactically complex, semantically broken dead ends that are nearly impossible to mutate out of.

Methods

DIO-Agent builds on a standard multi-island evolutionary backbone (where an LLM proposes SEARCH/REPLACE code diffs and a sandbox executes them), but tames the search space using three tightly coupled innovations:

Figure 2: Overview of DIO-Agent.
  • Transformation-Priority Guided Mutation (TPP): Borrowed from Robert Martin’s Test-Driven Development (TDD) practices, TPP enforces a strict structural hierarchy: constants $\rightarrow$ variables $\rightarrow$ conditionals (if) $\rightarrow$ loops (while) $\rightarrow$ recursion. Prompting biases the LLM to exhaust simple constructs before escalating to complex control flow, acting like Occam’s Razor inside the mutation operator.
  • Curriculum-wise Evolution: Instead of dumping all I/O pairs on the agent at once, examples are sorted from shortest/simplest to hardest and revealed in nested stages. The winning program from stage $s-1$ seeds stage $s$, allowing the agent to establish a clean core hypothesis early and refine it gradually.
  • Error-Grounded Feedback: Scalar accuracy scores hide why a program failed. DIO-Agent passes concrete execution mismatches, runtime errors, and an inherited chain of ancestor bugs directly into the mutation prompt, while explicitly penalizing code bloat and input-copying in its fitness score.

Datasets

Because existing Programming-by-Example (PBE) benchmarks mostly focus on narrow domains like spreadsheet string manipulation, the authors introduce IO2CodeBench. It evaluates true algorithmic induction across four distinct tiers—Base, Algorithm, Geometry, and Multimodal—using strict held-out test sets to catch overfitting. (Note: This is an inference-time discovery framework; no training datasets are used.)

Key Insights and Ideas

  • Brute-force sampling hits a wall: Giving an LLM 40 independent tries (Best-of-N) or using Self-Consistency severely trails 40 steps of structured evolution. In discovery tasks, the true underlying rule is rarely sitting at the top of the model's prior distribution waiting to be sampled.
  • Shrinking code is the hallmark of a eureka moment: Tracking code length across evolutionary stages revealed a striking pattern: runs that continuously simplified their code succeeded 94.4% of the time, whereas monotonically growing code signaled "patch-work" overfitting. Failed runs averaged 833.9 characters on the final stage (even when scoring 100% on visible tests!), compared to crisp 249.8-character solutions for true discoveries.
  • Active exploration unlocks even better discovery: When the authors removed static examples and let DIO-Agent invent its own inputs to query a black-box oracle, performance jumped even higher—proving the agent can strategically probe edge cases to resolve ambiguity.
Figure 4: Comparison between DIO-Agent and AlphaEvolve. (a) DIO-Agent produces shorter cor- rect programs. (b) DIO-Agent reduces incorrect early stopping during search. (c) DIO-Agent copies fewer prompt example cases into the generated programs.

Key Results

Across IO2CodeBench (using DeepSeek V3.2), DIO-Agent achieves an average pass rate of 58.63%, beating traditional PBE (14.58%) and state-of-the-art evolutionary coding agents like AlphaEvolve (47.29%) and CodeEvolve (49.60%).

  • Excels on hard tasks: On Algorithm tasks, DIO-Agent hits 71.43% (vs. 60.00% for AlphaEvolve/CodeEvolve), and nearly doubles AlphaEvolve on noisy Multimodal tasks (40.67% vs. 22.00%).
  • Token efficient: It uses 3,738 tokens/iteration, significantly leaner than AlphaEvolve (4,130) and CodeEvolve (5,829).
  • Model-agnostic: Swapping the backbone to Qwen-3.6-Plus (55.45% avg) or Claude-Sonnet-4.6 (57.31% avg) yields similarly strong gains over baselines.
  • Ablations: Removing the easy-to-hard curriculum hurts most (dropping accuracy to 51.33% while spiking token costs), followed by removing TPP (53.80%) and Error Feedback (54.61%).

Limitations and Future Work

While the main text does not feature a standalone limitations section, the authors' failure analyses highlight clear boundaries: models still fall prey to verbose overfitting in deceptive domains like Arithmetic (where 36 of 42 test failures achieved perfect training accuracy via convoluted logic), and autonomous active exploration significantly extends the search horizon required per task. Looking ahead, the authors position IO2CodeBench and active oracle-querying as stepping stones to push code-generating LLMs beyond pattern reuse toward autonomous scientific and algorithmic discovery.

Summary updated

Abstract

The automatic synthesis of a program from any form of specification is regarded as a holy grail of computer science. Fueled by LLMs, NL2Code has achieved tremendous success, yet the fundamentally more challenging task of synthesizing programs from input-output behavior, which we refer to as IO2Code, remains largely unsolved. Whereas NL2Code can exploit the semantic alignment between natural language and code acquired during pretraining, IO2Code requires recovering underlying principles from concrete computational behavior, navigating a vast and underspecified hypothesis space. To address this, we propose DIO-Agent, a discovery agent for IO2Code. Our method frames IO2Code as an evolutionary search over discrete program space, in which an LLM serves as the mutation operator and concrete error signals from execution guide each mutation. To prevent the search from wandering into structurally complex yet incorrect dead ends, we introduce the Transformation Priority Premise as a mutation prior that biases the LLM toward the simplest hypothesis consistent with current evidence, progressively escalating from constants to conditionals to iteration only when simpler constructs are insufficient. To facilitate systematic study, we further construct an IO2CodeBench spanning multiple difficulty levels. Extensive experiments show that DIO-Agent consistently outperforms both traditional program-by-example method and SOTA evolution-agent baselines across all difficulty levels and various LLMs, while substantially surpassing test-time scaling strategies with equivalent sampling budgets.
BibTeX
@inproceedings{dong2026agentic,
  author = {Yihong Dong and Jiaru Qian and Haoran Zhang and Peixu Wang and Binhua Li and Zhi Jin and Yongbin Li and Ge Li and Xiaokang Yang and Xue Jiang},
  title = {{Agentic Reverse Engineering: From I/O to Code with Discovery Agent}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=BZxrI7kEUy},
}
Figure