ProjekinAja. Agentic AI Stage 3 · Working With Agents Lesson 3.3
● Stage 3 · Lesson 3.3

Context Engineering

The brief tells the agent what to do. Context engineering is about giving it exactly the right information to do it — no more, no less.

⏱ ~14 min read 🎒 The information environment 📡 Signal vs noise

🎯 By the end you'll understand

What "context engineering" really means, why both too little and too much context hurt an agent, the concrete techniques for curating the right information (relevant docs, summaries, examples, pointers to retrieve), why order matters, and how to keep an agent's context clean across a long task. The mindset: you are the agent's information environment.

KEY INSIGHTThe one idea to take away

An agent is only as good as what it can see. Context engineering is the craft of deciding what it gets to see — and what it doesn't.

In Lesson 3.2 you learned to write a sharp brief: a clear goal and clear constraints. But a brief is instructions. Context engineering is the other half of the job — the information the agent needs to follow those instructions. Get this wrong and even a perfect brief produces garbage, because the agent is reasoning over the wrong material.

🔑 Hold onto this

The agent doesn't know anything you haven't put in front of it. Its entire world for this task is its context window (Lesson 2.3). Context engineering is deliberately curating what fills that window: the right files, data, examples, and prior results — and deliberately leaving out the noise.

DEFINITIONWhat context engineering actually is

Back in Lesson 2.3 we said the context window is the agent's working memory — everything it can "see" at this moment: your message, the system prompt, prior steps, tool results, files you pasted. It's finite, and once it's full, older or buried material stops doing much work.

Context engineering is what you do with that finite space. It's the deliberate act of choosing what goes in:

And — just as importantly — it's choosing what to leave out: stale notes, contradictory drafts, the 9,000 lines of code that have nothing to do with the bug.

📖 Context engineering

The practice of deliberately curating the information an agent has in its context window for a task — including the right material, excluding the noise, and arranging it so the most important things are most prominent. If prompting is what you say, context engineering is what you let the agent see.

People used to call all of this "prompt engineering," but that name undersells it. Wording the request is one small part. The bigger lever — especially for agents that run many steps — is the information environment you build around them. That's why the field quietly renamed it.

CORE CONCEPTThe core tension: signal vs noise

Here's the trap that catches almost everyone. There are two ways to ruin an agent's context, and they pull in opposite directions.

Too little context → the agent doesn't have what it needs, so it guesses. It invents a function that doesn't exist, assumes a file structure that isn't there, or hallucinates a fact. Underfed agents fill the gaps with plausible fiction.

Too much context → counterintuitively, this is just as bad. Dump everything in "to be safe" and three things go wrong at once: the agent gets distracted by irrelevant material, every step costs more and runs slower, and — critically — the important instructions get buried. Remember "lost in the middle" from Lesson 2.3? Models pay most attention to the start and end of their context; cram in 40 pages and your one crucial sentence drowns in the middle.

📡 Signal vs noise

Every item you add is either signal (it helps the agent reach the goal) or noise (it distracts, dilutes, or buries the signal). Good context engineering maximizes signal and ruthlessly cuts noise. More information is not more help.

The mental image to keep: context is a spotlight, not a warehouse. A warehouse holds everything; a spotlight points at the one thing that matters right now. Your job is to aim the spotlight.

Notice that this tension has no "just turn it up" escape hatch. You can't fix an under-fed agent by dumping in more, and you can't fix a bloated one by yanking everything out. The skill is judgment about which specific pieces are signal for this task — and that judgment is exactly what you'll practice in the widget below. Bigger context windows (millions of tokens now) don't dissolve the problem either: a model that can read a million tokens still reasons best over a few thousand well-chosen ones. Capacity is not the same as attention.

If context is…What happensThe failure
Too thin (under-fed)agent fills gaps with assumptionsguessing & hallucination
Lean & relevantagent reasons over exactly what matters— this is the goal —
Too bloated (over-fed)signal buried, attention scattered, cost updistraction & "lost in the middle"

PRACTICALThe techniques that actually work

Curating context isn't guesswork. There's a small toolkit you'll use again and again:

📄

Give the relevant section, not the whole document

The agent needs the API's auth chapter, not the entire 200-page manual. Slice down to the part that matters.

✂️

Summarize long material

A tight summary of a meeting transcript or a long thread often carries more usable signal than the raw text — and a fraction of the tokens.

🎯

Provide examples of the desired output

One or two concrete examples of the format you want beats three paragraphs describing it. Show, don't only tell.

🔎

Point to where info lives — let it retrieve

Instead of pasting everything, give the agent a way to fetch what it needs on demand. That's retrieval / RAG from Lesson 2.4 — the agent pulls in the right snippet only when relevant.

🧹

Remove stale & contradictory info

An outdated spec or two conflicting drafts will actively mislead the agent. Conflicting context is worse than missing context — delete the loser.

▸ The concrete example

You ask a coding agent to fix the checkout bug. Option A: hand it the entire repository — thousands of files, every test, all of node_modules. Option B: hand it the 3 relevant files, the failing test, and the error message. Option B wins every time. It's smaller, cheaper, faster — and the agent isn't wading through 9,000 irrelevant lines hunting for the 30 that matter. Less context, better result.

