On this page
- The seven repos
- The seven side by side
- How do coding agents find code?
- How do agents build the system prompt?
- DeepSeek Harness puts instructions in the session history
- Hermes Agent and OmO freeze memory at session start
- How do agents trim the context window?
- Hermes Agent compacts earlier than most
- DeepSeek Harness waits, then spills
- OpenClaw clears old tool results
- pi keeps compaction short
- free-claude-code cuts down requests
- Which agent do the others build on? pi
- What happened to the giant agent-loop functions?
- What does grep not answer? Where repowise fits
- How we measured
- FAQ
AI coding agents find context with grep, find and read, not with a code index. We read the context code of seven open-source agent repos (as of 6 October 2026), and none of them builds a searchable index of your code by default. Where they differ is what they throw away: most of the context code in these repos decides what the model stops reading, and when.
That is a useful result for anyone choosing or building an agent. A lot of public talk about agents is about retrieval: embeddings, code graphs, repo maps. In these seven codebases the code that decides what the model reads is small. The code that decides what it forgets is large.
Each section names the files involved, so you can check the reading yourself.
The seven repos
These are agent repos already indexed at repowise, in three kinds of project.
Full agent harnesses. A harness runs the loop: send messages to the model, run the tools it asks for, feed the results back, repeat.
- pi (earendil-works/pi): a coding agent CLI plus the libraries under it (an LLM API layer, an agent loop, a terminal UI).
- DeepSeek Harness (deepseek-ai/deepseek-harness): a harness where every feature is a plugin, built on the Cordis plugin framework.
General assistants that also code. Personal assistant agents that connect to chat apps, run scheduled jobs and browse the web. Coding is one of many jobs.
- OpenClaw (openclaw/openclaw)
- Hermes Agent (nousresearch/hermes-agent)
Layers on top of someone else's agent.
- OmO (code-yeongyu/oh-my-openagent): plugins and agents for OpenCode and Codex, and since version 5.0 its own CLI on "senpi", which its README describes as a fork of pi.
- free-claude-code (alishahryar1/free-claude-code): a proxy between a coding agent (Claude Code, Codex, pi and eight others) and the model provider, routing requests to other models.
- Claude Code's public repo (anthropics/claude-code): the agent's core is not in this repo. It holds 13 plugins, examples and the source of four built-in "mods", which are plugins that hook the engine's events. For Claude Code we can only describe the parts it exposes.
Codex CLI, Gemini CLI, OpenCode, Aider, Cline and OpenHands are not here because we had not indexed them, and we only write about code we have read.
The seven side by side
| Repo | What it is | Files | Lines of code | Finds code with | Shrinks context by |
|---|---|---|---|---|---|
| pi | Coding harness | 2,010 | 379k | read, bash; grep, find, ls optional | Summary when under 16,384 tokens left; keeps last 20,000 |
| DeepSeek Harness | Plugin harness | 12,578 | 899k | read, glob, grep, bash; LSP tool optional | Summary at 80% of window; keeps 16% |
| OpenClaw | Assistant | 19,361 | 4.36M | read, ls, shell (ripgrep, fd) | Caps tool output, clears old results, summary |
| Hermes Agent | Assistant | 8,758 | 2.12M | read_file, search_files (ripgrep), terminal | Summary by a cheaper model at 50% of window on large-window models, 75% under 512K |
| OmO | Layer | 5,591 | 591k | Host agent's tools plus LSP and ast-grep servers | Host agent's compaction; frozen memory block |
| free-claude-code | Proxy | 744 | 168k | Not its job | Answers some side requests locally; optional output filter |
| Claude Code (public repo) | Plugins and mods | 1,124 | 26k | Not in this repo | Not in this repo |
Scroll the table sideways to see every column.
Files and lines come from our latest index of each repo (non-blank, non-comment lines), dated between 26 June and 30 September 2026 depending on the repo. The size range says how much code an open agent grows once it must talk to chat apps, browsers, schedulers and dozens of model providers: OpenClaw is about 167 times the size of Claude Code's public repo, and its coding part is a small corner.
How do coding agents find code?
They give the model the same kit a person has in a terminal: read a file, list a directory, search contents, run a shell command. Every repo here that runs its own loop, plus OmO, works this way.
- pi ships four tools by default:
read,bash,editandwrite.grep,findandlsexist inpackages/coding-agent/src/core/tools/and can be switched on. The default system prompt insystem-prompt.tslists[read, bash, edit, write], so the model searches through the shell. - DeepSeek Harness has
read,writeandeditin itstool-fspackage andglobandgrepintool-fs-search. Atool-lsppackage lets the model jump to definitions and find references through a language server, the machinery behind your editor's "go to definition". Its README says to use it "when textual search is ambiguous" and that "ordinary navigation should continue to usesearchandread". It is not in the default bundle. - OpenClaw builds its file tools in
src/agents/core-coding-tools.ts: read, ls, edit, write, apply_patch and a shell. We found no dedicated grep tool in the main runner.src/agents/utils/tools-manager.tsdownloads pinned copies of ripgrep and fd, so search goes through the shell. - Hermes Agent has
search_files, backed by ripgrep intools/file_operations_search.py, next toread_fileandterminal. - OmO adds structure on top of its host agent: a shared language server daemon (
packages/lsp-daemon), LSP and ast-grep tools exposed as MCP servers, and "hashline" edits, where the model points at a line by a short hash of its content instead of a line number. Its Codex plugin once started a background CodeGraph index at session start; that component is gone, and the current config migration drops the oldcodegraphsetting as retired.
The pattern is a deliberate bet: models have become good at grep, a grep result is always fresh, and an index is one more thing that can be stale or broken on a user's machine. For finding a function by name, grep is enough. Questions like "what breaks if I change this" are different, because the answer is spread across files that never mention each other by name. That is where a graph helps, and we come back to it below.
How do agents build the system prompt?
Every agent loads the project's instruction file before the user types anything. pi's resource-loader.ts looks for AGENTS.override.md, AGENTS.md and CLAUDE.md. DeepSeek Harness has an agent-instructions plugin that loads AGENTS.md or CLAUDE.md and reloads them after the agent edits a file. OmO has agents-md-core and a rules-engine package for nested instruction files. Claude Code's public repo includes the source of its agents-md mod, which hands AGENTS.md files to the engine like CLAUDE.md, and attaches nested ones when the model reads a file in that folder.
Two designs stand out.
DeepSeek Harness puts instructions in the session history
The context package README says injected instructions and references "enter session history as user-role messages, so they persist, replay, and compact like other conversation content". A change to AGENTS.md mid-session therefore does not rewrite the system prompt.
Hermes Agent and OmO freeze memory at session start
Hermes keeps two memory files, MEMORY.md (agent notes) and USER.md (a profile of the user). The docstring in tools/memory_tool.py says both enter the system prompt "as a FROZEN snapshot at session start; mid-session writes hit disk but never change the prompt". OmO's changelog describes the same fix: a memory commit during a session no longer rewrites that session's system prompt.
Both teams are protecting the prompt cache. Providers charge less for a prompt prefix they have seen before, and changing one byte near the top loses the whole cache. A surprising amount of context code exists to keep the top of the prompt byte-for-byte stable.
How do agents trim the context window?
Agents trim in two ways: they cap each tool result as it arrives, and they compact, replacing older turns with a model-written summary when the conversation nears the model's limit. This is where most of their context code lives.
| Repo | Per-result cap | Compaction trigger | What it keeps |
|---|---|---|---|
| pi | 2,000 lines or 50 KB; grep lines cut at 500 chars | Fewer than 16,384 tokens left | The last ~20,000 tokens |
| OpenClaw | 16,000 chars by default, 32,000 above 100k-token windows, 64,000 above 200k; tool output capped at 30% of the window | Reserve capped at 25% of the window; up to 3 overflow retries | Agent core defaults: 16,384 reserve, last 20,000 tokens |
| Hermes Agent | read_file 100,000 chars | 50% of the window on large-window models, 75% under 512K | First 3 and last 20 messages; middle summarised |
| DeepSeek Harness | Oversized results pruned first; optional "spill" to disk | 80% of the window | About 16% of the window |
Scroll the table sideways to see every column.
Hermes Agent compacts earlier than most
Its default trigger is 50% of the window on models with 512K tokens or more, and 75% on smaller windows. The code comment explains the floor: on a small window, compacting at 50% frees so little room that it would fire every turn or two. On a large window that is much sooner than DeepSeek Harness (80%) or pi (16,384 tokens left, about 97% of a 512K window). It writes the summary with a separate, cheaper auxiliary model and prunes big tool outputs first (agent/context_compressor.py). The cost is a summary call more often; the gain is that the model rarely works with a nearly full window. For an assistant that runs long sessions over days, that is a sensible trade.
DeepSeek Harness waits, then spills
It compacts at 80% and keeps about 16%. Its spill packages can also move a large tool result out of the context entirely: the full text goes to a file and the model gets a short pointer with instructions on how to read more, like saving a long log to disk instead of pasting it into a chat.
OpenClaw clears old tool results
Besides capping each result, src/agents/embedded-agent-runner/tool-result-truncation.ts replaces tool output that has outlived the prompt cache window with [Old tool result content cleared], and old images with [image removed during context pruning]. The model keeps the record that it ran the tool but loses the bytes.
pi keeps compaction short
pi's whole compaction logic is in packages/coding-agent/src/core/compaction/compaction.ts: compact when the context is within 16,384 tokens of the limit, keep the most recent ~20,000 tokens, summarise everything before that. It is the easiest of the four to read in one sitting.
free-claude-code cuts down requests
As a proxy, free-claude-code never sees a repo directly, but src/free_claude_code/api/optimization_handlers.py answers five kinds of side request from Claude Code locally without calling a model: quota checks, command-prefix detection, title generation, suggestions and file-path extraction. Its README also offers an optional filter that shortens terminal output before the model sees it.
Which agent do the others build on? pi
pi is one of the smaller repos in the set (379k lines), yet it shows up inside three others.
- OpenClaw depends on
@earendil-works/pi-tuiin itspackage.json. Itspackages/agent-corehas the same compaction file names as pi (compaction.ts,branch-summarization.ts) and the same defaults: 16,384 reserve tokens and 20,000 recent tokens. Itstruncate.tshas pi's exact limits (2,000 lines, 50 KB, 500 characters per grep line), and it reserves the tool namesbash, edit, find, grep, ls, read, write, which is pi's tool list. The code shows that OpenClaw's agent core shares pi's design and numbers; the history behind that is not in the repo. - OmO says in its README that version 5 "runs on senpi, our fork of pi".
- DeepSeek Harness has a
dsh-llm-pi-aipackage that adapts pi's model API library. Its description calls it a "design-verification twin" of the main DeepSeek adapter, so it is not the default path.
If you want to learn how a coding agent's loop works from source, pi is the place to start: it is small enough to read, and larger agents reuse its choices.
What happened to the giant agent-loop functions?
Agent loops grow into very large functions, and the two longest in this set have since been split. When we indexed these repos, Hermes Agent's run_conversation in agent/conversation_loop.py was 6,591 lines (index of 19 August) and OpenClaw's runEmbeddedAttempt in src/agents/embedded-agent-runner/run/attempt.ts was 4,972 lines (index of 26 June). The loop is the first thing you write and the place every retry rule, provider quirk and recovery path lands, so it gets big fast.
Both teams have since refactored. On 6 October, Hermes's conversation_loop.py is 1,835 lines, down from 8,298 at our index, and run_conversation is a short wrapper around _run_conversation_turn. OpenClaw's attempt.ts is 567 lines, down from 5,808, and the run/ folder next to it went from 65 non-test files to 173, with names like attempt-prompt-build.ts, attempt-history-prepare.ts and attempt-tool-search-executor.ts.
What does grep not answer? Where repowise fits
Disclosure: we build repowise. Grep answers "where is this name". It does not answer "what depends on this" or "why is it shaped like this". Those need the dependency graph and the history, and an agent can fetch them over MCP, the standard way for agents to call outside tools, without giving up its grep loop.
repowise indexes a repository's dependency graph, git history and decisions, and serves them through ten MCP tools. Four groups map directly onto the gaps above:
| Question grep cannot answer | repowise MCP tool |
|---|---|
| Where is this symbol defined, and who calls it? | get_context with include=["references"], get_symbol |
| Find a name or a concept across the repo | search_codebase |
| How does this part work, in one cited answer? | get_answer |
| What is risky about this change? Why was it built this way? | get_risk, get_change_risk, get_why |
Scroll the table sideways to see every column.
Because the tools return compact, cited answers, a single call can replace several greps and file reads, which means fewer tool results competing for the window. Setup is repowise init, which registers the server with Claude Code, and repowise mcp for other clients. See the MCP tools reference, the ai-context feature page and the architecture pages of the repos above.
How we measured
- Repos: the seven agent repos already indexed at repowise. No repos were indexed for this post.
- Numbers: files, lines of code and longest functions come from each repo's latest ready snapshot, read on 6 October 2026. Snapshot dates: pi 30 Sep, DeepSeek Harness 28 Sep, Claude Code 27 Sep, free-claude-code 19 Sep, Hermes Agent 19 Aug, OmO 17 Jul, OpenClaw 26 Jun.
- Code reading: shallow clones of each repo's default branch on 6 October 2026, plus files fetched at the indexed commits for the before-and-after comparisons. Every file path in this post is from those clones.
- Scope: we read code and did not run benchmarks, so this post does not say whether early or late compaction gives better results. Defaults are quoted as shipped; users and some repos change them per model.
If you maintain one of these repos and something here is wrong, tell us and we will fix it.
FAQ
- Do AI coding agents use a code index or embeddings?
- Not by default. In the seven open-source agents we read, every one finds code with grep, find and read. OmO once started a background code index in its Codex plugin and has since removed it, and DeepSeek Harness offers an optional language-server tool.
- When do coding agents compact the context window?
- It varies by agent. Hermes Agent summarises at 50% of the window on models with 512K tokens or more and 75% on smaller ones, DeepSeek Harness at 80%, and pi when fewer than 16,384 tokens remain.
- What is context compaction?
- Compaction replaces older turns of a conversation with a summary written by a model, so the session can continue after the window fills. Agents usually keep the most recent turns verbatim and cap each tool result before it enters the history.
- Why do agents keep the top of the prompt unchanged?
- Providers cache a prompt prefix and bill cached tokens at a lower rate, but any change near the top invalidates the cache. Hermes Agent and OmO freeze memory at session start for this reason.
- Can I add a code graph to a grep-based agent?
- Yes. Any agent that speaks MCP can call a server such as repowise alongside its normal tools, and use it for callers, blast radius and history while grep handles name lookups.



