Open · free

Context engineering: what goes into a model's context

Deciding what a model or an agent sees, at which moment, and what stays out

Intermedio10 chapters2 hours of readingcertificate includedupdated on

A complete written course on context engineering, independent of any vendor: why the quality of a model-based application depends more and more on what the model has in front of it, and less and less on how the request is worded. It covers what context is made of, what it costs in space, time and quality, how to choose which documents to include, how to summarise a long session without losing what matters, when to split work across separate contexts, what to save in memory between sessions, how to design tool results, how to protect the context from untrusted content, and how to measure the effect of every choice. Pass the final test and you get a certificate of attendance with a verifiable Open Badge.

What you will learn7 outcomes
  • Explain what context engineering means and why the problem moved from how a prompt is worded to what the context contains
  • Break the context of a call into its components and lay them out by stability, author and trustworthiness
  • Recognise the costs of context in space, latency and quality, and treat it as a scarce resource even when the window is large
  • Choose between preloading and on-demand retrieval, and recognise when not to retrieve at all
  • Design a compaction step that keeps the goal, constraints, decisions and exact identifiers
  • Use separate contexts and persistent memory without losing information or carrying errors from one session to the next
  • Protect the context from untrusted content, and measure the effect of each choice with comparisons and removal experiments

Prerequisites

  • The Production-Ready Prompt Engineering course, or equivalent experience writing prompts for real systems
  • The AI agents: how they actually work course, or a basic understanding of how an agent uses tools in a loop
  • Being able to read JSON and a structured text file: you never write code during the course

Chapter 01

From prompt to context: why the problem moved

For a few years, the practical question with language models was how to write the request. The prompt was almost everything the model read: an instruction, maybe a few examples, the text to work on. Improving the result meant improving those lines. Today, in a real application, the text someone wrote by hand is often a minor share of what the model receives. The rest comes from retrieved documents, the conversation history, tool definitions, the results of earlier calls, notes saved in past sessions. The problem hasn't gone away: it has moved from how you write to what you put in.

Context engineering is the name that has caught on for this work: designing, for every call, the set of information the model has in front of it. It's a deliberately broad definition. It covers choosing documents, how a long conversation gets summarised, which tools are available and how much they return, what is remembered from one session to the next, and in what order all of this is presented. It isn't a discipline invented out of nowhere: many of its practices already existed under other names. The term is useful because it gathers them under a single question — what does the model need to see, right now, to do this step well — instead of treating them as separate problems.

The reason the problem has grown is mostly agentic. A single call has a context you design once and that then stays put. An agent, on the other hand, works in a loop: at every step it reads, decides, calls a tool, and the result is added to what it will read at the next step. The context is no longer a text you write but a state that evolves, partly by the model's own decisions. After many steps it can contain material nobody consciously chose: results that are no longer useful, failed attempts, pages read once and never again. The AI agents course introduces this problem in its chapter on memory and context; here it is treated as a design job in its own right.

It's worth saying up front what context engineering is not. It isn't filling the window as much as possible in the hope that the model will find what it needs: more context does not mean better results, and chapter 3 explains why. It doesn't replace prompt engineering: instructions remain part of the context, and writing them well is still necessary — the Production-Ready Prompt Engineering course is the groundwork for that. And it isn't a phrasing trick to win the model over: it's an architectural decision, made more often in the code that assembles the call than in the text of the instructions.

The most useful way to think about it is as an attention budget. Every element in the context competes with the others to influence the answer. A relevant element helps; an irrelevant one distracts; a wrong or outdated one can lead the model astray just as forcefully as a correct one. So the job has two sides: getting the model what it needs, at the moment it needs it, and keeping everything else out. The following chapters follow that thread: what context is made of, what it costs, how to choose it, how to summarise it, how to split it, what to remember, how tools fill it, which risks it carries and how to measure the effect of every choice.

Chapter 02

