Anatomy of a Coding Agent: Aider
In a previous post, I explained how the opencode coding agent works. In this post, I give an overview of aider, another open-source coding agent that uses different architectural choices. The objective is to look at some differences in the overall architecture of two coding agents. I will skip the introduction part about agents (you can read the previous post for that) and go directly in what differentiates aider.
General Design Choices
Aider is developed in Python, which is the language of choice when it comes to write ML applications. Where opencode uses the Vercel AI SDK, aider relies on the Python litellm to stay platform agnostic. Like opencode, it can interface with many models, either remote or local (if you use ollama).
A good entry point is the base_coder.py file that contains the main iteration loop. The file models.py contains the code that initialize the models (along with the tools).
Multiple Modes, Multiple Agents
Aider provides multiple modes, each of them has its own prompts and set of tools. For each mode, there is a new agent, built around a new prompt.
These agents have the same capacity (e.g. tools), the main difference is the initial prompt passed to them.
Code Indexing
Coding agents index your code incrementally. When you open a repository for the first time, the agent indexes the entire codebase and updates the index incrementally upon code changes. Aider supports all languages supported by the tree-sitter-language-pack, a collection of well-maintained tree-sitter grammars.
Aider indexes the code through a Repository Map, where it extracts symbols (also known as tags) definition (class or function/method definition) and reference (e.g. there the symbols are being used). This is implemented through tree-sitter queries that run queries (example of queries for Java) against each file. It qualifies the type of tag based on the name associated with the query.
This information is then saved in a SQLite database to make it available at the next execution and easily query it. The SQLite database is abstracted by the diskcache library.
Prompt Building
The prompt itself is built using some base strings (as shown in ask_prompts.py or architect_prompts.py). Then, the prompt is augmented with the code structure, which comes from the code index (aka repomap in the aider terminology). The enrichment logic resides in the repomap.py file and it attempts to pack the most information in the number of tokens available by ranking the data.
The code index sent to the prompt contains the class and function definition signatures. It’s enough to understand the structure of the code but it does not contains any information about the implementation of the function itself.
Comparing opencode and aider
The goal is not to compare the performance of the tools but the commonalities in the architecture. This gives you trends about what to use to build a coding agent and what may make a difference.
Common Patterns
Both use a high-level library (AI SDK or litellm) to stay LLM provider-agnostic
Both specialize their prompt for a particular task
Differences
opencode augment the LLM calls with tools to understand the codebase better. aider relies on its repository map to feed the architecture of the software to the LLM
opencode does not need explicit files, it finds what artifacts matters using tools (like grep)
opencode keeps a tool that manages the todo list to keep track of what to do to accomplish a task. Other tools like Claude Code or Gemini follows a similar approach.

