Diagnosing State Validity in Agent-Generated Code: what it means for business leaders
Fifteen programs written by coding agents passed every hidden test and earned full verifier reward, yet each is provably wrong on a valid input, and most of the errors trace to what the program chose to remember or discard.
1. What the method is
This paper is a diagnostic study, not a new model or tool. The authors, from Invisible Technologies, take fifteen programs written by coding agents for seven exact optimization tasks. Every one passed all of its hidden tests and received full verifier reward, and every one returns a wrong answer on some valid input. They introduce the term state validity for the property that failed: whether the working state a program keeps while it runs (the partial solutions it represents, updates and retains) preserves enough information to reach the true optimum. They sort defects into three kinds: a representation that merges or cannot express histories that matter later, a transition that breaks the task's rules, and pruning that throws away a candidate the optimum needed. Each error is established without relying on the task's reference solution, and the programs, inputs and checks are released in a public repository.
2. Why the method was developed
Generated code is judged almost everywhere by running it against tests: HumanEval, LiveCodeBench, SWE-bench and contest-style graders all accept a submission that produces the expected outputs. The same verifier can also supply the reward signal when models are trained with verifiable rewards. A test examines one output on one input. It does not examine the decisions behind that output, so a program that keeps only the 200 best partial solutions looks identical to a correct one until an input makes the discarded candidate matter. Earlier work showed that stronger test suites expose programs that passed weaker ones, but it stopped at the counterexample. The authors wanted to know whether the failure can be traced to a specific decision in the program, and why the original tests missed it. They also treat reference solutions as fallible, which turned out to be warranted: two of their own eight diagnostic tasks have references that fail a basic quality check.
3. Who should care
Engineering leaders who accept agent-written code on the strength of a green test run are the first audience, particularly where the code does search, scheduling, routing, allocation, pricing or any optimization in which a silently suboptimal answer costs money and never raises an error. Quality and platform teams that design our acceptance gates should read it for the specific blind spot it documents: size-triggered shortcuts such as caps, beams and fallbacks that our test inputs never make large enough to matter. Teams that build evaluation benchmarks or fine-tune models with test-based rewards should care because a verifier that accepts wrong programs both inflates scores and rewards the wrong behavior, although the paper does not measure any effect on training. Procurement and vendor management should note it when a supplier quotes benchmark pass rates as proof of correctness. Those evaluating automated reviewers should note that LLM judges gave these wrong programs near-perfect marks.
4. How the method works
Each error is proved in one of three ways: a hand proof, an exhaustive oracle that enumerates every possibility on a small domain, or a concrete permitted plan that beats the program's answer and is rescored by a separate simulator written only from the task statement. Diagnosis is a second step. The authors instrument the program and make one targeted edit, such as lifting a cap, raising a search budget or adding a guard, then check whether the correct value returns on the failing input. In one task a program keeps the 200 highest-scoring histories; with 201 competing, it drops the only one eligible for the final reward and returns 1,001 instead of the proved 1,002, and removing the cap restores 1,002. To explain the missed detections they replay every hidden suite with coverage measurement, separating tests that never reached the restriction from tests that executed it without the discarded information affecting the answer.
5. How it was evaluated
The programs came from four model configurations, which the authors label Opus, Gemini, Sol and Fable, run through the mini-swe-agent scaffold in a sandbox with 45 to 60 minutes per task. One source is an archive of 67 dynamic-programming tasks with 804 runs, 378 of them accepted. The other is eight purpose-built diagnostic tasks with 92 recoverable programs, 52 accepted. Most tasks had 15 hidden tests with a 30-second limit each. On the diagnostic tasks every program received the same four checks: a replay of the hidden suite, 40 to 60 small seeded instances verified against an exhaustive oracle, up to 150 random instances compared with the reference, and fixed witness inputs. The authors also examined the agents' own test files from 36 runs and the scores of three LLM judges on the archive programs. The fifteen cases were selected retrospectively, so none of these counts is a failure rate or a comparison between models.
6. How it performed
Eight of the fifteen programs have a specific state defect: six confirmed by an edit that restores the correct value, one by an exhibited pair of merged histories and one by an optimal history the program cannot represent. Five more are correct once switched from an approximate fallback to their own exact branch, one is only associated with its fallback, and one is unexplained. Of twelve programs with a size-triggered restriction, eight never had it activated by any hidden test; in four it ran and the answer still matched. The uniform protocol falsified 6 of 52 accepted programs, five caught by random testing, though one defect appeared in 1 of 800 random inputs. LLM judges scored the wrong programs at or near 1.00 on state and transition fidelity. The authors state that nothing here estimates prevalence, that no edit proves a program correct, and that their proposed tests are untried on new programs. Our call: pilot boundary and random testing against an independent oracle on any optimization code we accept from agents, and stop treating a passing suite as proof. (Source: arXiv 2612.05893, 2026)
← Back to dossier index