What context is made of: instructions, history, documents, tools, memory

Before deciding what to include, you need to know what's there. The context of a model call usually contains five families of content. Instructions: rules, role, format, constraints, written by whoever builds the application. History: earlier turns of the conversation or earlier steps of the agent, including its calls. Documents: reference material inserted for this request, retrieved from a knowledge base or attached by the user. Tools: the definitions of what the model can call, and the results of the calls already made. Memory: information kept from previous sessions and reintroduced at the start of this one.

Classifying them matters because they differ along three axes that drive every later decision. The first is the author: you write the instructions; documents and tool results are often written by someone else; memory may have been written by the model itself. The author determines how far a piece of content can be trusted, the subject of chapter 9. The second is stability: instructions rarely change, history grows at every step, documents change with every request. The third is who decides that content goes in: some parts are inserted deterministically by code, others are chosen by the model when it calls a search or read tool.

The logical layout of a context, from what never changes to what changes at every step. APIs express it through different fields, but the model reads it as one whole.text
[SYSTEM INSTRUCTIONS]            stable · written by you
  role, rules, format, prohibitions

[TOOL DEFINITIONS]               stable · written by you or an external server
  search_documents, read_order, ...

[MEMORY]                         rarely changes · written in past sessions
  project conventions, user preferences

[DOCUMENTS FOR THIS REQUEST]     changes every request · outside authors
  <document id="POL-07" source="intranet" date="2026-03-02"> ... </document>

[HISTORY AND RESULTS]            grows every step · partly untrusted
  previous turns, tool calls, results

[CURRENT REQUEST]                changes every step

Order isn't a cosmetic detail. Putting the stable parts at the top and the variable ones at the bottom has a practical advantage: many providers offer some form of prefix caching, which reuses the processing of the opening part of the context when it stays identical between calls, saving cost and time. A variable value placed at the top — a timestamp, a session identifier — makes everything after it different and cancels the benefit. There's also an effect on quality: in practice it's often observed that a request placed after long documents, near the end of the context, is followed better than one placed before them. How much this matters in your case is for the evaluation in chapter 10 to say, not a general rule. The same goes for content of different trustworthiness: keeping instructions apart from outside content, never mixed in, makes it clear to the model — and to whoever rereads the logs — where the rules end and the material to work on begins.

One last distinction prevents a lot of mistakes: the one between what the model sees and what the system knows. The system may have a customer's entire history, every file in a project, the complete result of every tool. The model sees only what is in the window at that moment. Keeping the full data outside the context and letting in only a view of it — an excerpt, a summary, a reference from which to fetch the rest — is the fundamental move of this whole course. What isn't in the context isn't lost: it simply hasn't been loaded yet, and it can be loaded when it's needed.

Chapter 03

Context has a cost: space, latency, and quality that drops as it grows

Every element in the context has three costs, and only the first is visible straight away. The first is space: the context window is finite, and everything that goes in — instructions, tool definitions, documents, history — takes room from everything else. In an agent the bill grows at every step, because each result is added and usually stays. Tool definitions are a cost people often forget: they take up space in every call, even the ones where no tool is used, and an agent connected to many tools can spend a significant share of the window just on knowing what it could do.

The second cost is money and time. Most APIs charge in proportion to the input text, and a longer text takes more processing time before the first word of the answer arrives. In an agent these costs multiply: every step rereads the whole context accumulated so far, so a bulky result obtained early on is paid for again at every later step. The Production-Ready Prompt Engineering course describes the general levers on cost and latency; one specific point matters here: in an agent's loop, the cost of an element depends not only on how big it is, but on how many steps it stays in the context.

The third cost is the least intuitive and the most important: quality. It would be natural to assume that a model with more information answers better, or at worst the same. In practice the opposite is often observed. With very long contexts, models tend to use what they contain less reliably: a detail sitting in the window can be overlooked, especially when it's surrounded by a lot of similar material; instructions given at the start can be followed less consistently after many steps; an outdated piece of information left in the context can win over the updated one. Among people who build these systems the phenomenon is sometimes called context rot. How pronounced it is varies from model to model and from task to task, and models are improving; but the tendency is common enough that it has to be designed for, not ignored.

