IBM · Filed Mar 28, 2025 · Published Oct 1, 2026 · verified — real USPTO data

IBM Patents an AI Code Generator That Tests Its Own Work as It Writes

IBM has filed a patent for an AI system that doesn't just write code from plain-English instructions, it also generates test cases on the fly and uses them to guide its own output before it ever hands you the result.

A transformer AI generates and evaluates code programs using a process of selection, expansion, evaluation, and backpropagation. Drawing from patent filing US 2026/0299897 A1.
A transformer AI generates and evaluates code programs using a process of selection, expansion, evaluation, and backpropagation.
See all 14 drawings from this filing ↓
Publication number US 2026/0299897 A1
Applicant INTERNATIONAL BUSINESS MACHINES CORPORATION
Filing date Mar 28, 2025
Publication date Oct 1, 2026
Inventors Zhenfang Chen, Yikang Shen, Chuang Gan, Xin Zhang, Shun Zhang
CPC classification 717/106
Grant likelihood Medium
Examiner CENTRAL, DOCKET (Art Unit OPAP)
Status Docketed New Case - Ready for Examination (Apr 28, 2025)
Document 20 claims

What IBM's self-testing code AI actually does

Every time a developer asks an AI tool to write a piece of software, the AI produces code that looks right but may fail the moment it runs. Catching those failures usually means someone has to write separate tests afterward, run them, and loop back to fix things.

IBM's patent describes a system where two AI models work in tandem: one writes the code, and another generates tests for that code. Crucially, each model learns from the other's results, so they improve together over time.

The code-writing model also uses a technique called tree search to plan several possible code paths before picking the one most likely to pass the tests. Think of it like a chess engine that considers multiple future moves before committing to one, except the "moves" here are lines of code.

From the filing · CLAIM 1
… generating corresponding computer code utilizing a code generation large language model (LLM) that includes a planning-guided transformer decoding (PG-TD) algorithm …

Translation: An advanced AI model writes software code based on a plain English description of what the application should do.

How the two transformers train each other in a loop

The system takes a plain-English description of what a program should do and outputs working computer code. That part is familiar territory for AI tools. What's different is the internal structure IBM proposes.

There are two transformer models (a transformer is the neural-network architecture behind most modern AI language tools, including ChatGPT):

  • Code generation transformer: writes the actual code.
  • Test case generation transformer: writes the checks that verify the code works correctly.

The two models are jointly trained, meaning neither is static. The code model's outputs inform how the test model improves, and the test model's outputs inform how the code model improves. They pull each other up.

On top of that, the code model uses a planning-guided transformer decoding (PG-TD) algorithm, which applies tree search (the same class of look-ahead technique used in game AI) during the writing process itself. Instead of generating code token by token and hoping for the best, it explores branches of possible code and picks the branch most likely to pass the test cases generated by its partner model.

From the filing · THE ABSTRACT
… tree search-based planning in a decoding process of a code generation transformer that is trained using test cases generated by a test case generation transformer …

Translation: One AI system uses a second AI system to write test cases that check whether the first system is writing correct code.

What this means for AI-generated code quality

For developers, the practical promise here is fewer broken outputs from AI coding tools. Right now, AI-generated code is fast but unreliable, you still have to babysit it. A system that builds self-checking into the generation process could meaningfully reduce that back-and-forth.

IBM's long bet on enterprise AI coding tools shows up across multiple filings, and this one fits a clear pattern: making AI code generation trustworthy enough for professional use, not just impressive enough for demos. Whether this particular approach survives contact with real-world codebases is a separate question, but the problem it's aimed at is real and expensive for companies that rely on generated code.

IBM's 18th filing we've tracked on our AI teams of models watchlist since May builds on earlier work like auto-fixing IT outages and self-built reference databases.

Editorial take

Getting this from patent to product requires two large AI models to be trained together in a loop, each improving based on the other's output. That coordination problem has to be solved before a single line of useful code reaches a developer.

The patent also describes a search process where the AI explores many possible ways to write code before committing to one, which is how it avoids producing answers that look correct but fail in practice. That kind of exhaustive checking is slow by nature, and slow tools get abandoned.

IBM is addressing a real cost: coding assistants that generate confident, broken code waste developer time and erode trust. But this document describes the design, not the solution to the speed and scale problems that would make it shippable, so the path to a finished product runs through substantial engineering work that is not yet on the page here.

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

14 drawing sheets from US 2026/0299897 A1 · click any drawing to enlarge

Patent filing page

Source. Full patent text and figures from the official USPTO publication PDF.
Reader comments

Be the first to weigh in

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.