Microsoft Files Patent for Fixing How AI Coding Assistants Search Through Your Code
AI coding assistants often read your project in slices that can end halfway through a function. Microsoft's new patent application tries to fix that by having a second pass of AI move the cut lines so each slice makes sense on its own.
What Microsoft's code-search filing actually does
Imagine tearing a cookbook into strips of exactly equal length without reading it first. One strip ends halfway through an ingredient list, and the next starts in the middle of the instructions. Now ask a helper to find the pancake recipe. That is roughly the problem an AI coding assistant faces when it searches a big software project.
Microsoft's patent application describes a fix. It still cuts the code into equal slices, because that works for any programming language. Then an AI model looks at each slice along with its neighbors and moves the cut lines, so a whole function or section stays together.
The system also files each piece in several ways: the code itself, a plain-English description of it, and a list of other code it depends on. When you ask a question, another AI picks which of those to search.
generating a plurality of fixed sized chunks from a codebase by dividing files of the codebase into chunks of a fixed size; generating, from the plurality of fixed sized chunks, a plurality of enhanced chunks …
Translation: The system chops up code files into uniform pieces and then improves them.
How the AI redraws the edges of each code slice
The system is built around retrieval-augmented generation, or RAG (a technique where an AI looks up outside material before answering, instead of relying only on what it learned in training). For software, the project's files must be split into chunks small enough for the model to read.
First, each file is divided into fixed-size chunks, a set number of bytes or characters. Because any programming language can be cut this way, the approach is called language-agnostic (it works without rules written for each language). Next, an "enhancement model," which can be an off-the-shelf large language model, receives each chunk plus its neighbors in a moving window and redraws the boundaries. In the filing's example, a chunk holding the middle of a method gets extended to include the method's beginning and end.
Then each enhanced chunk is indexed (made searchable as lists of numbers that capture meaning, called vector embeddings) in three ways:
- Content index: the code itself.
- Description index: a plain-language description written by another model.
- Reference index: calls to code outside the chunk, plus descriptions of those calls.
At question time, a model turns your request into a search string and a search strategy. "Explain what method Y does" goes to the description index, while "where is method Y used" goes to the reference index. Several strategies can run at once, and results from multiple codebases can be ranked together.
What this means for AI coding assistants
If you use an AI coding assistant, its answers depend on whether it pulls up the right piece of code. The filing says this approach aims to cut down incomplete or irrelevant results without retraining the model, and without writing custom setup for each programming language. That matters most for companies whose projects mix several languages.
The patent examiner has issued a final rejection of this application, so no patent has been granted. Microsoft can still amend the claims or appeal. The filing also says the chunk-fixing idea could apply to other text, such as logs that are close together in time.
Microsoft's 79th filing we've tracked in our AI assistant & agent coverage since May adds to a run that includes an app-finding AI assistant and faster chatbot math.
The big trade here is up-front cost in exchange for easier searching later. Every slice of code gets read by one AI model, described by another, and then stored three different ways. For a large project that means a lot of AI calls and a lot of storage before anyone asks a single question.
The fixed-size starting cut also gives something up. It keeps the system working in any programming language, but a function longer than the window of neighboring slices the model sees could still get split. And a wrong description written by the AI would send searches to the wrong place with full confidence.
Still, the trade reads as worth it for code that is indexed once and searched thousands of times. The recipe is sensible and built from familiar parts. The final rejection means its path to a granted patent is steep.
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
12 drawing sheets from US 2026/0349985 A1 · click any drawing to enlarge
Show the other 4 sheets
Want this weekly breakdown for a company we don't cover? Patentlyze Pro →
Be the first to weigh in