An intuitive way to understand it is to think of the model's attention as a resource spread over everything it reads. Irrelevant material isn't neutral: it competes with relevant material, and the more it resembles it, the harder it competes. That's why the worst damage doesn't come from obvious noise, which the model discards easily, but from material that is plausible and wrong: the old version of a contract, a search result about a customer with the same name, a hypothesis rejected many steps earlier but still written in the history, two nearly identical procedures of which one no longer applies.

Hence the rule that holds up the rest of the course: treat context space as a scarce resource even when the window is large. A larger window raises the technical ceiling; it doesn't make what you put in free. The goal isn't the shortest possible context, but the smallest set of information that makes the right result likely. Sometimes that set is large — analysing a long contract needs the whole contract — and then it should go in without hesitation. What to avoid is inclusion by inertia: material that is there only because nobody decided to take it out.

Chapter 04

Choosing what to include: retrieving the right documents, and when not to

For reference material there are two strategies, and almost every real system combines them. Preloading inserts the information before the model starts: code picks the documents — for instance with a search on the user's question — and puts them in the context. On-demand retrieval instead gives the model tools to search and read, and lets it decide what to load and when. The first is predictable, fast and easy to control; the second is flexible and loads only what's needed, but takes more steps and depends on the model's ability to search well. The AI agents course names on-demand retrieval as the usual choice for agents; here you'll see how to choose case by case.

The practical criterion is how predictable the need is. If you know in advance what a given type of request needs — the internal policy for a question about holidays, the customer record for a ticket — preloading is the simplest and most reliable choice. If the need only emerges while working — investigating an error in a codebase, answering a question that spans several documents — on-demand retrieval avoids loading everything for fear of missing something. A middle way that works well is to preload lightweight references instead of contents: the list of available documents, file paths, titles with a one-line description. The model knows what exists and decides what to open.

Lightweight references preloaded instead of the documents: a few characters per entry, and the superseded revision is flagged rather than left to compete with the current one.text
Available documents (open with read_document(id)):
- POL-07  Refund policy, current revision       refunds, returns, timing
- POL-12  Business contract terms               service levels, penalties
- FAQ-03  Billing FAQ                           VAT, credit notes
- ARC-01  Refund policy, previous revision      SUPERSEDED by POL-07

When you do retrieve, the quality of what arrives counts for more than the quantity. A good search result has three properties. It's relevant: a passage that answers the question, not a whole document with the answer somewhere inside. It's contextualised: it carries its source, date and position, so the model knows where it comes from and can cite it, and so that a fragment taken from a table or a list still makes sense outside its document. It's non-redundant: ten near-identical passages take the place of ten different pieces of information. Retrieving a few good results and letting the model ask for more if needed usually works better than retrieving many mediocre ones.

The most neglected decision is not to retrieve at all. Not every request needs documents: a rewording, a calculation, a clarifying question to the user. A system that always fires off a search fills the context with loosely related material that the model then feels obliged to use. It's also better not to retrieve when the information is already in the context, or when the only available source is outdated and an “I don't know” is preferable to an answer built on stale data. And keep in mind the limit already seen in the Production-Ready Prompt Engineering course: if retrieval didn't find the right passage, no instruction can make up for it. Retrieval therefore needs to be measured separately, as chapter 10 shows.

Chapter 05

Summarising without losing: compaction, and what must never be cut

Compaction is the most direct answer to a growing context: at some point the accumulated history is replaced by a condensed version of itself, and work carries on from there. The AI agents course describes the principle and the order of priority for what to keep. What matters here is how to design it, because bad compaction is worse than none: a long context is slow and expensive, but it still contains everything; a summary that has lost a constraint contains an error nobody will ever see, because the full version is no longer in front of the model.

