Microsoft Patents an AI Coder That Runs Each Line It Writes to Check Itself
Most AI code writers guess, then hope. This Microsoft filing has the AI run every line it writes and read the results before it writes the next one.

- Publication number
- US 2026/0367883 A1(US20260367883A1)
- Applicant
- Microsoft Technology Licensing, LLC
- Filed · Published
- May 16, 2025 · Nov 19, 2026
- Inventors
- Sumit GULWANI, Mukul SINGH, Ashish TIWARI, Vu Minh LE, Gust Ben Anneloes VERBRUGGEN
- Status when we published
- Waiting for an examiner
- Document
- 20 claims
- US classification
- 717/104
What Microsoft's example-driven code writer does
Every time you fix a messy list by hand, you are showing a pattern: this turns into that. Programming-by-example is the old idea that software should watch a few of those before-and-after pairs and write the instructions for you.
Microsoft's patent application describes how to do that with an AI language model that writes code. Instead of producing the whole program at once and hoping it works, the AI writes a line, actually runs it on your examples, and jots the result next to the line as a note. Then it writes the next line with those results in view.
It keeps going until some line produces exactly the answers you gave, then hands back only the lines that got it there.
… executing the one or more initial lines of code to extract a plurality of variable values, wherein each of the plurality of variable values corresponds to a respective one of the example inputs; storing, for each of the one or more initial lines of code, a text annotation describing the variable values for the example inputs; …
Translation: The system runs early code lines to check variable values and saves notes about them.
How the AI checks each line against your examples
The system starts with a request that includes example inputs and the outputs you want. It builds a prompt (the written instructions fed to the AI model) containing those pairs, then asks the model to build the program one line at a time.
After each batch of lines, the system executes the code on every example and records the value each line produced. Those values are stored as text annotations (comments written next to each line), so the model sees both the code and what the code produces.
- The model samples several candidate lines at once, using functions from the programming language's own library.
- Duplicates are removed, and equivalent lines are tidied into a standard form (canonicalizing).
- The model picks which earlier line to build on, so a single growing prompt holds every branch it explores. The filing calls this within-prompt search.
- Lines that nobody builds on can be dropped.
The loop stops when a function returns the right output for every example, or after a set number of rounds. In the filing's tests, the model proposed four candidates per round, with a cap of eight rounds. Unused lines are trimmed before the program is returned.
Why checking every line matters for AI-written code
If you have ever asked an AI to write a formula or script, you know the failure: the answer looks right and then breaks on the next input. Running each line against your examples gives the AI a built-in way to catch that, and the program it returns matches every example you supplied.
The filing also says the approach works in any programming language the model knows, with no special narrow language required, and that it uses less text than methods that score each option in a separate prompt. Across five test sets in the filing's comparisons, it came out best on three and second best on two. For everyday users, the payoff would be spreadsheet-style tasks handled by showing a few examples.
That makes this Microsoft's 36th filing we've tracked in our AI safety guardrails watchlist since July, building on a surprise test for chatbots and a self-updating grading checklist.
Source: US 2026/0367883 A1 at the USPTO (PDF). Full patent text and figures are in the official publication.
Get our take in your Top Stories
Liked this breakdown? Add Patentlyze as a preferred source on Google, and our plain-English take shows up more often in your Top Stories the next time Microsoft patent news breaks.
We read every patent application Big Tech publishes and send you the ones worth knowing. Plain English, free, every week.
The drawings · 8 sheets
8 drawing sheets from US 2026/0367883 A1 · click any drawing to enlarge

No comments yet