Why Code Is the Ideal Terrain for AI Agents
If agents shine anywhere, it's in code. The reason is simple and decisive: code returns an objective, immediate verdict.
- It compiles, or it doesn't.
- The tests pass, or they don't.
- The linter complains, or it doesn't.
No ambiguity, no judgement call. Unlike writing (is this text "good"?) or analysing a case (is this conclusion "right"?), code answers yes or no, and does so without needing a human to arbitrate. The agent can therefore check its own work unaided: try, observe the failure, fix, re-check. That short loop is why code agents are ahead.
An agent writing an email cannot know whether the email is any good. An agent writing code runs the tests and knows within the second. That is the whole difference: other agents need a human to find out they were wrong; this one does not.
The Pioneering Systems
Devin (Cognition, 2024)
Presented as the "first autonomous AI software engineer," Devin made an impression by showing an agent that takes a ticket and carries it to the end. It has a full environment (terminal, editor, web browser) draws up a plan and breaks the task into subtasks. Its 13.86% score started the race; the exact protocol behind that number is set out below, and it repays a look.
Claude Code (Anthropic)
A command-line tool (CLI) that turns the terminal into an assisted workbench. It has direct access to the file system and the terminal, and runs in a perceive-and-act loop: it reads files, writes code, runs a command, looks at what comes back, goes round again. That pattern has a name in the literature (ReAct, short for reasoning and acting) described in the ReAct pattern. It can also produce commits, run the tests and manage Git branches.
Cursor
A derivative of the VS Code editor that puts the model at the centre of the development environment:
- Completion as you type: suggestions informed by the current file and the rest of the project, this is the fill-in-the-middle technique explained in fill-in-the-middle
- Edit by instruction: select code and describe the change in plain English ("make this function async")
- Conversation over the whole repository, an index of which is built locally
- Coordinated edits across several files at once
- A choice among models from several providers, the exact lineup changing regularly
Vibe (Mistral)
A real code agent, described in detail in Vibe, and worth looking at for two traits that generic descriptions tend to skip.
Autonomy levels. The agent is not an all-or-nothing switch: you choose what it may do unasked and what requires explicit approval. That setting is not a convenience feature; it determines who decided what, and therefore, in a dispute, where responsibility lies.
Moving between terminal and cloud. One command, /teleport, transfers the running session from the terminal to a remote sandbox, preserving the history and the branch state: the task keeps running without the local machine staying on. It is a good illustration of what a code agent has become, no longer a program on a workstation, but a task that travels.

The Typical Architecture of a Code Agent
The Tools at Its Disposal
A good code agent has a complete toolbox:
- Files: read, write, modify a specific passage of a file
- Terminal: run commands, install dependencies, compile
- Search: find a string or a file in the repository, by name or by meaning
- Browser: consult documentation online
- Git: create a branch, record a change (a commit), open a merge request (a pull request, or PR)

The Development Loop
The agent follows an iterative cycle that closely resembles a human developer's:
- Understand: read the ticket or request, browse existing code to grasp how it is organised
- Plan: identify the files to modify, anticipate what the change breaks elsewhere
- Write: produce or modify the code
- Test: compile, run the tests, verify
- Go round again: if errors appear, read them and fix
- Conclude: record the changes, open the pull request, update documentation where needed