There are several forms, to be used from gentlest to harshest. The lightest is clearing results: tool results that have already been used — a page that was read, the output of a command — are replaced by a placeholder recording that the call happened and how to repeat it. It's safe because it rewrites nothing: it removes material that can be fetched again. More incisive is compaction by summary, where a model rewrites the history into a structured note. The most radical is starting over with a fresh context that contains only that note and the state saved outside, in files or in the system, like the progress file seen for long tasks. Use the reversible forms before the ones that rewrite.

The critical point is what never gets cut. The goal in the user's own words, not paraphrased: each paraphrase shifts the meaning slightly, and after a few compactions the goal has become a different one. Explicit constraints, with who set them. Decisions made and the reason for them, because without the reason the model will reopen them. Exact identifiers — file names, order numbers, codes — which a summary tends to approximate. Paths already tried and rejected, which will otherwise be tried again. Questions still open. What can go is the detail of steps that succeeded, already reflected in the state of the work, and raw content that can be reread from the source.

A compaction note template with fixed sections: an empty section stands out, an omission in free text does not.markdown
## Goal (the user's words, do not paraphrase)
"Align the B2B price list with the new exchange rate, without
touching customers on a locked contract."

## Constraints (and who set them)
- Do not modify customers on a locked contract (user, start of session)
- Round as in the current price list (finance, forwarded email)

## Decisions made and why
- We work on a copy of the price list: the original feeds the website

## State
- Done: first half of the rows updated and checked
- Next: second half, then compare totals against the original

## Tried and rejected
- Direct import through the API: it rejects files of this size

## Open questions
- Do prices in Swiss francs follow the same rate? (asked, no answer yet)

## Exact references
b2b_price_list_copy.xlsx · locked_customers.csv

Two habits make compaction checkable. The first is giving the summary a fixed structure, like the one above, instead of asking generically to “summarise the conversation”. The second is checking the note before replacing the history, at least for important flows: verify in code that the identifiers present in the history also appear in the note, and keep the full history outside the context, in the logs, so that a loss can be diagnosed. Timing matters as much as content: compacting at a natural handover point — a finished sub-task, a closed phase — loses less than compacting in the middle of a line of reasoning just because the window filled up. Finally, the instructions that produce the summary are a prompt too: test them on real histories, comparing what the model manages to do after compaction with what it did before, using the method of chapter 10.

Chapter 06

Separating contexts: sub-agents and isolated tasks

Compaction shrinks the context after it has filled up. Separation stops it from filling up: a task that needs a lot of material but produces a small result runs in a separate context, and only the result enters the main one. It's the same idea as a function in a program, which works with local variables and returns a value. The AI agents course discusses when a multi-agent system pays off in general; here it's looked at from one angle only: what goes into each context, and what passes from one to the other.

The natural candidates are exploratory tasks where what gets read is far larger than what gets returned. Finding where a given error originates in a codebase can mean opening many files, almost all of them irrelevant; the useful answer fits in a few lines. Going through a long document to pull out the clauses on penalties follows the same pattern. Done in the main context, these tasks leave it full of material read once; done in a separate context, they leave only the answer. The criterion is simple: if only a small part of what a task reads will be needed afterwards, that task is a good candidate. When sub-tasks are truly independent, separate contexts can also work in parallel and cut the overall time; the total cost, however, doesn't go down.

A sub-agent's context is exactly what's written in its task, plus whatever it reads on its own. It doesn't see the main conversation, doesn't know what the user said many turns earlier, and is unaware of any constraint it isn't given. That's why the delegation text is context engineering in its own right: it has to be enough for someone who knows nothing else. Just as important is the return format, which should be requested explicitly: what it found, with the exact references to check it, where it looked without finding anything, and how confident it is. A sub-agent left to its own devices tends to return an account of its work, and that account ends up in the main context.

