Building an agent harness? Keep file edits as their own tool
SummaryCode Mode lets an agent write code that calls your tools. Its coiner says file edits should stay separate. In our test, a code-mode style file write with missed escapes ran with exit 0 and silently broke a regex.
· MODEL Editors · 2 min read
Some links may be affiliate links. Disclosure

"Code Mode" is the idea that instead of handing an AI agent dozens of separate tools, you hand it one: run some code. The agent writes a short script that calls your APIs, chains the results, and prints only what it needs. Cloudflare's Kenton Varda and Sunil Pai described it in a September 26, 2025 Cloudflare blog post, which argued that "LLMs are better at writing code to call MCP, than at calling MCP directly."
On Monday evening, a developer post claiming Code Mode will replace tools like Read and Edit in every harness drew more than 110,000 views on X. On Tuesday morning Varda, who says he coined the name, replied with a caveat worth copying into your design notes: file read and edit are "still best provided as explicit tools."
His reasoning. If an agent has to edit files through code, the new file content has to go inside a string in that code, and strings need escaping. "Small / weak models struggle with this, and even frontier models still screw it up from time to time," he wrote. A plain tool call lets the model write the text without escaping it. He also pointed out that models are trained on specific edit formats: Claude on "replace string X with string Y," GPT on writing patches.
Both vendors' docs match that. Anthropic's text editor tool has a str_replace command with old_str and new_str fields. OpenAI's apply_patch tool has the model return file operations as V4A diffs that your code applies.
What we did. We wrote a 4-line Python file with a phone-number regex and a tab character in it. Then we wrote the same file two ways, the way a model in code mode would: as a Node.js script that calls writeFileSync with the content in a normal quoted string.
- Version 1 forgot to double the backslashes. Node ran it with exit code 0 and no warning. The file on disk had
^d{3}-d{4}$instead of^\d{3}-\d{4}$, and the regex no longer matched 555-1234. The\tturned into a raw tab, which happened to still work. - Version 2 escaped everything. It matched the original byte for byte, and needed 16 backslashes for 4 lines.
We also measured three real files from our own site's code. Written as a JSON-style string, they needed 54, 100 and 106 backslashes (29, 50 and 61 lines).
The tip. If you build or configure an agent harness:
- Use Code Mode for API calls with structured inputs, where it shines.
- Keep file reads and edits as dedicated tools.
- Give each model the edit format it was trained on:
str_replacestyle for Claude, patches for GPT. - After any agent edit, run the tests or a diff. Our broken write didn't throw an error. Exit code 0 told us nothing.
The catch. We did not run a model. Our test shows what a missed escape does, not how often a given model misses one. Varda's points about how models perceive tool calls are his view from building these systems, not a published benchmark.
Not sponsored. No affiliate links. Test files and scripts are from MODEL's own run on December 1, 2026.
Get three tested tools every Friday
Free, weekly. Unsubscribe anytime.
Sources
- Kenton Varda on file edits and Code Mode (X post, Dec 1 2026)
X
- Code Mode: the better way to use MCP
Cloudflare Blog
- Text editor tool
Anthropic (Claude Platform docs)
- Apply Patch
OpenAI API docs
Keep reading

We tested it
We tested the open-source App Store guard: it blocked 3 planted rejection risks, and an empty stub fooled it
A free scanner trending on GitHub promises to catch App Store and Google Play rejection causes before review. We planted three in a small iOS project. It caught all three in under a second. The catch: it checks code, not whether your features work.
· MODEL Editors

Google DeepMind
Google DeepMind's CellGemma predicts how cells react to drugs
Google DeepMind released CellGemma on Tuesday, an open Apache 2.0 model built on Gemma 4 E4B that predicts how human cells respond to drugs, immune signals and CRISPR edits, so researchers can screen thousands of options on a computer before the lab. It's for research only, not clinical use. Not tested by MODEL.
· MODEL Editors

Hot take
Hot take: a green AI security check is not proof your code is safe
Anthropic's Claude Security plugin now runs as a GitHub Action that reviews pull requests for vulnerabilities and can block the merge. Its own docs list when the check passes without a scan, and say a clean review is not proof of absence. Not tested by MODEL.
· MODEL Editors

OpenAI
Codex Cloud can now use a browser and a desktop to test your app
OpenAI says Codex can now use a browser and a desktop inside Codex Cloud to build and test features or reproduce bugs. You can watch it work, take over the mouse and keyboard, open a private preview link, or connect over SSH. Availability varies by task and workspace. Not tested by MODEL.
· MODEL Editors
FREE · EVERY WEEK
The top AI tools this week, tested.
Every week MODEL's editors pick the AI tools worth your time, try them hands-on, and tell you what's good, what's not, and who it's for. Free, in your inbox.
Free. Unsubscribe anytime. Our picks are editorial and can't be bought.