CORE CONCEPTOrder matters — put the important stuff where it'll be seen

Two contexts can contain the exact same information and perform differently, purely based on arrangement. Because of the "lost in the middle" effect, the start and end of the context get the most attention. So:

💡 Quick heuristic

If a human skim-reader would miss it, the model probably will too. Front-load and book-end what matters most.

SEE ITPack the context

Your agent has one job: fix the checkout bug. Below are eight things you could stuff into its context window. Toggle the ones you'd include, then press Score it. The widget rates your context on signal (did you include what's needed?) and noise (did you add junk or blow the budget?).

🎒 Interactive · Build the agent's context

Task: "Fix the bug where the checkout button does nothing." Pick what to put in the context window.

Toggle items, then score.

Weights are illustrative and deterministic — the point is the shape of the trade-off, not exact percentages.

PRACTICALKeeping context clean over a long task

Everything so far was about setting up context. But agents run in a loop (Lesson 2.1), and over a long task the context grows on its own — every tool result, every step, every dead end accumulates. Left alone, it bloats until the signal-to-noise ratio collapses and the agent starts to drift.

So context engineering isn't a one-time setup. It's ongoing hygiene:

Modern agent frameworks do some of this automatically (auto-summarizing old turns, for instance), but the mindset is yours to own. A useful habit: every so often during a long run, ask yourself "if I read only what's in this context right now, would I know what to do next?" If the answer is buried under tool dumps and abandoned attempts, the agent is in the same fog — and it's time to summarize and prune before the next step.

This is also why "the agent got dumber over time" is so common a complaint and so rarely about the model. The model didn't change mid-task; its context did. It quietly filled with stale results and contradictory turns until the useful signal was a needle in a haystack the agent itself had been building. Clean context is a renewable resource — but only if you keep tending it.

🧠 The mindset

You are the agent's information environment. Garbage in, garbage out — but also clutter in, confusion out. Curate at the start, and keep curating as the task runs. The agent will reason brilliantly over good context and flail over bad context, no matter how capable the model is.

WEAKNESSCommon mistakes to avoid

✗ "I'll paste everything to be safe."

The single most common mistake. More context isn't safer — it buries the signal, scatters attention ("lost in the middle"), and costs more. Safety comes from including the right things, not all the things.

✗ "Context is just the brief."

No. The brief (3.2) is your instructions; context is the information the agent reasons over. A perfect brief on top of the wrong files still fails. They're two different levers — engineer both.

✗ "Set the context once, then never touch it."

On a long task, context decays — tool outputs and dead ends pile up until signal drowns. If you never prune or summarize, the agent gets worse the longer it runs. Hygiene is continuous.

KEY INSIGHTWhere this connects in your course

  • The context window (2.3) — the finite working memory you're curating. "Lost in the middle" is exactly why too much context hurts.
  • Retrieval / RAG (2.4) — the technique that lets an agent fetch the right snippet on demand instead of you pasting everything up front.
  • The art of the brief (3.2) — instructions, the other half of the pair. Brief = what to do; context = what to know.
  • Memory (2.4) — the long-game version of this: what an agent should remember between tasks is a context-curation problem too.

Hold the spotlight metaphor: aim it at signal, keep it off noise, and keep aiming as the task moves. That habit is most of what separates people who get great work from agents from people who get confident nonsense.

GLOSSARYKey terms introduced

Context engineering
Deliberately curating the information in an agent's context window — including what's needed, excluding noise, and ordering for prominence.
Signal vs noise
Signal is information that helps reach the goal; noise distracts, dilutes, or buries it. Good context maximizes signal and cuts noise.
Curation
The act of selecting which files, data, examples, and results go into the context — and which get left out.
Pruning
Removing now-irrelevant material (old tool outputs, dead ends) from a growing context to keep it clean.
Summarization
Compressing long material or task history into a tight recap that carries the signal in far fewer tokens.
Retrieval
Letting the agent fetch the right information on demand (RAG, Lesson 2.4) instead of pre-loading everything into context.

ACTIVE RECALLCheck your understanding

Answer in your own words first, then reveal.

1How is context engineering different from writing a good brief?›

The brief is instructions — what to do and what constraints to respect. Context engineering is the information the agent reasons over — the files, data, examples, and prior results. A perfect brief over the wrong context still fails; you need both.

2Why is "too much context" a real problem, not just a cost issue?›

Beyond costing more and running slower, excess context distracts the agent and buries the signal. Because models attend most to the start and end of their context ("lost in the middle"), critical instructions sandwiched in a huge dump get effectively ignored.

3Name three techniques for giving an agent the right context.›

Any three: give the relevant section, not the whole doc; summarize long material; provide examples of the desired output; point to where info lives and let it retrieve (RAG); and remove stale/contradictory material.

4Why isn't context engineering a one-time setup on a long task?›

Because the agent runs in a loop, context grows on its own — every tool result, step, and dead end accumulates. Without ongoing pruning and summarization, the signal-to-noise ratio collapses and the agent drifts. You curate at the start and keep it clean as it runs.

You aimed the spotlight. Next: how much to trust what comes back →