A delegation that contains all the context needed and fixes the shape of the result, so that only what matters enters the main context.text
TASK
Find where the application raises the "session expired" error
right after login.

ALREADY KNOWN, DO NOT REDO
- The session timeout in the configuration file is correct: verified.

CONSTRAINTS
- Read only: do not modify any file.

RETURN, IN A FEW LINES
- Found: file and line of every place the error originates
- Why you think it is the cause, in two sentences
- Searched without finding: where you looked
- Confidence: high / medium / low

Separation has costs that need accounting for. Every handover loses information: whatever the sub-agent doesn't report doesn't exist for the main context. Total work goes up, because the sub-agent has to rebuild part of the context the main one already had. And two separate contexts working on the same object make different implicit decisions that neither of them sees. A practical rule follows: separate the tasks that read a lot and decide little, keep together the ones that decide a lot. When several contexts need to share bulky information, it's better to pass it through a file or a store that each one reads when needed, rather than copying it into every message. Finally, treat a sub-agent's result like a tool's: an input to check, especially if the sub-agent read untrusted content.

Chapter 07

Memory across sessions: what to save, how to reread it, how to stop an error spreading

Every session with a model starts from zero: whatever looks like memory is always content the system reintroduces into the context, be it a saved note, a profile or a project file. Memory is therefore a special case of this whole course's problem, with one extra complication: whoever decides what to save does so in one session, and whoever rereads it does so in another, without knowing under what conditions the note was written. The AI agents course explains why persistent memory is useful and delicate; here you'll see how to design it.

What's worth saving is whatever is expensive to rediscover, stable over time and useful across sessions. In practice it falls into a few categories: facts about the environment, such as how a project is organised or which command runs the tests; user preferences and decisions, not to be raised again every time; lessons learned, such as a problem already diagnosed or an approach that doesn't work. Not worth saving: anything you can get from the source in a moment, anything that changes often — the status of a ticket, a balance — and personal or confidential data that must not travel from one context to another. The state of a task in progress already has the right tool, the progress file, which lives and dies with the task.

Every entry should carry where it came from and when it was written. A note with no source and no date is reread as a fact; the same note stating the file and the day it was observed is reread as an observation to recheck if time has passed. It also pays to separate what was observed from what was inferred: “the test fails intermittently” is an observation; “the test fails because of a network problem” is a hypothesis, and saving it as a fact turns it into a certainty for every future session.

A memory file a person can read: every entry has a source and a date, and hypotheses are kept apart from verified lessons.markdown
# Project memory: customer portal
<!-- Every entry has a source and a date. Before acting on an old
     entry, reread the source. -->

## Environment
- Tests run with "make test", not with the default command
  (source: Makefile, 2026-10-14)

## User decisions
- No new dependencies without asking (user, 2026-10-02)

## Verified lessons
- The CSV export failed on accented names: an encoding problem,
  fixed in export.py (observed and verified, 2026-10-20)

## Unverified hypotheses
- Slow logins might be caused by the cache
  (inferred, not verified, 2026-10-21)

Rereading memory raises the same problem as chapter 4: loading all of it in every session fills the context with notes irrelevant to today's task. As it grows, load only a short index and the always-valid entries at startup, and leave the rest to an on-demand search. It also needs upkeep: merge duplicates, fix entries that are out of date, delete the useless ones. The specific risk, though, is propagation. An error in one session's context dies with the session; an error saved in memory is reread in every later session with the authority of something the system knows, and can spawn new notes that confirm it. The defences are about process: save only what has been verified, or mark it as a hypothesis; reread the source before acting on an important or old entry; make memory readable and editable by a person; and don't let untrusted content into it unchecked, the subject of chapter 9.

Chapter 08

Tools as context: descriptions, results and how much to return

