Recommended resources
The freely available resources this lesson will direct you to.
Introduction
In our last lesson, we established a systematic process for auditing a business workflow. By mapping tasks, roles, and decision points, you learned how to produce a comprehensive inventory of the inputs, context, and knowledge an agent needs to perform its job. This audit provides the "what"—the raw list of informational requirements.
Today, we move from "what" to "how." The information an agent needs isn't a monolithic block; it comes from different sources and serves different purposes. To build a robust and efficient agentic system, we must understand and manage these sources strategically.
This lesson directly addresses the learning outcome: to distinguish between static context (system instructions), dynamic context (retrieved data), and conversational context (user input). Understanding these three categories is fundamental to designing the agent's information environment. This distinction governs how you will architect the flow of information into the agent's "working memory," ensuring it has the right information at the right time without being overwhelmed.
1. The Agent's Working Memory: The Context Window
Before we categorize the information, we must first understand the space it occupies: the context window. Conceptually, you can think of the context window as the LLM's RAM. It's a finite space that holds all the information the model can "see" at the moment it generates a response. Everything—instructions, user queries, retrieved documents, and conversation history—must fit into this window.
The size of this window is measured in tokens, which are the basic units of text for the model. Let's watch a short video to solidify this core concept.
What is a Context Window? Unlocking LLM Secrets
This video from IBM Technology provides a clear explanation of what a context window is, how tokenization works, and critically, the different types of information that compete for space within it.
First, watch from the beginning to 02:45 to understand the context window as a form of working memory. Then, watch the segment from 07:23 to 08:53. Pay close attention to the list of things that can occupy the context window. This list provides the foundation for the categories we will explore next.
As the video highlights, the context window isn't just for the user's message. It's a shared space filled with various components, each playing a distinct role. Our job as system designers is to manage this space effectively.
2. The Three Categories of Context
To manage the context window, we need a clear taxonomy. The information an agent uses can be organized into three primary categories: static, dynamic, and conversational. The following article provides an excellent breakdown of these components.
Context Engineering in LLM-Based Agents
The article 'Context Engineering in LLM-Based Agents' by Jin Tan Ruan offers a detailed list of the elements that constitute an agent's context. We will use this to formalize our three categories.
Read the section under the heading 'What is Context Engineering?'. Focus on the bulleted list of components that a typical agent's context might include. As you read, mentally group these components into our three categories.
Based on that reading, let's define our three categories with precision.
a) Static Context: The Agent's Core Identity
Static context consists of the foundational instructions that define the agent's purpose, personality, and operational rules. It is typically loaded once at the beginning of an interaction and remains constant.
From a systems perspective, this is analogous to a program's configuration file or the firmware on a device. It sets the baseline for all subsequent operations.
Static context includes:
- System Instructions: Defines the agent's role ("You are a helpful project manager assistant"), core directives ("Your goal is to process meeting transcripts"), and persona ("Your tone should be professional and concise").
- Boundaries and Constraints: Rules the agent must always follow ("You must not provide financial advice," "Never execute code without approval").
- Structured Output Formats: Schemas (like JSON) that define the required structure of the agent's output, ensuring consistency.
b) Dynamic Context: The "Just-in-Time" Knowledge
Dynamic context is information that is fetched on-demand from external sources to complete a specific task. It's not part of the agent's core instructions but is injected into the context window as needed. This is the primary mechanism for grounding an agent in real-time, factual information.
This is analogous to a program reading from a file, querying a database, or making an API call.
Dynamic context includes:
- Retrieved Knowledge (RAG): Content retrieved from a knowledge base, such as documents, articles, or internal wikis. This is the core of Retrieval-Augmented Generation.
- Tool Outputs: The data returned from an API call or function execution (e.g., the current weather from a weather API, or the result of a database query).
- Real-time Data: Any information that reflects the current state of the world, like stock prices or system status.
c) Conversational Context: The Flow of Interaction
Conversational context represents the history of the current interaction. It allows the agent to remember what has been said, maintain a coherent dialogue, and understand ambiguous references like "it" or "that."
This is analogous to a thread's call stack or session state in a web application.
Conversational context includes:
- User Input: The most recent query or command from the user.
- Chat History: The sequence of previous turns in the conversation between the user and the agent. This is often summarized or truncated to save space.
- Short-Term Memory / Scratchpad: Intermediate thoughts, calculations, or partial results the agent generates and needs to reference in subsequent steps of a multi-step task.
The following diagram provides a useful visual summary of how these different information sources feed into the central context window.

