A model that writes a Python script to call five tools in a loop, instead of emitting five separate JSON tool-call blocks and waiting for each result, is not a new idea in 2026 — it's a pattern with a name (CodeAct), a widely cited paper, and shipping implementations at Cloudflare, Anthropic, OpenAI, and HuggingFace. On March 4, 2026, Mistral AI filed for a US patent on exactly this pattern anyway, and the USPTO granted it: US Patent 12,670,045 B1, "Code implemented tool calls," naming Paris-based engineer Gabriel Vergnaud as inventor. When the grant surfaced on Hacker News, the top comment thread did what patent threads on HN always do — start listing prior art, and within a few replies, that list had five separate independent sources.
This is explainx.ai's deep dive into what the patent's Claim 1 actually says in plain language, what "code mode" or "CodeAct" means as an agent-harness design pattern, the specific prior art the community pointed to, and why a French AI lab would file a US software patent it likely couldn't get at home.
TL;DR
| Question | Answer |
|---|---|
| What was granted? | US Patent 12,670,045 B1, "Code implemented tool calls," to Mistral AI |
| Who invented it? | Gabriel Vergnaud, Paris, France (Mistral AI, assignee) |
| When filed? | March 4, 2026, Application No. 19/557,103 |
| What does it cover? | An LLM writes a code block that calls tools; a server runs it in a sandbox, pauses on tool calls the client must execute, resumes with the result |
| What's the common name for this pattern? | CodeAct, or "code mode" |
| Is it novel? | Disputed — Cloudflare (Sep 2025), the CodeAct paper (Feb 2024), Anthropic, OpenAI, and HuggingFace's smolagents all describe or ship the same pattern |
| Why file in the US, not the EU? | The European Patent Office generally excludes pure software from patentability; the US doesn't |
| Is this settled law? | No — nobody has challenged the patent yet, and whether it would survive a challenge is an open legal question |
What does Mistral's patent actually claim?
Patent claims are written in dense legal-technical language, but Claim 1 — the independent claim everything else in the patent's 20 claims depends on — is the whole method in one sentence. It's worth quoting directly, since claim language is the actual legal boundary of what's protected, not a paraphrase of it:
"A method, comprising: receiving, at a server, a user request for execution of one or more tool calls; generating, by a large language model (LLM), a code block in a programming language, the code block configured to encapsulate the one or more tool calls; executing, by the server, the code block in a sandbox; in response to obtaining a pending tool call, pausing execution of the code block; transmitting the pending tool call to a client for execution; receiving, from the client, a first result of the pending tool call; resuming execution of the code block and substituting the first result of the pending tool call for the pending tool call in the code block; and returning a second result of the executed code block to the LLM."
In plain language: instead of the model emitting a single structured tool-call request and waiting for the result — the pattern most people know from MCP tool calling and OpenAI-style function calling — the model writes an actual code block, say Python, that calls one or more tools as function calls inside real program logic: loops, conditionals, intermediate variables, branching on a previous tool's output. A server executes that code in a sandbox. When the code hits a tool call it can't run itself — a "pending" call that needs a client to actually execute (hit an API, touch a filesystem, whatever the tool does) — execution pauses mid-script. The pending call ships to the client, the client runs it and sends back a result, and the server resumes the code from exactly where it paused, substituting the real value in for the placeholder. Once the whole code block finishes, the final result goes back to the LLM.
The technical classification (G06F 9/54, "Interprogram communication," with CPC G06F 9/547) and the filing's structure — server, sandbox, client, pause/resume — are what make this a "method" claim rather than an abstract-idea claim under US patent law, which is the legal hook that lets software patents survive at all in the US.
Why write code instead of one JSON call per turn?
This is the part worth understanding on its own, separate from the patent dispute. Code can express things a single tool-call JSON object can't: a for loop that calls the same tool 20 times with different arguments, an if/else branch that only calls a second tool when the first one's result meets a condition, a variable that holds an intermediate result across three tool calls without round-tripping back through the model each time. Emitting one tool call, waiting, emitting the next, waiting again — the pattern most agent frameworks defaulted to — burns a model turn (and token budget) per tool call and forces the orchestration logic to live in the harness rather than in the model's own reasoning. Letting the model write the orchestration as code compresses that into fewer, denser turns. It's the same instinct behind DAG-planner agent harnesses and loop engineering more broadly — pushing control flow out of a rigid request/response loop and into something closer to a real program.
What is CodeAct / "code mode," and who described it first?
"CodeAct" is the name given to this exact idea in an academic paper, arXiv:2402.01030, published in February 2024 — over two years before Mistral's March 2026 filing. The paper's premise is precisely Claim 1 in different words: use executable code, rather than JSON or text, as the unified action space for an LLM agent interacting with tools, because code natively supports control flow (loops, conditionals) and composability (calling multiple tools and combining their outputs) in ways single-shot structured tool calls don't.
"Code mode" is the name Cloudflare gave to its own implementation of the same idea, described in a blog post published September 26, 2025 — about five months before Mistral filed. Cloudflare's write-up describes an LLM writing code that calls MCP tools programmatically, executed inside a sandboxed V8 isolate rather than a plain server-side sandbox. explainx.ai has covered the isolate-based execution model Cloudflare built this on in two companion pieces: Cloudflare Computer, on the isolate-vs-container runtime tradeoff for agent workloads, and Cloudflare Kitesurf, on running an entire browser engine inside the same V8 isolate model. Both describe the identical technical family — untrusted, agent-generated code executed inside a sandboxed isolate, paused and resumed around calls that need to leave the sandbox — that Mistral's Claim 1 covers architecturally.
The prior art Hacker News surfaced
The patent grant showed up on Hacker News as "Mistral Patent for 'Code implemented tool calls,'" drawing 87 points and roughly 82 comments — and the comment section did exactly what a technically literate audience does when a patent claims something they've already seen shipped multiple times. Here's what got surfaced, roughly in the order commenters raised it:
| Prior art | Date | Source |
|---|---|---|
| CodeAct paper — "executable code actions" as agent action space | February 2024 | arXiv:2402.01030 |
| HuggingFace smolagents — "code agents" as a core framework design | Ongoing since inception | smolagents documentation |
| Cloudflare "Code Mode" — LLM writes code calling MCP tools in a V8 isolate | September 26, 2025 | blog.cloudflare.com/code-mode/ |
| Cloudflare "Code Mode: MCP" follow-up | 2025/2026 | blog.cloudflare.com/code-mode-mcp/ |
| Anthropic — "programmatic tool calling" documented in Claude API docs | Predates/contemporaneous | platform.claude.com docs |
| OpenAI — same pattern documented in developer docs | Predates/contemporaneous | OpenAI developer docs |
| langgraph-codeact — open-source implementation | February 2026 | Before Mistral's March 4, 2026 filing |
That's five months of daylight against Cloudflare's public blog post alone, and over two years against the original academic paper — with two of the largest frontier labs, Anthropic and OpenAI, both documenting the same "model writes code, sandbox executes it, tool calls pause and resume" pattern in their own production API docs. None of this proves the patent is invalid — that determination happens in a formal challenge, not a comment thread, and the USPTO's examiner clearly judged the claim allowable as filed. But it does mean the "is this actually novel" question isn't a matter of opinion; it's a documented timeline anyone can check.
Why did the patent examiner allow it?
Brian W. Wathen is named as the primary examiner on the grant. A commenter on the Hacker News thread noted that Wathen has previously granted patents in adjacent, prior-art-heavy territory to Salesforce and NCR Voyix — read by that commenter as evidence of a generally permissive examination pattern in this space rather than something specific to Mistral's filing. That's a reasonable inference from public grant history, not a claim about the examiner's judgment on this particular application, and it's worth holding loosely: examiners work from the prior art actually cited during prosecution, and it's unclear from the outside whether Cloudflare's September 2025 blog post or the CodeAct paper were surfaced to the examiner at all before allowance.
Why file a US patent when Mistral is a French, EU-based company?
This is the detail that generated the most discussion on the thread, and it has a fairly clean answer once you know the underlying law. The European Patent Convention excludes "programs for computers... as such" from patentability at the European Patent Office — pure software methods generally don't get through EPO examination the way they can at the USPTO. A French AI lab describing a server/sandbox/client method has essentially no realistic path to an equivalent patent at home.
US patent law takes a different approach: a software method framed around concrete technical architecture — here, a server, a sandbox, a client, and a defined pause-and-resume execution flow — can clear the bar even when the underlying idea (LLM writes code, code calls tools) is abstract on its own. Filing in the US instead of the EU isn't a mistake or an oversight; multiple commenters read it as a deliberate jurisdictional choice, going to the one major patent office where this kind of claim has a real chance.
The strategic logic commenters converged on: Mistral is smaller than OpenAI, Anthropic, Google, and Meta, all of whom are shipping agent-tooling patches into the same territory. Holding US patents in core agent-infrastructure techniques — even techniques Mistral didn't originate — gives a smaller player negotiating leverage: cross-licensing terms, or a deterrent against being sued first by a larger rival holding its own broad patents. This is a decades-old pattern in software patents generally: companies patent widely-known techniques defensively, building a "war chest" so that if a rival asserts a patent against them, they have something to counter-assert or trade. It isn't a claim to have invented the idea first; it's insurance.
Do Anthropic and OpenAI already ship this?
Yes, in their own current API documentation. Anthropic's Claude API docs describe "programmatic tool calling" as a supported feature — the model writes code that orchestrates tool calls rather than being limited to one structured call per turn. OpenAI's developer docs describe the equivalent capability for its own API. Both of these are live, documented product surfaces, not research demos — developers building against either API today, including anyone using patterns from explainx.ai's MCP guide or agent harness guide, can already reach for code-based tool orchestration without touching anything Mistral built.
Whether that overlaps with Mistral's specific claim language in a way that matters legally is a question for IP counsel, not a blog post — patent claims are narrower than the plain-English description of a pattern, and infringement turns on matching the exact claim elements (server, sandbox, pause on pending call, client execution, substitution, resume), not just "does the general idea look similar." What's factually verifiable is that the pattern, described in almost identical plain-English terms, ships today from at least two other frontier labs.
Should developers be worried?
Short answer: nobody outside a courtroom can give you a confident yes or no today, and this post isn't legal advice. What's true on the record: a patent has been granted, extensive prior art has been publicly surfaced but not tested against the claim in any formal proceeding, and — as of this post's publication — Mistral has not announced any enforcement action, licensing demand, or lawsuit against Cloudflare, Anthropic, OpenAI, HuggingFace, or any open-source project shipping this pattern. Software patents in agent tooling more often function as portfolio assets — leverage for cross-licensing or fundraising valuation — than as weapons actually fired in court, and that's the more likely near-term outcome here. But "more likely" isn't a guarantee, and any team with real commercial exposure in this exact architecture should get an actual IP opinion rather than inferring one from a patent number and a comment thread.
Related on explainx.ai
- Cloudflare Computer: agents need isolates, not just containers — the sandboxed execution model behind Cloudflare's own Code Mode pattern
- Cloudflare Kitesurf: agent-first browser in V8 isolates — same isolate family, applied to browsing
- Agent harness: DAG planner, worker, critic, budget pressure
- What is an agent harness? Complete guide
- What is loop engineering for AI agents?
- What is MCP? Model Context Protocol complete guide
- Mistral Shieldstral: 3B safety classifier — Mistral's other August 2026 release, for company context
Sources
- US Patent 12,670,045 B1, "Code implemented tool calls," USPTO — inventor Gabriel Vergnaud, assignee Mistral AI, filed March 4, 2026
- "CodeAct: Executable Code Actions Elicit Better LLM Agents" — arXiv:2402.01030, February 2024
- Cloudflare Blog — "Code Mode", September 26, 2025
- Cloudflare Blog — "Code Mode: MCP" follow-up, blog.cloudflare.com/code-mode-mcp/
- Anthropic Claude API docs — programmatic tool calling, platform.claude.com
- OpenAI developer docs — programmatic tool calling
- Hacker News — "Mistral Patent for 'Code implemented tool calls'" discussion thread (87 points, ~82 comments)
Patent claim text, filing dates, and prior-art dates in this post reflect information available as of publication (August 10, 2026). This post is journalism and technical explanation, not legal advice — whether this patent would survive a formal novelty or obviousness challenge is an open legal question that no court has yet decided. Consult a qualified IP attorney for guidance on any specific infringement concern.