A tool enters the context twice. First with its definition — name, description, parameters — which the model reads in every call where the tool is available. Second with its results, which stay in the context for every later step. Whoever designs a tool is therefore writing context, even if they think they are writing an API. The AI agents and Production-Ready Prompt Engineering courses explain how to write a good description and why errors must be readable; here the focus is on the volume and shape of what goes in.

On the definitions side, the problem is quantity. Every available tool takes up space even when it isn't used, and similar tools compete with each other when the model chooses. Connecting an agent to everything it might need, just in case, worsens both cost and choice. There are three countermeasures: offer each task only the relevant subset of tools; merge into a single tool the operations the model would always use in sequence; and, when there really are many tools, load their definitions on demand, giving the model a way to search for the right tool instead of listing them all. Some platforms offer this search as a built-in feature, but it can also be built into the code that assembles the call.

On the results side, the question is: what will the model need in the next steps? Almost never the raw result. An API returns dozens of technical fields, unreadable internal identifiers, pagination metadata, null values; the model needs the fields useful for deciding, recognisable names and an identifier it can reuse in later calls. The two results below answer the same call: the second takes a fraction of the space, reads without ambiguity and says what to do to get the rest. Readable identifiers matter more than they seem: a short, meaningful code is copied from one step to the next with less risk than a long random string, and a miscopied identifier produces a wrong call that looks entirely correct.

An API's raw result, passed through as is: unreadable identifiers, numeric status codes, amounts in cents, internal fields.json
{
  "data": [{
    "id": "8f3a2c1e-77b0-4d2e-9a51-0c6e2b9f1d44",
    "obj_type": "order",
    "created_ts": 1760003421,
    "updated_ts": 1760091877,
    "cust_ref": "a91e0f52-3b7c-4c11-8e2d-5f0a9b6c7d18",
    "status_cd": 4,
    "lines": [ ...thirty-seven objects with ten fields each... ],
    "shipping": { "carrier_id": 12, "tracking": null, "addr_id": "c3d9e1f0" },
    "internal_flags": { "legacy_import": false, "audit_rev": 17 },
    "currency": "EUR",
    "total_cents": 184500
  }],
  "page": { "cursor": "eyJvZmZzZXQiOjUwfQ==", "has_more": true }
}
The same result trimmed to what is needed: readable names, reusable identifiers, and a note stating that the result is incomplete and how to continue.json
{
  "orders": [
    {
      "order": "ORD-2291",
      "customer": "Ferri Arredamenti (C-10482)",
      "status": "shipped, tracking not yet available",
      "date": "2026-10-09",
      "total": "EUR 1,845.00",
      "lines": 37
    }
  ],
  "complete": false,
  "note": "This customer has more orders. To see them: search_orders(customer='C-10482', page=2). For the lines of an order: read_order(order='ORD-2291')."
}

Three habits complete the picture. The first is letting the model choose the level of detail, with an explicit parameter — a concise answer by default and a detailed one on request — instead of deciding once and for all. The second concerns results that are unavoidably large, such as a log file or the output of a broad query: instead of pouring them into the context, the tool can save them outside, in a file or a store, and return a summary with a reference from which to read a part. The third, already seen in the AI agents course, is never to truncate silently: a list cut short without saying so leads the model to conclude there's nothing else, and it's a frequent cause of wrong answers delivered with confidence. A well-designed result always says whether it is complete.

Chapter 09

Context and security: untrusted content inside the window

Chapter 2 classified the context by author. For security, that classification becomes decisive, for a reason the AI agents and Production-Ready Prompt Engineering courses have already introduced: the model doesn't reliably tell apart the instructions of whoever is using it from the text it reads while working. Any content in the window can influence its behaviour, whoever wrote it. From a context engineering standpoint, a simple principle follows: every channel that brings content into the context is a possible way in, and it should be treated according to who can write to it.

