Ai · Technology

I Built My Own Coding Agent.

I wanted better memory management built in, not bolted on.

I use coding agents all day, and I kept running into two walls. The first was memory. A session fills up, the tool summarizes or truncates, and the thing you needed from forty minutes ago is gone. The second was the model: I wanted to move between models freely without losing the thread. So a few months ago I wrote a spec and asked my orchestration platform to assist me in building a coding agent to start exploring my ideas.

The model half of the idea had its own root. I had already built my own interface to the agents (Claude Code, Codex and the rest) so that I can switch between them on the fly and I wanted the agent itself to do the same with the model, without hurting how well it works while it switches. The thought being instead of having to switch agents to use a better model for the task, you could maintain a single conversation and the agent activates the correct model for the task.

What I built

The agent is a command-line tool with the usual parts: a tool loop, file and shell tools, sub-agents, slash commands, and support for MCP servers. The part I cared about is underneath, a three-tier memory substrate that was designed in from day one rather than bolted on later.

The design came from thinking about how people work: how our brains take in information, hold some of it close, push the rest away and still pull it back when something reminds us. Think of how you answer a question: a quick first reply, then a more detailed and sometimes corrective one once your brain has switched context to the topic and loaded the relevant memories. I wanted an agent that works the same way. I started sketching a memory system on those ideas, and the current iteration is the three-tier system, built as a core component rather than an add-on.

  • Tier 1 is a bulk store. Large or rarely used material lives in a shared vector-and-metadata service. The agent keeps summaries and pointers in its working context and fetches the full content only when it needs it.
  • Tier 2 is temporal working memory. Context is scored for eviction by recency, how often it is touched, and how close it sits to a retrieval anchor. When something is evicted it can be promoted into Tier 1 instead of dropped.
  • Tier 3 is a fast path. An exact match, then a fuzzy match, then embedding similarity, with a confidence score that decides whether to fall back to the slower tiers.

In practice, when a long tool loop gets big, older history spills to Tier 2 and the agent is left a note saying what was spilled and a tool called resolve_context reads it back when needed. Now, the tradeoff every session-scoped agent has to make (summarize, truncate, or forget) becomes a system behavior and process instead of a loss.

What the evals show

Memory tiers. On two long-context tasks with kimi-k3, runs with the tiers on passed 8 of 9 and runs with the tiers off passed 5 of 9. Where history actually spilled, it was 3 of 4 against 1 of 5. That is a good direction and it met the bar I set before running it. It is also nine runs per arm, one model, two synthetic tasks, and a significance level (Fisher p of about 0.3) that does not support a strong claim. I call it directional, nothing more.

The failures were more interesting than the passes. In one batch the model spilled its history and then never went back to read it. When the steps it needed were gone from view, it filled in a plausible name instead of fetching the real one. Changing the spill note so it names what was spilled raised read-backs from none to some. That is a model-behavior problem as much as a retrieval one, and it is the thing I am still working on.

Head-to-head. I ran nine standard tasks across five setups: my agent with kimi-k3, my agent on Claude’s Agent SDK with Opus, Claude Code with Opus, Codex, and OpenCode with kimi-k3. In the first run every arm passed the same eight tasks and failed the same one. When I looked, the failure was not the tools. My verifier required a string to be absent from the README while the task asked the agent to keep the README accurate, and the agent had correctly documented the old field name there. I fixed the verifier and reran, and all five arms passed 9 of 9.

Harder tasks. I retuned a set of tasks to be harder and ran kimi-k3 on five of them: four passed, and a cross-module refactor failed. One failure out of five is a signal, not a measurement, but it is the first result that separates anything, and it is where the next round of work starts.

Along the way the eval work caught several of my own mistakes: a task whose answer leaked into the prompt, a verifier pinned too tightly, and a harness that was scoring infrastructure failures as model failures. Each one would have produced a confident, wrong headline. The self-checking harness exists because I kept making these.

Where it goes from here

There’s still work to do if I want to reach parity of other features other agents have but my primary focus is continuing to improve the memory and context handling, especially across models.

If you have any ideas, or want to talk building an agent for you or your company, get in touch!

This is the thinking. Want to see it applied to your problem? Weft & Whetstone (opens in new tab)

← All thoughts