Latest / In The Loop / What Is Context Engineering And Why Should You Care?
Transcript
- 0:00The term context engineering has become the biggest buzzword in
- 0:02AI in the past 10 days, and it's a word that if industry leaders
- 0:07are to be trusted, you must now start to learn, with many people
- 0:11calling it the next big evolution from prompt
- 0:13engineering. In very simple terms, prompt
- 0:16engineering is what you ask an AI model to do for you, whereas
- 0:19context engineering is what a model knows when you ask it
- 0:23something. This shift reflects very hard
- 0:25one lessons when building AI agent systems.
- 0:28You can have something that has all the bells and whistles, but
- 0:31if it doesn't give the right context, it can never deliver
- 0:34good outcomes for people. In today's episode, we're going
- 0:36to discuss the evolution from prompt engineering to context
- 0:39engineering, and I'll breakdown what context means when it comes
- 0:42to AI. And finally, I'll actually give
- 0:44a breakdown of some of the real things that you as a person are
- 0:48going to start noticing as a result of improved context
- 0:51engineering. This is in the Loop with Jack
- 0:53Halton. I hope you enjoy the show.
- 1:06So I'm going to assume most of you already know what prompt
- 1:08engineering is, but just just for the sake of the episode, I'm
- 1:10going to spend 20 seconds on it. Prompt engineering is a phrase
- 1:14that gained mainstream adoption and traction generally after the
- 1:18launch of ChatGPT in about late 2022.
- 1:21And this is because millions of people are suddenly trying to
- 1:24figure out how to talk to an AI system.
- 1:27It was one of the very early job roles that were advertised for
- 1:29by big companies. Prompt engineering became a
- 1:32skill set that people went into courses about generally became a
- 1:35really important skill. And engineering a prompt
- 1:37basically meant using trial and error and intuition really to
- 1:42find a set of I guess instructions and also the way
- 1:44the instructions are worded to make the model do what you want
- 1:48it to do. A really famous example of this
- 1:50was the very famous prompt that literally just said, let's think
- 1:54step by step. And this led to train of
- 1:56thought, which is a form of AI reasoning, which typically
- 1:59improves the performance of how an AI model performs when you
- 2:02just ask it a simple question because it's making itself a
- 2:05plan and following it step by step.
- 2:07However, as the use cases for AI have become increasingly
- 2:10advanced, so have the steps and the tasks that an agent must
- 2:16follow to actually, I guess, deliver value today.
- 2:18And as a result, there were very clear limitations with prompt
- 2:21engineering because early prompt engineering is essentially the
- 2:25A1 shot attempt. So meaning you write a single
- 2:28prompt, which could maybe include a few examples or
- 2:31instructions, and the model then give an answer as a result.
- 2:33But many tasks require dialogue with users.
- 2:37It requires the agent to memorize things.
- 2:39It requires the agent to use tools, so integration into
- 2:42separate systems to capture data from those systems.
- 2:45And so, for example, asking a model to, say, answer this
- 2:49question by searching the web and then write a summary can't
- 2:52be done in a single one prompt attempt.
- 2:55The model needs to take many different actions, like doing a
- 2:58search and remembering what it found and then doing something
- 3:00with that information. And many builders in the space,
- 3:03including ourselves, do things called prompt chaining, which
- 3:06essentially means chaining prompts together to give the
- 3:08model more context to every single step.
- 3:11So take a step and then follow another step and use the
- 3:14information from that previous step.
- 3:16And there was many different innovations that include RAG, so
- 3:19retrieval, augmented generation, including what's called React,
- 3:23So reasoning and action, which essentially are ways of getting
- 3:28a model to prompt and capture subsequent information and use
- 3:32that as context to provide a better answer.
- 3:34The point being is that it's not actually just the instruction
- 3:37sent to a language model that matters.
- 3:39It's actually the context the language model has and how it
- 3:42carries context throughout many different steps.
- 3:46And this is where context engineering really starts to
- 3:48take center stage. Because context engineering is
- 3:51all about deciding what a language model should know
- 3:53before it speaks and answers a human.
- 3:55Not just what you ask, but what data or tools or memories,
- 3:59instructions, and history should be fed into that system to guide
- 4:03its answer. And the term itself became
- 4:05largely popularized by Shopify CEO very recently on Twitter.
- 4:10He said, I prefer the name context engineering to prompt
- 4:13engineering. It better describes the core
- 4:15skill set, which is giving the model the context it needs to
- 4:18plausibly solve the task. And there are other big names
- 4:21out there like Andre Kapathy who was one of the Co founders or
- 4:24let's say founding team members of open AI.
- 4:27And he's very famous and even coined the term vibe coding.
- 4:31He described it more as an art and science of filling the
- 4:34models context window just enough to make the next step in
- 4:38its sequence work, but not too much and not too little.
- 4:42It's just the right amount of information.
- 4:43So you can almost consider context engineering like
- 4:46orchestration. You're orchestrating an agent
- 4:48over many subsequent steps and trying to control what
- 4:52information and context it should have after each step and
- 4:55how it should use that context in the subsequent one.
- 4:58Let's go one level deeper and actually unpack what counts as
- 5:01context when it comes to an AI model.
- 5:04Because every piece of software built over a language model,
- 5:08that's mindset, that's every provider is essentially this
- 5:10fantastic piece of software that is dictating the context and the
- 5:15instructions sent to a model and how that information is surfaced
- 5:18to a user. And that is where all the hard
- 5:20work comes from because it's flipping difficult to get it all
- 5:23to work. And you'll see why in a second.
- 5:26There's many layers to context. So you've got the first piece of
- 5:29context, which is the immediate prompt.
- 5:31So this is the direct question or instruction by a user, for
- 5:36example, creating a marketing strategy.
- 5:39And this is where prompt engineering has typically been
- 5:41focused #2 you've got systems instructions, which essentially
- 5:45a system message sent to the large language model to set a
- 5:50behavior. So you are an expert travel
- 5:52panel. The second layer is called
- 5:53system instructions and essentially this is where you
- 5:56send a system message to a large language model such as you are
- 6:00an expert travel planner. So this is the context that
- 6:03influences say the tone, the scope, and this alone can be
- 6:06quite detailed. We've got an entire agent
- 6:08builder around these which dictates how to behave, not to
- 6:12behave, guard rails, policy, personality, how it should
- 6:15structure its responses, but that's all system messages.
- 6:18Again, the software built on top of these things a highly complex
- 6:23in advance just to make sure the right thing is sent at the right
- 6:25time with the right amount of context.
- 6:27So third piece of context is the conversation history, which is
- 6:30often called the short term memory.
- 6:32So in a conversation which they ChatGPT, you want parts of that
- 6:35chat to be included in every single prompt that goes to the
- 6:39LLM. So when you ask a question, it
- 6:41has the context of all previous conversations you've had in that
- 6:45thread again, so you might say as I was speaking about earlier,
- 6:50and therefore it knows what earlier means.
- 6:52And that's because every time a message by a user is sent
- 6:56ChatGPT is a piece of software also takes the message history,
- 7:00condenses it down and sends it to the language model.
- 7:03So it then has that context of the conversation.
- 7:05The 4th type of context that's absolutely critical is long term
- 7:09memory or persistent memory. This can be a summary of
- 7:12previous interactions. This could be stored facts about
- 7:15a user, such as my preferences or information about my profile
- 7:19or even previous conversations between different threads.
- 7:23So it's that context that persists across different
- 7:25messages. So it knows that you work in a
- 7:29certain job, you like response in a certain way, you hate
- 7:32things that sound like this. We're actually as mindset
- 7:35launching an entire long term memory layer next month, which
- 7:39enables our customers to dictate what an agent should remember.
- 7:43Then you've got retrieving external information.
- 7:45So this might be both RAG or integrations into third party
- 7:48systems. So sometimes you'll ask
- 7:49questions that will require context of external documents or
- 7:53code snippets or videos. And so the software that you'll
- 7:56be interacting with will then call that information, bring it
- 8:00into the prompt that is sent. So your message plus that
- 8:03information from an external data source sent to the LLM, and
- 8:07then the LLM will use that to answer your question.
- 8:09Another example could be a customer support bot that pulls
- 8:12in user's account data whenever it answers a question about
- 8:15billing. You've then got another layer
- 8:16down, which is tool definitions. So if the models can use tools
- 8:19like say, making API calls or running calculations, to do
- 8:24that, it needs to understand how to actually call those tools or
- 8:27interact with external tools, and it must use the information
- 8:30it gets back to answer or support what it's doing.
- 8:33And so whenever it uses one of those tools, let's say
- 8:36summarizes all my WhatsApp conversations, you then want it
- 8:39to be able to retain the output of that query into WhatsApp for
- 8:43the next step in the process. So yeah, that's different layers
- 8:46of what context actually means in AI system.
- 8:48Again, it just sounds like a human that requires context to
- 8:51do good work, but it actually has very big implications on
- 8:55what it means for a genetic systems.
- 8:57And it's one of the big reasons we're launching a new
- 8:59orchestration system that enables our customers to really
- 9:03give models the right context at the right time.
- 9:06And I think in summary, and I'll explain why in just a second,
- 9:10simpler processes or sequential step by step processes are
- 9:13better than multi agent systems right now.
- 9:26We've talked about multi agent systems before in previous
- 9:28episodes, but this is where you have teams of agents doing many
- 9:31different things. And it's really relevant to this
- 9:34conversation because it's all about the concept of context
- 9:38engineering and really highlights why context is so
- 9:41important. So let me delve a level deeper
- 9:44by explaining the problem of having teams of agents doing
- 9:46many different things at once. There are many different use
- 9:49case ideas that people often think, oh, let's get a team of
- 9:53agents to do this. Let's get a team of agents also
- 9:56working on tasks in parallel to each other and then breaking
- 10:00down those tasks into subtasks and getting other agents to help
- 10:03with those subtasks. So the idea might be to have,
- 10:06say, Agent A break a problem into small little parts,
- 10:09delegate it to agent B&C, and then have a say combine all of
- 10:13their information into one answer.
- 10:15Because in theory it would just make the responses faster
- 10:18because you have people working, or so I say, agents working in
- 10:21parallel. And those agents could be
- 10:23specialized, breaking down tasks, for example, or
- 10:27summarizing information. So in theory it makes sense, but
- 10:31often it will fail because of coordination.
- 10:33And when we say coordination, what we actually mean is
- 10:37context, contacts not being shared between different agents.
- 10:41Now, there was a fantastic paper recently released by Cognition
- 10:44Labs again, the one of the labs behind what's called the Devin
- 10:47agent, one of the very famous coding agents before the new age
- 10:51coding apps emerged. And that paper was called Don't
- 10:55build multi agent systems. And to show why they actually
- 10:59tasked a set of agents to build a Flappy Bird clone.
- 11:02To accomplish this. The I created sub agents want to
- 11:06create the background graphics and another one to create that
- 11:08player bird, the thing that you're going to control.
- 11:11Now without the full context, the first sub agent might
- 11:14interpret the task a little bit different and generate a Mario
- 11:18like background instead of a Flappy Bird pipes background.
- 11:21Now they're very similar but slightly different.
- 11:24But the second agent might then produce a bird that doesn't
- 11:26therefore fit with the style of graphics.
- 11:30So when these two agents merge the outputs to combine it into a
- 11:33single game, it obviously doesn't work.
- 11:38It feels like separate products. And the root cause of this is
- 11:41that the sub agents lack the full context of the original
- 11:44objective and the work of other agents going on at the same
- 11:48time. Now the straightforward solution
- 11:50you might say would just to be give all these sub agents all
- 11:52the information they need, like the information on the task, the
- 11:56description, any decisions of the agents have made so they can
- 11:59go and do a good job. In practice, that means when
- 12:01agent A, say, delegate something, it should pass along
- 12:04not just the sub task, but also all of the information, the
- 12:08conversation history, everything that's happened up until that
- 12:11point, and all the decisions that led there.
- 12:14However, even sharing the entire context isn't enough sometimes
- 12:18because the sub agents then might work with full knowledge
- 12:21of say the main objective, yet still produce something that's
- 12:24incompatible because they may make assumptions throughout that
- 12:28process that conflict with each other.
- 12:30Like 1 deciding that the game should have a cartoon style and
- 12:33the other a realistic style. Again, you'll notice that every
- 12:36single decision or action by an agent will always have a knock
- 12:40on effect. And so overall what Cognition
- 12:42Labs have claimed and believed after much testing is that
- 12:46single agent architectures, which means that one agent
- 12:50follows sequentially a few steps is far easier to get a fantastic
- 12:54output than multi agent systems. And it's exactly as I said, why
- 12:57mindset is enabling this exact use case making enabling our
- 13:01customers to dictate all the different steps and separate
- 13:05integrations and the long term memory that an agent should
- 13:08carry throughout a conversation and essentially what it should
- 13:11do with each part of its data and output at each step.
- 13:14And they're not the only ones that reported this because
- 13:16Anthropic did a lot of research into multi agent systems for
- 13:19their research assistance and hire the exact same problem.
- 13:24We've personally found that same problem when trying to use multi
- 13:27agent systems in our own business.
- 13:29So for all the excitement of multi agent systems with teams
- 13:32of agents doing things and and even a single agent doing
- 13:35something really powerful, it all comes down to how well the
- 13:39software product on top of those large language models can prompt
- 13:44and give it context every single time it prompts.
- 13:47So I think this is going to be a growing area of innovation over
- 13:49the next sort of 12 months. And obviously I believe
- 13:53everything will be solved and multi agent systems will
- 13:55probably be possible in I'd say 12 months, but we can always
- 13:59half it and everything happens faster than we thought.
- 14:12So I guess the interesting question therefore, is as a
- 14:15listener right now, how does this impacts you?
- 14:18Like what should you know about this?
- 14:20Why is this relevant to you? But really simply, I think good
- 14:23context engineering, either as a user using just something simple
- 14:26as ChatGPT, or using a product that's an AI product.
- 14:30Good context engineering is where you're left with a sense
- 14:33of that was actually helpful. It also massively influences the
- 14:37types of experiences and features and options as a user
- 14:41that you're going to be given by products.
- 14:42So one of those are going to be personalization.
- 14:45The system is going to increasingly be able to remember
- 14:47everything about you, your preferences, and previous
- 14:49conversations. You're going to start to see
- 14:51more user interface and user experience patterns emerge.
- 14:55For example, as AI becomes integrated and say, apps,
- 14:58designers are going to have to come up with ways to give
- 15:02context to agents without users actually realizing it.
- 15:06For example, many chat interfaces have an upload file
- 15:09button, which enables you to upload a document.
- 15:12From a user's perspective, it's straightforward.
- 15:13I want to talk to a document. But actually what you're doing
- 15:17is giving the agent or the AI language model context.
- 15:21You're also going to have different modes of working.
- 15:23So even if you go on the ChatGPT app, you have the deep research
- 15:25prompt. If you're a pro user, you have
- 15:28the Google search, you now have study with me.
- 15:30There's many different options. And what that does is
- 15:33essentially give context to an agent that they built.
- 15:37And it might just be a single agent architecture with a series
- 15:39of steps. It gives it context on how it
- 15:42should behave in that situation. Another big area is managing
- 15:45context in multi tenant environments.
- 15:48So many of our customers are technology providers, software
- 15:50providers who have say thousands of enterprise customers and each
- 15:55one of them have their own space in these platforms.
- 15:58How therefore does an agent or an AI retain conversations and
- 16:01contacts between all these people and stay secure?
- 16:05So it's an area we've been working really harder and we're
- 16:07excited to bring some out for. But this is the area that's
- 16:11really important because let's take a SAS platform in sales.
- 16:14It might integrate with every single salesperson's contacts.
- 16:19It's CRM, it's e-mail. So when a salesperson asks to
- 16:23say, let's say draft an e-mail, it'll just use all of that data
- 16:27seamlessly, very cleverly, magically and answer you.
- 16:31But all of that magic actually had to be done quite securely.
- 16:36I think the other one is going to be privacy and trust for you
- 16:38because I would be worried about what happens with all this data.
- 16:43They're capturing a lot of data on us now.
- 16:45I personally use it as a life coach as ever.
- 16:48I use it for almost any question that I've got.
- 16:50I will almost always go to ChatGPT or another AI system
- 16:53first. So I guess let's just conclude,
- 17:07early on we were obsessed with the model itself and how to talk
- 17:10to it with prompt engineering. And over time we've realized
- 17:13that an AI agent isn't just the model, it's the whole system
- 17:16that feeds it contacts and interpret its output and uses
- 17:20that output to inform its next set of contacts.
- 17:24So in a way, we're moving one level above in terms of
- 17:27abstraction. How do I get the model to output
- 17:30X? Response is more about thinking
- 17:34what information do I need to give it and guidance to get that
- 17:38best response. Anyway, I hope you enjoyed the
- 17:41episode, I certainly did, and I'll see you next week.