There are more ways in than it seems. There are the obvious ones: web pages, emails, uploaded documents, search results. And there are less obvious ones: the descriptions of tools supplied by third-party servers, which the model reads as instructions and which can contain malicious ones; the results of a sub-agent that read untrusted material; and above all the texts the system itself produces by reworking outside content, such as a compaction note or a memory entry. These last are the most insidious, because they erase provenance: an instruction hidden in a page, once summarised, becomes a sentence of the system's own; saved in memory, it's reread in future sessions as the system's own knowledge.

The first countermeasure is to keep provenance along the whole path. Outside content comes in delimited and labelled with its source; compaction instructions ask for anything from untrusted sources to be reported as content attributed to that source, never as established fact or as a task to carry out; memory entries that originate from outside content are not saved without a check. None of these measures makes the model immune: they exist so as not to lose information that later defences, and the people who review, need to be able to use.

The second countermeasure, sturdier, is architectural: limit what a context exposed to untrusted content can do. The most solid pattern separates reading from acting. A reading context, with no tools that have side effects and no access to confidential data, processes the outside content and returns only structured data, with closed fields and values the code validates. The acting context receives those fields, not the original text. An instruction hidden in an email may perhaps skew the classification, but it doesn't reach the context that has permission to act as free text, and a value outside the allowed set is discarded by the code.

What the reading context returns after processing an email: closed fields, validated by code. The email's free text never reaches the acting context.json
{
  "sender_is_known_customer": true,
  "category": "refund_request",
  "order_number": "ORD-2291",
  "requested_amount_eur": 184.50,
  "language": "en"
}

Finally, the context should also be seen as a place information can leak out of. Anything in it can end up, by mistake or through manipulation, in an answer, in a call parameter, in a log. Two rules follow. Don't put secrets the model doesn't need to use into the context: keys, passwords and tokens stay in the code that runs the tools, and the model receives at most a reference. And include only the personal data the task needs, because the data minimisation principle applies to the context as it does to any other processing. The rules that matter, as the earlier courses point out, are enforced in code: the context informs the model, it doesn't bind it.

Chapter 10

Measuring the effect: evaluating context choices before and after

Every choice in this course — what to retrieve, when to compact, what to delegate, how much to return — is a hypothesis. They all sound reasonable, and that's exactly why they need checking: a more aggressive summary can save space and lose a constraint in precisely the case that matters; an extra document can help on one question and confuse on another. The Production-Ready Prompt Engineering and AI agents courses explain how to build a set of evaluation cases and what to measure. Here you'll see how to use it for context decisions, which have a few peculiarities.

Comparisons are made with everything else held equal: same cases, same model, same instructions, and only the context choice changes. For each configuration it's worth measuring four things together: the quality of the result, including serious failures; the amount of context used; the cost and time per task; and, for agents, the number of steps. They must be read together because context choices almost always shift the balance between them: one configuration may be slightly less accurate and much cheaper, or more accurate but too slow. Which trade-off is acceptable is decided before looking at the results.

An illustrative comparison with made-up data: two retrieval strategies on the same cases, with quality, context, steps and cost read together, and the cases that got worse listed separately.text
Illustrative comparison, made-up data
A: ten passages preloaded
B: three passages preloaded + on-demand search
Same 60 cases, same model, same instructions, each case run 3 times

                               A          B
Cases solved correctly        51         53
Serious failures               3          1
Average context per case      high       low
Average steps per case        1.0        1.6
Average cost per task         higher     lower

Got worse going from A to B: 2 cases (in both the model
did not search for the document it was missing)

For context, the most instructive technique is the removal experiment: take out one component at a time — a section of the instructions, the memory, a group of tools, the retrieved documents — and rerun the cases. If the results don't change, that component wasn't doing any work and can go, saving on every call. If they get worse, you know what it's for. A useful variant for agents is to grow the context on purpose, adding history or documents that are irrelevant but plausible, to see at what point quality starts to drop: it's how you move from the general tendency of chapter 3 to a threshold measured on your own system.