The quality of the code produced depends first on what the agent has understood about the project: how it is organised, its writing conventions, its dependencies, the ways of doing things already in use there. An agent that takes time to explore the repository before writing does far better than one that lunges at the keyboard.
Three Ways of Writing the Code, and a Fourth More Radical One
Whole file: the agent produces a complete file, starting from nothing. Suited to a new feature or a new module.
Targeted edit: the agent replaces a specific passage in an existing file. This is the mode for defect fixes and small adjustments.
Diff-based: instead of rewriting the file, the agent produces only the list of lines to remove and add, a patch, or diff. Two advantages: far less text to generate, so fewer tokens to pay for and fewer chances to break something elsewhere in the file; and a human can read the change itself rather than compare two whole versions.
The agent that writes code instead of tool calls. This is the Smolagents approach, at Hugging Face, and it is worth understanding because it changes the nature of the system. An ordinary agent, to use its tools, emits a structured description of the call it wants, a JSON object along the lines of "call the search tool with this parameter". Here the model writes Python code directly, which the program executes. A loop and a condition then take two lines, where otherwise you would chain a series of separate calls. It is more expressive, and it is also what makes sandboxed execution non-negotiable, since you are running code written by a model.
How These Agents Are Measured, and Why Reported Scores Need Care
SWE-bench
This is the reference exercise: fix real tickets drawn from real, widely used open-source projects (Django, scikit-learn, sympy). The agent receives a defect described in plain language plus the whole repository; it must find the files involved and produce a patch. The verdict comes not from a human but from the project's own test suite: it passes, or it does not.
This page gives no table of scores, and that is not an omission. There are two substantive reasons.
First reason: two rows of such a table almost never measure the same thing. SWE-bench exists in several versions (Full, Lite, Verified, Pro) which yield very different numbers for the same system. And each vendor reports its score with its own scaffold, its own step budget, its own way of counting attempts.
One example shows the scale of the problem. The most-cited figure in this benchmark's history is Devin's, in March 2024: 13.86%. Read Cognition's technical report and you find that this number is 79 tickets resolved out of 570, that is, out of a randomly drawn quarter of the test set, not the whole of it. And crucially: Devin worked without being told which files to edit, whereas the systems it was compared against were given that information. The figure is still interesting, but it does not line up row-for-row against the others. Without the protocol, it says nothing.
Second reason, and graver: this benchmark's credibility collapsed in February 2026. A significant share of the supposedly hard tasks rested on faulty or under-specified tests, with further signs of contamination, solutions present in the training data. An exam whose answer key contains errors does not produce a noisy ranking, it produces a wrong one.
The full story, with its dates and figures, is in agent evaluation and SWE-bench: the controversy. The list of questions to put to any reported score is in how to read a benchmark score.
SWE-bench: Can Language Models Resolve Real-World GitHub Issues? (Jimenez et al., 2023)HumanEval and MBPP
Two older and far simpler exercises: write one isolated function from its description. HumanEval is a set of 164 small Python programming problems built by OpenAI; MBPP, for Mostly Basic Python Problems, offers about a thousand of the same kind. They say nothing about moving around an existing repository, and they are saturated today: good models solve nearly all of them, which leaves them unable to separate anything.
None of them measures how the agent behaves in the face of hostile content. A code agent reads tickets, comments, configuration files, dependencies, third-party repositories, all texts written by strangers. That is precisely the channel for indirect prompt injection, covered in tool use and orchestration.
The mechanism, in one sentence: a sentence planted in a file the agent will read is indistinguishable, to the agent, from an instruction from its user. A code agent is the most exposed case there is, because it holds the terminal, the network and write permissions. An excellent SWE-bench score says nothing about that risk.
The Remaining Challenges
Scale. An industrial repository runs to hundreds of thousands of lines, while a model's context window, however large, holds a fraction of that. The agent therefore cannot read everything: it must move by probing, following filenames, dependencies and search results the way an investigator follows leads.
Silent regressions. A reliable agent does not merely write code, it also writes and runs tests. Without them the code "looks right", survives review, and breaks something elsewhere, the most expensive failure mode there is, because nothing announces it.
Security, on two levels. The first is obvious: handing the terminal and the file system to a program that improvises creates risk, hence execution in a sandbox (an isolated environment, usually a container, where the agent can break whatever it likes without touching the real machine) and restricted permissions. The second is less known and more insidious: the content the agent reads may be hostile. See the warning above and tool use and orchestration.
Even the best agents regularly produce code that is wrong, needlessly convoluted, or at odds with the project's habits. Human review stays necessary, especially for code headed to production. Agents speed up the work; they do not replace judgement.
What This Changes for Someone Examining an Invention
Three observations, more useful here than a prediction about what comes next.
The invention is rarely in the model. The preceding sections show it: what separates one code agent from another is the scaffolding around the model, the toolset offered, the form in which results come back to it (the central idea of the SWE-agent paper), the repository search strategy, sandbox management, the stopping points for human approval. That is where the real differences live, and where to look to understand why one agent beats another.
The degree of autonomy is a legal fact, not an ergonomic setting. An agent that proposes a patch and an agent that merges a branch itself do not engage the same responsibilities. Autonomy levels, execution logs and approval checkpoints are the evidence of who decided what, see Vibe.
Code provenance becomes a question in its own right. An agent opening pull requests autonomously produces code whose origin must be traceable, all the more so when the repository mixes dependencies under different licences.
On present capability, only one thing is solidly established: agents now fix real defects in real projects, and tasks requiring an architectural decision (restructuring a system, choosing how to organise code, migrating from one library to another) still largely escape them. Numerical comparisons between agents call for the caution set out above.
1. Why are code agents ahead of writing or analysis agents?
2. Devin's founding score (13.86% on SWE-bench in 2024) is the most quoted in the benchmark's history. What do you discover by reading the technical report?
3. A Smolagents agent writes Python code instead of producing JSON tool-call descriptions. What does that change?
4. A code agent posts an excellent SWE-bench score. What do we know about its resistance to a hostile sentence planted in a ticket it reads?
5. What really separates one code agent from another, according to the page?