🧠 Giving LLMs a “Working Brain”
🔍 Goal
Turn a stateless LLM into a stateful, persistent, intelligent agent — one that remembers who you are, what you like, and past conversations.
🧩 Three Core Components
1. Context Engineering
- Purpose: Dynamically manage what information goes into the LLM’s context window each turn.
- Analogy:
- Prompt Engineering = giving a recipe.
- Context Engineering = preparing ingredients + tools + user preferences.
- Key Responsibilities:
- Build the complete prompt dynamically (system msg, functions, few-shot examples, history, retrieved docs, memory, etc.)
- Handle external data — e.g. RAG, long-term memory fetches.
- Manage conversation history and temporary variables.
- Challenges:
- Context Rot: When context gets too large/noisy → model focus degrades.
- Fix: Dynamic history mutation — summarization, pruning, or compression.
Context Management Cycle (4 Steps):
- Fetch Context → retrieve memory, RAG docs, etc.
- Prepare Context → assemble the full prompt (blocking step).
- Invoke LLM/Tools → get responses or run functions.
- Upload Context → save new info to long-term memory (async).
2. Sessions (Short-term Memory)
- Definition: Self-contained container for a single conversation.
- Stores:
- Events: chronological logs (“user said X”, “agent used tool Y”).
- State: working memory (e.g., items in cart, current step).