The final result isn't enough: for context choices, traces are what count. For every failed case the useful question is whether the necessary information was in the context at the moment of the decision. If it wasn't, the problem is selection: retrieval, delegation, compaction or memory lost it or never brought it in. If it was there and got ignored, the problem is presentation or overload: too much competing material, an unfavourable position, a piece of information contradicted by another. The two diagnoses lead to opposite fixes — adding in the first case, removing or reordering in the second — which is why it pays to log, for every call, the exact context the model received.

A few habits complete the picture: include among the cases those that put pressure on the context, such as sessions that require compaction, restarts from memory, documents in contradictory versions, content with hidden instructions; run each case several times, because variability between runs can be as large as the effect you're looking for; and redo everything when the model changes, because the best choice for one model may not be the best for the next.

Final testpass mark 80%

Get your certificate

Pass the final test by answering at least 80% of the questions correctly. The certificate is issued automatically and stays verifiable online through a permanent link: it is an Open Badge compliant with the 2.0 standard, ready to be added to LinkedIn and to digital skills wallets.

No sign-up needed. Your name will appear on the certificate; the email is only used to identify the credential and avoid issuing duplicates.

Your name and the course title will be publicly visible on the credential verification page, which anyone holding the link can open.

FAQ

Certificate, badge and course access

Is the course free? Do I get a certificate?

Yes to both. The course is free in full: the content, the final test and the certificate, with no paid modules and no payment method ever requested. When you pass the final test with at least 80% correct answers you receive a Certificate of Attendance in your name, with a verification code, a public page anyone can consult to confirm it's genuine, a downloadable PDF and an Open Badge you can add to your LinkedIn profile. Your name and email are requested only at the end, if you decide to take the test.

Who runs the course? Is it tied to a model provider?

It's an independent course by Rinoova Academy, and the certificate is issued by Rinoova. It isn't affiliated with or endorsed by any AI provider. The concepts were chosen precisely because they hold whatever the model or platform: where the course mentions a feature some platforms offer, such as prefix caching, it describes it in general terms and points you to your provider's documentation for the details.

What's the difference between context engineering and prompt engineering?

Prompt engineering is about how instructions are written; context engineering is about everything the model has in front of it at every call — instructions, history, documents, tools and memory — and how that changes over the course of a task. The second doesn't replace the first, it contains it. The Production-Ready Prompt Engineering course is the recommended groundwork; this course starts from there and focuses on systems where the context is assembled by code or by the agent itself.

How long is the course, and how are the hours calculated?

About two hours. Ten chapters and roughly 5,000 words of technical text, which take a little under an hour to read carefully, plus nine examples — context layouts, compaction notes, delegations, memory files, tool results and comparisons — worth stopping on, and the final test. It isn't a video course: you can read it at your own pace, stop and pick it up again whenever you like.

What prerequisites do I need? Do I have to know how to program?

The course is intermediate: it assumes you know how to write a prompt for a real system and how an agent uses tools in a loop, the topics of the Production-Ready Prompt Engineering and AI agents courses. You never write code during the course: the examples are short text and JSON files, explained by the text around them. To apply many of the techniques, though, you need to be able to change the code that assembles the model calls, yourself or together with whoever develops it.

What happens if I don't pass the final test?

You can retake it. The threshold is 80% and the questions cover every chapter, so if part of it isn't clear it's worth going back to that chapter and reading it again before trying once more. The certificate is issued only on a pass, and it is never issued twice for the same course to the same person.

Is the course up to date? The field moves fast.

Yes, and it's written to stay that way. The course focuses on what remains valid as models and products change — what to include, how to summarise, how to separate, what to remember, how to protect and measure the context — and that's what the test covers. Model names, versions, prices, statistics and context window sizes are left out on purpose, because they age faster than the rest. The date of the last revision is shown at the top of the page.

Where to go next

More Open courses