3. Context in Action: A System-Level View
Understanding the categories is the first step. The next is to see how they interact within an agentic system's architecture. A well-designed system has distinct components responsible for managing each type of context before they are assembled into the final prompt for the LLM.
The following pseudo-code provides a clear architectural blueprint for a conversational RAG agent. Notice how different classes are responsible for handling different types of context.
RAG and Conversational Patterns: Building Intelligent Knowledge ...
The article 'RAG and Conversational Patterns' by Lijo Jose provides pseudo-code for a RAG system that clearly separates concerns. This will help you see how our abstract categories translate into concrete system components.
First, review the 'Code Patterns Overview' diagram to see the high-level data flow. Then, examine the pseudo-Python code for the RAGConversationalAgent class and the helper classes it uses: GenerationAgent's build_system_prompt() method is responsible for crafting the Static Context. ConversationContextManager is responsible for processing the chat history and current query into the Conversational Context. RetrievalAgent is responsible for fetching the Dynamic Context from the knowledge base. This structure shows a modular approach to context assembly.
This modular design is critical for building scalable and maintainable agentic systems. By separating the logic for managing static, dynamic, and conversational context, you can independently improve, test, and version each component. For example, you could refine the retrieval strategy (dynamic context) without altering the agent's core personality (static context).
4. Strategic Management of Context
Effectively managing these context types is what "Context Engineering" is all about. It's not just about stuffing information into the prompt, but about strategically writing, selecting, compressing, and isolating it.
Let's watch a final video that frames these activities and explains why they are especially critical for agents performing complex, multi-step tasks.
Context Engineering for Agents
This video from LangChain, a popular agent development framework, discusses 'Context Engineering' as a discipline. It highlights the challenges agents face with long contexts and introduces strategies for managing them.
Watch from the beginning to 03:20. Focus on two key ideas: The definition of context engineering as the art of filling the context window with the right information at each step. Why agents, due to long-running tasks and tool use, amplify context management challenges, leading to failures like 'context poisoning' or 'distraction'.
The video underscores a key architectural principle: your system's job is to act as an intelligent filter, curating the perfect "briefing packet" for the LLM at every single step. This packet is a careful composition of static, dynamic, and conversational context.
Conclusion
In this lesson, we dissected the concept of "context" into a practical, three-part framework. This taxonomy is essential for moving from a simple list of requirements to a sophisticated system architecture.
Key Takeaways:
- The Context Window is Finite: All information an agent uses must fit within the LLM's limited context window, making strategic management essential.
- Static Context defines the Agent's Core: System instructions, rules, and output schemas form the stable, foundational identity of the agent.
- Dynamic Context provides Real-World Grounding: Information retrieved on-demand from knowledge bases and tools (RAG) keeps the agent factual and up-to-date.
- Conversational Context maintains the Flow: User input and chat history provide the immediate state of the interaction, enabling coherent dialogue.
- System Design Reflects Context Types: A robust agent architecture has distinct components for managing each category of context before assembling the final prompt.
Preview of the Next Lesson
We now understand what information an agent needs (from Lesson 3.1) and have categorized it into static, dynamic, and conversational types (this lesson). However, when all this information exceeds the context window's size, how do we decide what to include and what to leave out?
In the next lesson, we will address this directly. We will focus on how to design a context assembly strategy that prioritizes the most relevant information within token limits. This involves techniques for ranking, summarizing, and compressing context to ensure the agent receives the most potent, high-signal information possible.