Context Engineering – Fundamentals

Generative artificial intelligence has made it easy to obtain an answer.
What is much more difficult is obtaining the right answer, in the right context, and with the necessary level of reliability.
When we use a generative system, the result does not depend solely on the language model. It also depends on the instructions it receives, the information available to it, the conversation history, the documents it can access, the rules that constrain its behavior, the tools it can use, and the way the user guides and verifies the process.
This combination of elements is what we call context.

Context Engineering emerged from the need to consciously design that context.
While Prompt Engineering focuses primarily on constructing the request, Context Engineering addresses a broader problem: what information should be available to the system, in what form, at what moment, and under what constraints so that it can produce a genuinely useful result?
This book introduces the fundamentals of this discipline.
Our starting point will be the generative system as a whole. A language model alone does not represent the entire system with which we interact. Surrounding the model may be instructions, memory, documents, tools, information retrieval systems, controls, and interfaces that profoundly influence its behavior.

Understanding this distinction is essential: using artificial intelligence effectively means learning to design not only what we ask the model, but also the information environment in which the model operates.
The first part of this journey will be dedicated to Prompt Engineering.

We will learn to construct more precise requests, distinguish between objectives, data, constraints, and output formats, and use techniques such as priming, templates, and other reusable patterns. We will also introduce an abstract model of the prompt, useful for reasoning about the structure of requests independently of the specific tool being used.
But formulating a good request is not enough.
A generative system can produce fluent, plausible, and seemingly convincing responses even when the information they contain is incomplete, questionable, or incorrect. For this reason, a central part of the book will be devoted to analyzing AI responses.
We will learn to distinguish between verifiable statements, interpretations, and hypotheses, identify claims that require verification, and assess whether a response is genuinely supported by data and sources.
The first form of verification will be domain knowledge.

The more familiar we are with the subject we are discussing, the better equipped we are to recognize errors, omissions, inappropriate simplifications, or contradictions. However, personal knowledge is not always sufficient, especially when working in unfamiliar areas.
We will therefore introduce additional verification strategies.
Cross-response consistency allows us to observe how stable a response remains when the same question is addressed multiple times or from different perspectives. Retrospective criteria verification, on the other hand, makes it possible to break down a conclusion into the conditions that would need to be satisfied for it to be valid, making its claims easier to verify. Finally, cross-checking allows us to compare statements against independent sources and external evidence.
These tools will converge into a more general method of analysis, designed to make interaction with artificial intelligence not only more effective, but also more controllable.

The book will then address another fundamental element: dialogue management.
A conversation with a generative system is not a neutral sequence of questions and answers. Every message modifies the context of subsequent messages. An incorrect initial assumption can propagate, ambiguous wording can influence later responses, and a direction established in the early stages can create a form of conversational inertia.
Managing dialogue therefore means knowing when to explore further, when to correct course, when to start over, and when to ask the system to question what it has produced so far.

From here, we will move into the heart of Context Engineering: designing the different types of context.
Conversational context contains what has already taken place in the dialogue and allows the system to maintain continuity, but it can also introduce distortions and dependencies on previous responses.
Personal context makes it possible to adapt the interaction to the user’s characteristics, preferences, and objectives, while preventing personalization from becoming a source of rigidity.
Normative context defines the rules, permissions, priorities, and constraints within which the system must operate. It becomes particularly important when artificial intelligence is integrated into organizations and real-world applications.
Documentary context makes it possible to provide the system with information from documents and external sources, transforming the model from a generator that relies primarily on its internal knowledge into a tool capable of working with a specific and verifiable information base.
Finally, tool context further extends the system’s capabilities by allowing it to use tools: conducting searches, querying databases, performing calculations, reading files, interacting with applications, or carrying out operations within more complex workflows.
This is where the distinction between a simple chatbot and an agentic system begins to become apparent.
The model no longer merely generates a response. It can observe a situation, select a tool, perform an action, analyze the result, and use that result to determine the next step.
In this scenario, the role of the human also changes.
The objective is not simply to delegate work to artificial intelligence, but to learn how to orchestrate a collaboration
.
Humans can define objectives, provide domain knowledge, establish criteria, challenge results, and make decisions. The system can explore alternatives, synthesize information, generate variations, use tools, and accelerate cognitive or operational tasks.
Effective interaction emerges from the combination of these capabilities.
For this reason, the final perspective explored in the book will focus on human–AI interaction, understood as an iterative process in which lateral thinking, development, and verification are not necessarily carried out by the same agent or at the same moment.
The purpose of this book, therefore, is not to teach a collection of formulas for obtaining better answers.
It is to build a mental model for designing interactions with generative systems.
Understanding what influences a response. Knowing what information to provide. Recognizing what information is missing. Constructing verifiable requests. Evaluating results. Managing dialogue. Organizing documents, memory, rules, and tools so that the system can operate under the most appropriate conditions.

Because using a generative model means formulating a request.
Designing the context means designing the conditions under which that request can produce a genuinely useful response.

Support the project

All the materials I share stem from a very simple conviction: good training should not be limited to teaching which buttons to press, but should help people understand the ideas, principles, and processes behind the tools.

That is why I dedicate a significant portion of my time to researching, organizing, and producing free content focused on multimedia, design, and visual communication—articles, lessons, in-depth analyses, and resources aimed at making accessible topics that are often addressed in a fragmented or superficial way.

However, this work requires time, research, and care. Every guide, video, and piece of material published for free is the result of many hours of study, writing, and revision.
Supporting the project via Patreon enables me to continue producing high-quality educational content, keep it accessible to as many people as possible, and devote more energy to building a resource that benefits students, professionals, and enthusiasts alike.

If you believe that a deeper, more rigorous, and informed understanding of multimedia is valuable, your contribution does more than just support my work: it helps make these resources available to the entire community.
Thank you for your support and trust

Is Patreon too demanding?

You can also support me with a voluntary donation—no subscription or commitment required.

Even a small contribution helps me continue creating games, educational content, and free materials with greater freedom.