Get the newsletter
Microsoft · AI / ML · Filed May 16, 2025 · USPTO published Nov 19, 2026 · This week's release

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.

Code suggestions evaluated line by line, with execution results saved as comments so the system can verify each step. Drawing from patent filing US 2026/0367883 A1.
Code suggestions evaluated line by line, with execution results saved as comments so the system can verify each step.All 8 drawings ↓
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.

From the filing · CLAIM 1
… 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.

There are more where this came from

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

Computer parts that guide an AI in writing software, drawing sheet 1 from US 2026/0367883 A1
Sheet 1 Computer parts that guide an AI in writing software
Feeding test results into the AI to fix code, drawing sheet 2 from US 2026/0367883 A1
Sheet 2 Feeding test results into the AI to fix code
Testing candidate code lines and saving outputs as notes, drawing sheet 3 from US 2026/0367883 A1
Sheet 3 Testing candidate code lines and saving outputs as notes
Growing a full program line by line using verified results, drawing sheet 4 from US 2026/0367883 A1
Sheet 4 Growing a full program line by line using verified results
Test scores showing how line checks improve code accuracy, drawing sheet 5 from US 2026/0367883 A1
Sheet 5 Test scores showing how line checks improve code accuracy
Steps for generating software by running lines on sample inputs, drawing sheet 6 from US 2026/0367883 A1
Sheet 6 Steps for generating software by running lines on sample inputs
Repeating code trials until a working solution is discovered, drawing sheet 7 from US 2026/0367883 A1
Sheet 7 Repeating code trials until a working solution is discovered
Hardware components that run the coding AI system, drawing sheet 8 from US 2026/0367883 A1
Sheet 8 Hardware components that run the coding AI system
Patent filing page

Watchlists this filing belongs to

All watchlists →
Reader comments

No comments yet

Start the discussion

Real name or a handle, either is fine. Comments are read by a person before they appear, so allow a little time. Keep it about the filing.