Context management
The context refers to everything to which an agent has access. A good analogy is that the agent’s LLM is its brain, whereas the agent’s context is the information that is communicated to the brain to generate a response. We have already discussed several ways to expose important information to the agent, through system instructions, previous conversation history, prompt injections, and even through knowledge retrieval from tool calls.
In this section, we will narrow the context down to the local context (also called the run context). This refers to the information that is needed to instantiate the agent and acts as a dependency on tools and other hooks.
Local context
Local context enables your agent to access information (from when the agent was instantiated) without that data being explicitly part of the LLM’s prompt. This is most useful for storing user-specific information (e.g., user ID, name, preferences) so that tools can fetch...