Microsoft · Filed Mar 10, 2025 · Published Sep 10, 2026

Microsoft Patents an AI Coding Tool That Flags Unsafe Inputs Before Running Your Code

When you ask an AI to write code for you, the AI just... does it, without asking whether your request contains something dangerous or malformed. Microsoft's new patent describes a system that makes the AI double-check the request itself before anything runs.

A user's natural language request is translated into code, with a potential error flagged for an unsafe input. Drawing from patent filing US 2026/0267621 A1.
A user's natural language request is translated into code, with a potential error flagged for an unsafe input.
See all 12 drawings from this filing ↓
Publication number US 2026/0267621 A1 US20260267621A1
Applicant Microsoft Technology Licensing, LLC
Filing date Mar 10, 2025
Publication date Sep 10, 2026
Inventors Shikhar Mathur, Derek Koh, Dharmen Mahendra Mehta, Achyuthan Jootoo Ramesh Bapu, Francis Alexander Pattara
US classification 717/104
Status when we published Waiting for an examiner (Apr 16, 2025)
Document 20 claims

How Microsoft's self-checking AI code tool works

You're using an AI assistant to write a piece of software. You type your instructions in plain English, the AI produces working code, and you hit run. But what if part of your original request was ambiguous, malformed, or even malicious? Right now, most systems wouldn't catch that before executing.

Microsoft's patent describes a system that sends two separate sets of instructions to the AI at once: one telling it to generate the code, and another telling it to check whether every part of your original request was safe and valid. If the AI spots something it couldn't confirm as legitimate, that portion of your request gets excluded from the code that actually runs.

Think of it as the AI acting as its own security reviewer. Rather than blindly doing whatever you ask, it pauses to flag the parts of your instructions it can't vouch for, before anything reaches your machine.

From the filing · CLAIM 1
… formulating an instruction for a generative machine learning model (GMLM), wherein the instruction comprises an input validation sub-instruction and a code generation sub-instruction; …

Translation: The system prepares instructions for the AI that include both security checks and coding tasks.

How the GMLM splits validation from code generation

The core idea is splitting a single AI prompt into two coordinated sub-instructions that run together. When you submit a plain-English request to generate code, the system doesn't just hand that request to the AI and ask for code. It also hands the AI a second, separate directive: check whether each part of the input has been properly validated.

Here's how the pieces fit together:

  • Code generation sub-instruction: The AI receives your natural-language request alongside a prompt to produce executable code in a programming language. This is the familiar part of any AI coding tool.
  • Input validation sub-instruction: At the same time, the AI processes a second prompt asking it to identify any portion of your original input that it couldn't verify as safe or well-formed. This is the new layer.
  • Exclusion step: Any fragment of your input flagged as "unvalidated" is stripped out before the generated code is actually executed. The system runs a cleaner version of the code, with the suspicious parts left out.

The patent calls this model a Generative Machine Learning Model (GMLM), which is just the AI doing both jobs simultaneously using a single, specially structured prompt. The key insight is that the same AI that writes the code is also asked to audit the instructions that produced it.

From the filing · THE ABSTRACT
… detect an unvalidated portion of the digital input. Examples may exclude the unvalidated portion of the digital input from an execution of the code generated by the GMLM.

Translation: The tool spots unsafe parts of your prompt and blocks them from running in the final code.

What this means for AI-assisted software development

AI coding assistants are already embedded in developer workflows, and the question of what happens when a bad or manipulated prompt sneaks through is becoming a real security concern. A system that catches unvalidated inputs before execution adds a layer of protection that currently has to be built manually, if it's built at all.

Microsoft's steady investment in AI coding safety is visible here: the patent sits squarely inside the GitHub Copilot and Azure AI ecosystem. For everyday users, the practical upshot is that AI tools built on this approach would be less likely to run code based on garbled or tampered instructions, which matters most in enterprise or automated environments where human review doesn't always happen before execution.

That makes this Microsoft's 17th filing we've tracked since July in our AI guardrails race watch, building on their work around rewriting security rules and blocking forbidden leaks.

Editorial take

Claim 1 is structurally broad. It covers any method that formulates a single instruction containing both a validation sub-instruction and a code generation sub-instruction, detects an unvalidated portion, and excludes it from execution. The claim doesn't require a specific programming language, a specific AI architecture, or a specific validation technique. That breadth means it could, if granted, reach a wide range of AI coding tools that happen to combine prompt-based validation with code generation in one pass.

In practice, the narrowest reading is still pretty wide: any system where the same model that generates code is also asked to flag unvalidated input, all within one structured prompt, falls within the claim's scope. That's a pattern likely to appear in many AI developer tools as safety requirements tighten.

Whether the patent survives examination at that breadth is another question. Prompt engineering techniques that bundle instructions together are well-documented in published research, and examiners will push for prior art. But as a description of a problem worth solving, the filing is clear-eyed: the gap between "AI wrote the code" and "the code is safe to run" is real, and plugging it at the prompt level is a practical approach.

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/0267621 A1 · click any drawing to enlarge

Multi-agent system overview., drawing sheet 1 from US 2026/0267621 A1
Sheet 1 Multi-agent system overview.
Input augmentation agent interactions., drawing sheet 2 from US 2026/0267621 A1
Sheet 2 Input augmentation agent interactions.
Input augmentation sub-agent details., drawing sheet 3 from US 2026/0267621 A1
Sheet 3 Input augmentation sub-agent details.
Natural language to code example., drawing sheet 4 from US 2026/0267621 A1
Sheet 4 Natural language to code example.
Multi-agent system interaction flow., drawing sheet 5 from US 2026/0267621 A1
Sheet 5 Multi-agent system interaction flow.
AI code generation method., drawing sheet 6 from US 2026/0267621 A1
Sheet 6 AI code generation method.
User and application system connections., drawing sheet 7 from US 2026/0267621 A1
Sheet 7 User and application system connections.
Machine learning model training., drawing sheet 8 from US 2026/0267621 A1
Sheet 8 Machine learning model training.
Show the other 4 sheets
Microsoft Patents an AI Coding Tool That Flags Unsafe Inputs Before Running Your Code patent drawing, sheet 9
Sheet 9
Microsoft Patents an AI Coding Tool That Flags Unsafe Inputs Before Running Your Code patent drawing, sheet 10
Sheet 10
Microsoft Patents an AI Coding Tool That Flags Unsafe Inputs Before Running Your Code patent drawing, sheet 11
Sheet 11
Microsoft Patents an AI Coding Tool That Flags Unsafe Inputs Before Running Your Code patent drawing, sheet 12
Sheet 12
Browse all the drawings 12 drawing sheets
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.