Why AI Coding Agents Need Better Context, Not Bigger Models

Why AI Coding Agents Need Better Context, Not Bigger Models

An agent can be capable of changing code and still get stuck before it reaches the code that matters. In a large repository, the hard part is often discovering where the relevant knowledge lives: in a service, a past decision, an incident, a deployment note or someone’s memory. The agent may search widely, miss the important detail and confidently build on an outdated assumption.

My view is that this is often a context problem before it is a model problem. A stronger model cannot reliably use knowledge it has not found. Context engineering — deciding what an agent should know, where that knowledge lives and when it should be retrieved — is becoming a core engineering discipline.

Why code search is not enough

Repositories contain clues, but organisational knowledge is spread across more than source files. A service boundary might be explained in an architecture decision. A convention may have been established after a production issue. A change that looks redundant may be necessary because another service depends on it.

When an agent starts by searching the filesystem, it has to work out which clues matter while also trying to solve the task. That can mean repeated searches, reading unrelated files or treating an old comment as current guidance. The result is not always an obvious failure. It may be a plausible change that ignores a constraint the team already learned the hard way.

The practical question for a team is therefore not simply, “Which model should we use?” It is also, “Can the agent retrieve the relevant, current knowledge before it starts exploring?” Better context can reduce unnecessary rediscovery and make an agent’s work easier to inspect. It does not make the agent infallible; it gives it a better starting point.

Make memory available before exploration

At Presence Digital, our approach through LocalMinds is MindGraph: a local-first memory graph for agents. It stores what a team has already learned — such as architecture decisions, gotchas and conventions — as connected memories, decisions, entities and relationships. Its guiding idea is simple: every agent should ask memory before asking the filesystem.

MindGraph is not an automatic record of every incident, pull request, deployment or dataset. A team needs to decide what is worth preserving and add that knowledge. The graph can then help an agent retrieve relevant context, resolve beliefs that have been superseded, and suggest files to read before it begins searching the repository.

Retrieval combines keyword search, optional embeddings and typed graph relationships such as mentions, supersedes and related_to. The result includes a summary for the prompt and file hints. Supersedes chains retain the history of earlier knowledge rather than silently overwriting it, which matters when a team needs to understand why guidance changed.

The memory lives in a .mindgraph/ store in the repository. It is local-first and can be shared through git: teammates pull the repository and run mindgraph sync. That keeps knowledge portable, mergeable and private within the repo, rather than making a separate hosted service the only place the team can find it.

A practical way to introduce context engineering

Start with a repository the team knows well. The aim is not to map everything; it is to make a small body of trusted knowledge retrievable and test whether it changes how an agent approaches real work.

  1. Choose a recurring point of confusion. Pick a task where agents or new team members often need the same explanation, such as how authentication flows through a service or which files define a boundary. Avoid trying to capture every system and historical detail at once.

  2. Write down durable knowledge. Record the decision, convention or gotcha in a form the team can check. Include the reason where it will help, and identify relevant files. Keep transient observations out unless they are likely to matter again.

  3. Set up retrieval before file exploration. Install the package with npm install @localminds/mindgraph, then initialise it with npx mindgraph init. MindGraph also provides an MCP server, a CLI and a library API. Its MCP setup command is npx mindgraph mcp install, so an agent can call memory_retrieve before reading or searching files.

  4. Try retrieval on a real task and review the result. With the library, open the graph using MindGraph.open({ root: process.cwd() }), then call retrieve({ query: 'How does authentication work?' }). The response includes summaryForPrompt and fileHints. Check whether those hints point to the right material, and correct or add knowledge when they do not.

  5. Keep useful learning current. During a session, an agent or developer might observe: “Auth middleware must run before tenant context.” Persist that learning when the session ends, then review whether it is durable and accurate. The CLI equivalents are mindgraph retrieve, mindgraph observe and mindgraph consolidate. Treat consolidation as a chance to keep the memory useful, not as permission to store every observation.

Who should act now — and what to watch

This is worth exploring if your team repeatedly explains the same architectural decisions, if agents spend too much effort locating relevant files, or if knowledge is lost when work moves between people. A small, well-understood repository is a sensible place to learn whether structured memory helps.

Wait if the codebase is changing so quickly that nobody can tell which guidance is current, or if the team has not agreed how knowledge should be reviewed. A graph can make stale assumptions easier to retrieve as well as useful facts. Superseded history helps preserve change, but people still need to record and maintain the knowledge responsibly.

MindGraph is open source under the MIT licence and available as @localminds/mindgraph. It is a local knowledge graph for durable, structured facts about a codebase, not a substitute for sound tests, code review or clear ownership. The useful measure is not how much information you have stored; it is whether the agent gets the right context before it starts searching.

Try the package on a repository you know well, or get in touch with Presence Digital if you want help giving your agents better context. For operators and builders, the takeaway is simple: make the team’s hard-won knowledge easy to ask for before asking the agent to explore.

// Share this post

Newsletter

New articles, in your inbox

One email when we publish. No digests and no product pitches. Unsubscribe any time. Privacy policy