Agentic Synthesis against Counterexample-Supplemented Sketches
This paper introduces "Agentic Synthesis against Counterexample-Supplemented Sketches," a repository-native method where human-approved policy corrections are integrated into an evolving code sketch rather than accumulated examples, demonstrating that this approach reduces developer effort and improves the transfer of learned rules to unseen cases compared to traditional replay-based regeneration.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine a world where you have a super-smart robot assistant that can write computer code for you. It's like having a genius apprentice who can type faster than anyone else and knows a million programming tricks. But here's the catch: this robot is a bit of a "people pleaser." If you tell it, "Fix this broken button," it will happily fix the button. But if the button was broken because of a secret rule you never told it (like "never let the button turn red on Tuesdays"), the robot might fix the button while accidentally breaking that secret rule. If you don't catch it, the robot might make the exact same mistake again next time, because it only remembers the specific fix, not the reason behind it. This is the problem of "coding agents" in the real world: they are great at patching holes, but terrible at learning the deep, unwritten laws of how a system should behave unless someone explicitly teaches them.
This paper, written by Muness Castle and Eric Rubeck, tackles that exact problem. It introduces a new way of working called "Agentic Synthesis against Counterexample-Supplemented Sketches." Think of it as a rigorous training camp for AI coders. Instead of just letting the AI guess and check, this method forces a human to act as a strict coach. When the AI makes a mistake that breaks a hidden rule, a human doesn't just say "fix it." They say, "Here is the mistake, here is the correct answer, and here is the rule you broke." The AI then has to rewrite its own "instruction manual" (called a sketch) to include that new rule before it's allowed to try again. The paper tests this idea with a fake browser app called "CatSynth" and finds that this method helps the AI learn the rules better than just showing it a list of past mistakes, though the authors are careful to say this is based on one specific experiment, not a magic bullet for every situation.
The Story of the Sketch and the Rulebook
Imagine you are trying to build a robot that picks the perfect cat for a family. You give the robot a "Sketch." In this story, a Sketch isn't a drawing; it's a rough, half-written instruction manual. It says things like, "The cat should be fluffy," and "The cat should be friendly." But it's missing the most important part: "The cat cannot be a Persian because the family has a cat allergy."
At first, the robot (the coding agent) looks at the Sketch and says, "Okay, Persians are fluffy and friendly! I'll pick a Persian!" It writes the code to do this. But then, a human expert (the Subject-Matter Expert) looks at the result and says, "Whoa, stop! That's a disaster. The family has an allergy. You picked the wrong cat."
In the old way of doing things, the human might just say, "Okay, fix it, pick a different cat." The robot would then pick a different cat, maybe a Siamese. But the robot wouldn't actually learn the rule about allergies. It would just remember "Don't pick Persians for this specific family." Next time, if the family changed their mind about the allergy but the robot didn't know, or if a new family with an allergy came along, the robot might make the same mistake again.
This paper proposes a different, stricter loop. When the human expert says, "Wrong cat!", they don't just fix the output. They act like a judge in a courtroom. They say:
- The Mistake: "You picked a Persian."
- The Correction: "The correct cat is a Siberian."
- The Rule: "The rule you broke is: 'Hard rules (like allergies) must always beat soft preferences (like fluffiness).'"
Then, a human "Operator" (the boss) has to explicitly sign off on this. They say, "Yes, this is a real rule now." Once signed, the robot must rewrite its Sketch to include this new rule. The robot can't just patch the code; it has to update the manual.
The Two-Step Check: The Replay and The Compare
To make sure the robot actually learned the lesson, the paper uses a clever two-step test, like a security guard checking a visitor at a gate.
- The Replay (The "Did you fix the mess?" check): This checks if the robot's new answer actually solves the immediate problem. Did the robot pick a cat that is fluffy and friendly? If yes, the "Replay" passes.
- The Compare (The "Did you follow the rules?" check): This is the tricky part. It checks if the robot picked the right cat based on the new rule. Did it pick the Siberian instead of the Persian? Did it remember the allergy? If the robot picked a fluffy Persian that solved the "fluffy" problem but broke the "allergy" rule, the "Compare" fails.
The paper calls this the "Gate." If the robot passes both, it moves on. If it fails the Compare, it means the robot fixed the surface problem but ignored the deep rule. The robot has to go back and fix its Sketch again.
The CatSynth Experiment
The authors tested this with a fake project called CatSynth. They created a scenario where a robot had to pick a cat based on a list of preferences (big, fluffy, affectionate) and a hard rule (no cats that trigger allergies).
They ran a simulation where the robot tried to solve 14 different "frozen" cases (scenarios that were set in stone before the experiment started).
- The Result: In 8 out of 14 cases, the robot's initial guess was wrong because it missed a rule. These 8 cases became "counterexamples."
- The Process: For each of these 8 mistakes, a human approved the correction, the robot updated its Sketch, and the robot tried again.
- The Test: After the robot finished learning, the authors tested it on 21 new, hidden cases (cases it had never seen before).
Here is what they found:
- When they rebuilt the robot's code from scratch using only the final, evolved Sketch (the one that had been updated with all the rules), the robot got 19 out of 21 of the new cases right.
- When they tried to rebuild the robot by showing it the original Sketch plus a long list of all the past examples (the "replay-all" method), the robot only got 15 out of 21 right.
This suggests that having the robot learn the rules and write them into its Sketch was more effective than just showing it a history of mistakes. The robot that learned the rules generalized better to new situations.
What This Means (and What It Doesn't)
The paper is very careful not to overhype the results. They don't claim this is the "perfect" way to fix all AI coding problems forever. They admit that this was a simulation with one specific model (GPT-5.4-mini) and one specific order of problems. They don't know if it would work exactly the same way with a different robot or a different set of rules.
However, the experiment does show something important: It's better to teach an AI the "Why" (the rule) than just the "What" (the example).
If you just show an AI a list of "Don't do X," it might memorize the list but miss the pattern. But if you force the AI to update its own instruction manual (the Sketch) every time it breaks a rule, and then test it by throwing away its old code and rebuilding it from that manual, you get a smarter, more reliable AI.
The authors also point out that this method requires a lot of human effort. You need a human expert to spot the mistake, a human operator to approve the new rule, and a human to curate the list of tests. It's not a "set it and forget it" system. It's a partnership where the human is the teacher and the AI is the student who has to take notes and rewrite its own textbook.
The Takeaway
In the end, this paper is a guide on how to stop AI from being a "plausible but wrong" fixer. It argues that when an AI makes a mistake, we shouldn't just patch the code. We should treat the mistake as a lesson that changes the AI's fundamental understanding of the world. By using a "Sketch" to hold the rules, a "Gate" to check the work, and a human to approve the lessons, we can build AI that doesn't just guess the right answer, but actually understands why it's right.
The authors conclude that while this method didn't solve every problem in their simulation (the robot still got 2 out of 21 hidden cases wrong), it proved that the "evolved Sketch" carried the knowledge better than a simple history of examples. It's a step toward making AI coding more like a disciplined apprenticeship and less like a lucky guess.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.