All you need to know about Context Engineering
Key Takeaways
This video covers the basics of Context Engineering for large language models, including tools like MongoDB, and techniques such as RAG, state and history, memory, prompt engineering, and structured output. The speaker provides a step-by-step guide on how to create context required to provide to an AI agent before running it, and how to use the free tier of MongoDB to get started.
Full Transcript
Stop wipe coding and start context engineering. Even entre karpathy prefer context engineering over prompt engineering. Vibe coding is good but without context it results in errors. So to build high quality application you need context engineering. Context engineering is providing relevant information such as retrieved knowledge, tool outputs, prior conversation, user input to the large language model so that it can complete the task more effectively. So in summary, context engineering includes rag, state and history, memory, prompt engineering, and structured output. Cognition called out context engineering is effectively the number one job of engineers building AI agents. Anthropic mentioned clearly that agents often engage in conversations spanning hundreds of turns requiring careful context management strategies. This involves adding memory to AI agents such as short-term memory, long-term memory, saving those data in vector databases and retrieving when required. It also includes providing knowledge to AI agents for example your documentation and also providing output from tools. When the user provide a input or a task we need to prepare the context. So this preparation is happening before running AI agents. Then the prepared context is passed to AI agent and the AI agent started running. During that time we need to provide memory and also knowledge. As a result, you get a high quality output. So we are going to focus on all these three and mainly we are going to use MongoDB to store the memory and also to store the knowledge. So the AI agent can retrieve the data whenever required from its own memory and also from its own knowledge. In just three lines of code, you are able to create that context which is required to provide to an AI agent before running it. While running the agent, we can retrieve relevant information from the memory, from its past conversation, and also from its knowledge. So, I'm going to take you through step by step and also explain you what all this about. That's exactly what we're going to see today. Let's get started. Prompt engineering is for one-off task, content generation, and format specific output. and context engineering is for conversational AI document analysis tools and coding assistant. By adding both we can provide production ready AI application. These are the four general categories for context engineering. First write context. So that's what we saw now long-term memories writing that in a scratch pad that is in the session also at a state. So all this data gets retrieved in the runtime when the agents are running and then select context. So we don't need all the data included in context. So we need to retrieve only relevant tools. Retrieve from scratchpad that is session and then retrieve from long-term memory and then retrieve relevant knowledge. And the third step compress context. By compressing the context we make it fit into the context window. So if it's a large code base, you can summarize context to retain relevant tokens. Trim context to remove irrelevant tokens. And finally, the last step is to isolate context. You don't need all the context for all the agents. You can partition context in state, hold an environment or sandbox, partition across multi- aent. I'll put the information about all the links which I'm sharing here in the description below. So in this we are going to use multiple agents such as codebased reader agent, review agent, requirements preparation agent and implementation steps preparation agent. So when we provide with a URL or a goal, it'll automatically go through all these agents and finally give the context document. This includes all the context required to achieve the goal provided and the codebase. So this context is nothing but a detailed prompt which clearly explains the steps required to achieve the goal. So first let's prepare the content that is the context required to run the goal and while the AI agents run we going to provide memory and knowledge to get the final output. So we have a context agent which will automatically go through different agents and prepare the final context document. So we are just providing the URL of the GitHub repo and then I'm going to say need to add authentication that is the goal. So literally three lines of code also I'm going to add GitHub token so that we can access the repo. So you can generate GitHub token from github.com. Even if you want to provide a path to a folder in your computer, this agent should be able to access that folder and prepare the context based on the goal. I'll provide all the code in the description below. So step number one, preparing the context. So just three lines. Now open your terminal. Export your open AI API key like this and then click enter. And then export your GitHub token like this and then click enter. If you're using your local folder, you don't need this GitHub token. Next, pip install praise MongoDB like this and then click enter. That is now installing. Now I'm going to run the code. And now first it went to the structured input passer. So it's automatically extracting the URL and the goal from the input. And you can see here the code base and the goal. Next, it's extracting detail information. It's analyzing individual file and analyzing the code. That's the first agent. Next, enhanced file selection agent. So choosing only relevant files. Not everything is required. Now the relevant files been chosen. Focus repository analyst for each individual file. It's giving a description aligned to the goal that is we need authentication. It's giving the architecture patterns dependencies testing integration. Finally, we got the document here adding authentication to praise AI and it's clearly listing the steps and everything is completed. The document is also stored here. So I can just open this and here it is implementation add authentication the URL and executive summary repository analysis goal relevant components dependencies and is more detailed list of files to use implementation blueprint implementation checklist and that is really nice and now if I have a cursor I can just add the documentation by dragging it here and I can just say implement this feature and you can see it's going through the requirements And it's automatically adding the to-do list which we gave and is now fulfilling the request going through one by one. That is really nice. See how good this context engineering uh providing the context beforehand is useful. Even in win you can do the same. So you got the document here. I provide that document here and I can just say implement this. Now I just need to wait for another 15 minutes or 20 minutes for this implementation to be completed. Next I was telling you about memory and knowledge. So in regards to cursor, cursor has its own inbuilt memory and knowledge. But we can customize this further. So if you are building an AI application, you want this memory and knowledge to be customizable. I'm going to show you how you can do that. For that I'm going to use MongoDB. This can be used as a vector database and also as a key value pair database. And it's available in the cloud version. And you can get started for free. Just choose the free tier and the location where you want to deploy. Then add your username and the password. And this is how you get the connection string username M and get the password. And in the connection string to store your knowledge, I'm adding the username here and the password here. And the remaining connection string you can get it from here. When you go there to the dashboard, click connect and the drivers. There you got the full connection string. So you can just copy this and paste that here with the with your password. So here is the code. So same as before we are providing the context agent which is capable of generating the context and we are taking the output from that and we need to pass that to the goes to the implementation agent. So this agent is going to implement the context which is provided that is the output from the previous agent that is a context agent and we are connecting that to the database. Here for implementation you might need to provide other tools such as code execution, file management, web scraping but for now I'm going to keep it simple just to show you the demo but you can extend this from here. You can include as many tools as you want based on your project requirements. Now going to run and show you. So in your terminal mentioning the file name and clicking enter. This will automatically go through the previous step collecting all the required context and then it goes to the implementation agent and you can see that the implementation agent is writing the code and all the relevant information will get stored in here in database. Similarly, if you want to feed knowledge data to an agent, we can provide to which database the knowledge can be stored. In our case is a MongoDB. So, I've got a document called documentation.md. So, that's where I've got the documentation stored. So I can provide that as a knowledge to this agent. So now you get the point. Giving the right information to the agent to execute its task. This is MongoDB canvas. This is where you can connect to your database with the right information. That is your database information. Connect. And then you can see the database details here. So we got knowledge and memory stored. So if I see memory, you can see all the data here with the embeddings stored in this way. For knowledge, you got the details here. So when the agent start implementing, it'll retrieve relevant information from the memory and knowledge to give a high quality output. That is context engineering. And I'm super excited about this. Do try and let me know in the comments below what you think about this. And thanks to MongoDB for sponsoring this
Original Description
# Stop Wipe Coding, Start Context Engineering: Build High-Quality AI Applications with MongoDB
👉 Try MongoDB 8.0 here: https://mdb.link/mervin-praison-mdb
👉 Sign up for a free cluster here: https://mdb.link/mervin-praison-cluster
Read more MongoDB blogs!
MongoDB on Medium: https://medium.com/@MongoDB
MongoDB on Dev Community: https://dev.to/mongodb
Follow MongoDB Socials!
YouTube: https://www.youtube.com/channel/UCK_m2976Yvbx-TyDLw7n1WA
LinkedIn: linkedin.com/company/mongodbinc
Instagram: instagram.com/mongodb/?hl=en
X: twitter.com/MongoDB
https://blog.langchain.com/context-engineering-for-agents/
code: https://mer.vin/2025/07/context-agent/
https://docs.praison.ai/
https://github.com/MervinPraison/PraisonAI/
Inspired by Cole Medin and Rasmus
In this video, I dive deep into why context engineering is revolutionising AI development - even Andrej Karpathy prefers it over traditional prompt engineering! While vibe coding might feel good, without proper context, it leads to errors and suboptimal results. Let me show you how to build production-ready AI applications using context engineering.
## What is Context Engineering?
Context engineering is the practice of providing relevant information to large language models (LLMs) to help them complete tasks more effectively. This includes:
- Retrieved knowledge
- Tool outputs
- Prior conversation history
- User inputs
- RAG (Retrieval-Augmented Generation)
- State and history management
- Memory systems
- Prompt engineering
- Structured outputs
As Cognition Labs states: "Context engineering is effectively the number one job of engineers building AI agents."
Timestamp:
0:00 - Introduction to Context Engineering
0:23 - What is Context Engineering
0:40 - Context Engineering Components
1:08 - Memory and Knowledge in AI Agents
2:23 - Context Engineering Categories
3:47 - Multi-Agent Context Preparation
5:05 - Setting Up the Environment
5:30 - Running Context Preparation Agent
6:44 - Using Context in Cursor/Wind
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Mervin Praison · Mervin Praison · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Build GCP Infra using Pulumi in YAML format
Mervin Praison
How to Convert a Pulumi YAML File to Python Format
Mervin Praison
Speed Up AWS EKS: A Complete Guide to Performance Tuning & Debugging!
Mervin Praison
Learn GCP GKE to AWS EKS Migration in Just 5 Minutes: Quick Guide
Mervin Praison
AWS & Kubernetes: The Definitive Guide to Data Persistence with PV and PVC
Mervin Praison
ChatGPT Voice Conversation RELEASED! It's AMAZING!! (Demo)
Mervin Praison
How to Install Mistral 7B in Minutes: Quick & Easy Guide! ✅
Mervin Praison
Code Llama Install Locally: 🐍💻 Elevate Your Python Skills!
Mervin Praison
Orca Mini: Your Ultimate Guide to Install and Test on Mac & Linux 💻
Mervin Praison
Quick & Easy Vicuna Setup on Mac and Linux 💻
Mervin Praison
Quick Guide: Llama2 Local Installation and ChatGPT with pip! Python🛠️
Mervin Praison
Query PDFs Like a Pro with Local GPT: Full Setup Guide! 📜
Mervin Praison
LM Studio: EASIEST way to Run Large Language Models Locally!
Mervin Praison
AMAZING ChatGPT Vision is OUT! 🤯 14+ Examples (Step-by-Step) FULL Tutorial
Mervin Praison
Unbelievable! Build ANY App Instantly with Smol AI! 😲🔥
Mervin Praison
Amazing! AutoGen Made Easy: A Step-by-Step Beginners Guide 📚
Mervin Praison
How to Set Up LoLLMS and Run LLMs Locally! 🚀 Step-by-Step Tutorial
Mervin Praison
GPT4All: INSANE Way to Run Large Language Models Locally! 😲 Step-By-Step Tutorial
Mervin Praison
Incredible AI-Powered NPCs in Unity Game Engine: Step by Step Tutorial!🤯
Mervin Praison
MemGPT 🧠 LLM as Operating System. It's INSANE! Step-by-Step Tutorial 🤯
Mervin Praison
Text Generation Web UI: MIND-BLOWING Way to Run LLM Locally! 🤯
Mervin Praison
Unlock the INSANE Power of OpenAI GPT-4 with C#/.NET! 😲
Mervin Praison
Integrate Langchain and Ollama for Local AI Power 🤯 Indeed POWERFUL!
Mervin Praison
ChatDev: INSANE Virtual AI Agents! Future of Software Development 😲
Mervin Praison
Query PDFs Using Mistral: Unlock INSANE Power! 🤯
Mervin Praison
AutoGen + Open-Source LLMs: UNBELIEVABLE! Step-by-Step Tutorial You Can't Miss! 🤯
Mervin Praison
AutoGen + Text Generation WebUI: Unbelievable 100% Local Private Setup 🤯
Mervin Praison
MemGPT: Amazing! External Context for LLM #ai #llm #memgpt #generativeai #mem #gpt #openai #chatgpt
Mervin Praison
GeniA: Kubernetes + AI for MIND-BLOWING Operational Efficiency! 🤯 FULL Tutorial
Mervin Praison
VertexAI Meets LangChain for Mind-Blowing AI Conversations! 😲 Step by Step Tutorial
Mervin Praison
Simplified ChatGPT API Setup on Node.js for Newbies! 😍 Step by Step Tutorial
Mervin Praison
Autogen: Ollama integration 🤯 Step by Step Tutorial. Mind-blowing!
Mervin Praison
LiteLLM: One-Function Call to ANY Large Language Model! 🤯 UNBELIEVABLE!
Mervin Praison
ChatGPT Chatbot in Less Time Than You Think! 🚀😎 Step-by-Step Tutorial
Mervin Praison
LiteLLM Chatbot: Build Your Own in MINUTES! INSANE! 🤖🔥
Mervin Praison
Create Chatbot: Turn ANY Open-Source LLM into a Conversation Pro! 🤖
Mervin Praison
Create Chatbot: Ollama Integration Made UNBELIEVABLY Easy! 🎉
Mervin Praison
LlamaIndex + ChatGPT: Ingest Data and Experience UNBELIEVABLE Query Results! 🌟
Mervin Praison
INSANE! OpenAgents: Automated Data Analysis with Kaggle 🤯
Mervin Praison
React.js LLM Agent for Next-Gen Coding using ChatGPT 🚀 Mind-Blowing 🤯
Mervin Praison
MemGPT + Any LLM 🚀 100% Local & Private Integration Unveiled! Unlimited Memory
Mervin Praison
MemGPT + AutoGen 🧠🤖 Unlimited Memory & Autonomous AI Agents! INSANE🤯
Mervin Praison
AutoGen + Google's Palm LLM & More! Revolutionary AI Integration 🚀
Mervin Praison
MemGPT & LM Studio Integration Revealed! 🔥 Next-Level AI
Mervin Praison
🚀 AutoLLM: Unlock the Power of 100+ Language Models! Step-by-Step Tutorial
Mervin Praison
AutoLLM & Gradio Integration You Won't Believe! 🤯 Mind-Blowing
Mervin Praison
AutoLLM & FastAPI Tutorial: Query 100+ Language Models! 😱
Mervin Praison
Quivr: LLM's Second Brain - Transforming Data Management & Advanced Query with AI! 🤯
Mervin Praison
AutoGen & MemGPT with Local LLM: A Complete Setup Tutorial! 🧠 AMAZING 🤯
Mervin Praison
LocalAI: Free, Open Source OpenAI Alternative 🚀 INSANE 🤯 Step-by-Step Tutorial
Mervin Praison
Yarn Mistral 7B 128k LARGE context window, Small size 🤯 INSANE 🚀 Setup Tutorial!
Mervin Praison
Zephyr-7B: The Small and Mighty LLM 🤯 Step by Step Tutorial! 📘
Mervin Praison
Promptfoo: How to Test Your LLM ? 🚀 VERY EASY!
Mervin Praison
Pydantic: How to Validate LLM Responses? 🚀 Quality Response. VERY EASY!!!!
Mervin Praison
Pydantic: FORCE Your AI to Respond Back in UPPERCASE! 🤯 Step-by-Step Tutorial 🔥
Mervin Praison
Pydantic: How to use LLM to convert unstructured data to structured data?
Mervin Praison
AutoGen Function Calling: INSANE 🚀 Custom Integrations! Step-by-Step Tutorial 🤯
Mervin Praison
OpenAI Assistants API + Python 🤖 How to get started? (FULL Tutorial) 🤯 INSANE
Mervin Praison
GPT-4 Vision API 🤯 INSANE Video Recognition Powers! Step-by-Step Tutorial 🚀
Mervin Praison
GPT-4 Vision API 🚀 The Future of Image Recognition! 🤯 Step-by-Step Tutorial
Mervin Praison
More on: LLM Engineering
View skill →Related Reads
Chapters (9)
Introduction to Context Engineering
0:23
What is Context Engineering
0:40
Context Engineering Components
1:08
Memory and Knowledge in AI Agents
2:23
Context Engineering Categories
3:47
Multi-Agent Context Preparation
5:05
Setting Up the Environment
5:30
Running Context Preparation Agent
6:44
Using Context in Cursor/Wind
🎓
Tutor Explanation
DeepCamp AI