Get the newsletter
IBM · AI / ML · Filed Mar 28, 2025 · USPTO published Oct 1, 2026 · Oct 1 release

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.All 14 drawings ↓
Publication number
US 2026/0299897 A1(US20260299897A1)
Applicant
INTERNATIONAL BUSINESS MACHINES CORPORATION
Filed · Published
Mar 28, 2025 · Oct 1, 2026
Inventors
Zhenfang Chen, Yikang Shen, Chuang Gan, Xin Zhang, Shun Zhang
Status when we published
Waiting for an examiner
Document
20 claims
US classification
717/106

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.

Source: US 2026/0299897 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 IBM 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 · 14 sheets

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

Computer system with code generation AI., drawing sheet 1 from US 2026/0299897 A1
Sheet 1 Computer system with code generation AI.
Server with code generation AI., drawing sheet 2 from US 2026/0299897 A1
Sheet 2 Server with code generation AI.
Code generation problem and solutions., drawing sheet 3 from US 2026/0299897 A1
Sheet 3 Code generation problem and solutions.
AI code generation and evaluation process., drawing sheet 4 from US 2026/0299897 A1
Sheet 4 AI code generation and evaluation process.
Algorithm for AI code generation., drawing sheet 5 from US 2026/0299897 A1
Sheet 5 Algorithm for AI code generation.
Iterative code generation refinement., drawing sheet 6 from US 2026/0299897 A1
Sheet 6 Iterative code generation refinement.
Code generation with pass rates., drawing sheet 7 from US 2026/0299897 A1
Sheet 7 Code generation with pass rates.
Performance comparison of code generators., drawing sheet 8 from US 2026/0299897 A1
Sheet 8 Performance comparison of code generators.
Show the other 6 sheets
IBM Patents an AI Code Generator That Tests Its Own Work as It Writes patent drawing, sheet 9
Sheet 9
IBM Patents an AI Code Generator That Tests Its Own Work as It Writes patent drawing, sheet 10
Sheet 10
IBM Patents an AI Code Generator That Tests Its Own Work as It Writes patent drawing, sheet 11
Sheet 11
IBM Patents an AI Code Generator That Tests Its Own Work as It Writes patent drawing, sheet 12
Sheet 12
IBM Patents an AI Code Generator That Tests Its Own Work as It Writes patent drawing, sheet 13
Sheet 13
IBM Patents an AI Code Generator That Tests Its Own Work as It Writes patent drawing, sheet 14
Sheet 14
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.