Teardown: how an AI coding agent is likely built
A coding agent likely combines a strong model with tools to search the repository, read files, edit files and run commands, a project instructions file it reads at the start, a loop that runs tests and feeds errors back to the model, context management that summarises or restarts when the window fills, and a permission system that asks before risky commands. Several of these are documented by the products themselves, and the rest is reasoned from how they behave.
Likely components
| Component | Role |
|---|---|
| Project instructions | Rules, architecture, commands (for example a CLAUDE.md) |
| Repo tools | Search, read, list files |
| Edit tools | Write or patch files |
| Execution | Run tests and commands in a terminal or sandbox |
| Loop | Plan, edit, run, read errors, repeat |
| Context management | Compaction, sub-tasks with fresh context |
| Permissions | Ask before destructive or external actions |
Loop
1 - Read the task and the instructions file. 2 - Search and read the relevant files. 3 - Plan the change. 4 - Edit files. 5 - Run tests or the build. 6 - Read the errors and go back to step 4, until tests pass or a step limit is reached.
The test results are what make this loop work: without a check the agent can run, it can only guess whether the change is right.
Context management
A repository doesn't fit in the context window, so the agent reads files on demand. In long sessions the context fills with old file contents and tool output, and earlier instructions get less attention, so agents summarise (compact) the history or hand sub-tasks to sub-agents with fresh context.
What you can observe yourself
- Results improve when the instructions file is clear and tasks are small.
- Long sessions drift as context fills, and a fresh session with the same files often does better.
- Agents sometimes pass tests in ways you didn't intend, so review the diff.
From the floor
I gave Claude Code the errors in my project and asked it to fix them and explain what went wrong, and it checked the files, made the changes, and got the agent running again, but as the context fills up, it can miss earlier instructions. So I give it smaller tasks, one component at a time, check what it changed and why, and run the earlier test cases again to make sure the other parts still work.
In the DevFix auto agent build, we built a small version of this loop ourselves with LangGraph: write code, run it, check for errors, fix them and repeat until the tests pass.