Skip to content
Data McFly.
Back to writing

writing

The Context Layer: Why Your Agent Keeps Getting It Wrong

Jun 23, 2026 · 3 min read · Roger Stringer

Most of the time an agent "gets it wrong," it didn't reason badly. It answered correctly based on what it could see, and what it could see was incomplete. The fix isn't a smarter model or a cleverer prompt. It's a better context layer.

The context layer is the part of an AI system that decides what information the model gets to see, and when. It's the least glamorous component and the one that most determines whether the thing works. If you've ever wondered why your agent nails one question and faceplants on the next that looks almost identical, the answer is almost always in here.

What the context layer actually is

When a person does a task, they pull context from everywhere without thinking about it: what they remember, the doc they have open, the Slack thread from this morning, the unwritten rule that this customer gets special handling. A model has none of that unless you give it. The context layer is the machinery that assembles the right information for each request and hands it over.

It's a few things working together: the instructions and rules the agent always operates under, the relevant data fetched fresh for this specific task, the examples that show what good looks like, and the memory of what's happened before. Get the mix right and the model looks brilliant. Get it wrong and the same model looks careless.

Why the same agent succeeds and fails

Say you've got an agent answering customer questions. Ask it about a common feature and it's perfect, because the help docs cover it well and the context layer pulls the right page. Ask it about an edge case in your pricing and it stumbles, because that rule lives only in a sales playbook the context layer doesn't reach.

Same model. Same prompt structure. The difference is entirely what the context layer could put in front of it. The agent didn't get dumber between the two questions. Its information did.

Building a context layer that holds up

A few principles separate a context layer that works from one that flakes.

Pull the right thing, not everything. Dumping your entire knowledge base into the prompt isn't context, it's noise, and it makes the model worse, not better. The skill is fetching the specific, relevant pieces for this task.

Keep it fresh and authoritative. The context layer should point at the current source of truth, not a stale copy. If your policies changed last week, the agent should be reading last week's version, not a snapshot from a year ago.

Shape it for the model. Clean, structured, consistent information beats a pile of raw documents. The work of getting data into the right shape is most of the work, and it pays off on every single request.

Decide what it can't see. Boundaries are part of context too. An agent that shouldn't touch certain data needs that enforced here, not hoped for.

This is where the work lives

If your AI has a data problem, not a model problem, the context layer is where you fix it. It's the practical machinery of the 30% in the 70/30 Method: the senior, unglamorous work of getting the right information, in the right shape, in front of the model at the right moment. The model is the easy part. This is the part that decides whether you have a demo or a system.

Designing a context layer that stays accurate as your business changes is core to the Agentic OS work I do with clients. If your agent keeps getting things wrong in ways a bigger model won't fix, this is where to look. Let's talk.