Context

The term “context” is mostly conceptual. It refers to “the background information the agent/LLM has while performing a task”. If that sounds abstract/general, it is supposed to be.

Continuing our Bob the assistant analogy. Lets say you walk into Bob’s office and say “Draft a project update.” Well thats a pretty vague request. E.g. What project are you talking about? What should be the format of the update? Should Bob use word doc? Bob needs more “context”.

Same principle applies to LLM/agents. When people say “the agent needs more context”, they mean the agent needs more background information to complete the task correctly.

Key concepts

The Bob analogy illustrates why context is important for agents/LLMs to complete tasks correctly. Unlike humans, LLMs are not very good at asking clarification questions to resolve such ambiguities (although people are actively working on this).

So how can one figure out whats the right context to give to the agent? “Step into the agent’s shoes” is a standard and effective technique/principle: pretend you are the agent and you don't have existing knowledge about the task you are asking the agent to perform. You can only use the tools the agent has, see what the agent sees. Can you successfully perform the task with only the information given to the agent? This helps identify missing context/ambiguities.

So how is context different from prompting? There is overlap between prompting and context. You can consider prompt as a part of context. Since context is “anything the agent sees”. Thus prompt engineering is a subset of context engineering. See Prompting for more details.

Another useful tip: if your LLM/agent gave you unexpected answers and you suspect its a context problem, directly ask the LLM/agent, e.g. “You answered X, but that is not correct because… Can you explain your thought process on how you concluded X?”

❓Quiz

Here is an instruction I am giving to the agent: “Helping me prepare a report based on the following template. Use the attached pdf as the source of truth. Also, I found this article online and pasted it below because it’s newer, so use it as well. (the report template) (the pdf) (the article)” What might be problematic with this instruction?

Go to next lesson