The new skill in AI is not prompting, it's context engineering

原始链接: https://www.philschmid.de/context-engineering

上下文工程正在成为一种重要的转变,它超越了提示工程,尤其是在AI智能体兴起之后。Tobi Lutke 精辟地将其定义为:为大型语言模型(LLM)提供必要的信息,以便其合理地解决任务。智能体的成功取决于上下文质量;失败通常是由于上下文不足,而不是模型的局限性。 上下文包括指令、用户提示、对话历史(短期记忆)、长期知识、检索到的信息(RAG)、可用的工具和结构化的输出格式。与静态提示不同,上下文工程是一个动态系统,可以按需提供信息和工具。它旨在确保LLM不会遗漏重要的细节,简洁地呈现信息,并提供清晰的工具模式。 有效的AI智能体更依赖于上下文工程,而不是复杂的代码或提示工程:在正确的时间,以正确的格式提供正确的信息和工具。这需要深入理解用例、输出定义和结构化信息,使LLM能够有效地完成其任务。

A Hacker News discussion debates the shift from "prompt engineering" to "context engineering" in AI. Many argue it's a rebranding of existing practices, while others see it as a necessary evolution for building reliable AI agents. The core idea is that providing the right information, tools, and context is more crucial than crafting perfect prompts. Concerns are raised about whether context engineering is genuinely different or just a new buzzword. Some compare it to over-fitting, while others highlight its potential for automated agents and complex software development. The discussion also touches on the limitations of current LLMs, the importance of evaluations, and ethical considerations like copyright infringement. Ultimately, the conversation explores the evolving role of humans in guiding AI, balancing control with the model's capabilities. The future of this field may not be about prompt or context, but the ability of models to self-source and refine the most accurate, pertinent information possible.
相关文章

原文

Context Engineering is new term gaining traction in the AI world. The conversation is shifting from "prompt engineering" to a broader, more powerful concept: Context Engineering. Tobi Lutke describes it as "the art of providing all the context for the task to be plausibly solvable by the LLM.” and he is right.

With the rise of Agents it becomes more important what information we load into the “limited working memory”. We are seeing that the main thing that determines whether an Agents succeeds or fails is the quality of the context you give it. Most agent failures are not model failures anyemore, they are context failures.

What is the Context?

To understand context engineering, we must first expand our definition of "context." It isn't just the single prompt you send to an LLM. Think of it as everything the model sees before it generates a response.

Context

  • Instructions / System Prompt: An initial set of instructions that define the behavior of the model during a conversation, can/should include examples, rules ….
  • User Prompt: Immediate task or question from the user.
  • State / History (short-term Memory): The current conversation, including user and model responses that have led to this moment.
  • Long-Term Memory: Persistent knowledge base, gathered across many prior conversations, containing learned user preferences, summaries of past projects, or facts it has been told to remember for future use.
  • Retrieved Information (RAG): External, up-to-date knowledge, relevant information from documents, databases, or APIs to answer specific questions.
  • Available Tools: Definitions of all the functions or built-in tools it can call (e.g., check_inventory, send_email).
  • Structured Output: Definitions on the format of the model's response, e.g. a JSON object.

Why It Matters: From Cheap Demo to Magical Product

The secret to building truly effective AI agents has less to do with the complexity of the code you write, and everything to do with the quality of the context you provide.

Building Agents is less about the code you write or framework you use. The difference between a cheap demo and a “magical” agent is about the quality of the context you provide. Imagine an AI assistant is asked to schedule a meeting based on a simple email:

Hey, just checking if you’re around for a quick sync tomorrow.

The "Cheap Demo" Agent has poor context. It sees only the user's request and nothing else. Its code might be perfectly functional—it calls an LLM and gets a response—but the output is unhelpful and robotic:

Thank you for your message. Tomorrow works for me. May I ask what time you had in mind?

The "Magical" Agent is powered by rich context. The code's primary job isn't to figure out how to respond, but to gather the information the LLM needs to full fill its goal. Before calling the LLM, you would extend the context to include

  • Your calendar information (which shows you're fully booked).
  • Your past emails with this person (to determine the appropriate informal tone).
  • Your contact list (to identify them as a key partner).
  • Tools for send_invite or send_email.

Then you can generate a response.

Hey Jim! Tomorrow’s packed on my end, back-to-back all day. Thursday AM free if that works for you? Sent an invite, lmk if it works.

The magic isn't in a smarter model or a more clever algorithm. It’s in about providing the right context for the right task. This is why context engineering will matter. Agent failures aren't only model failures; they are context failures.

From Prompt to Context Engineering

What is context engineering? While "prompt engineering" focuses on crafting the perfect set of instructions in a single text string, context engineering is a far broader. Let's put it simply:

Context Engineering is the discipline of designing and building dynamic systems that provides the right information and tools, in the right format, at the right time, to give a LLM everything it needs to accomplish a task.

Context Engineering is

  • A System, Not a String: Context isn't just a static prompt template. It’s the output of a system that runs before the main LLM call.
  • Dynamic: Created on the fly, tailored to the immediate task. For one request this could be the calendar data for another the emails or a web search.
  • About the right information, tools at the right time: The core job is to ensure the model isn’t missing crucial details ("Garbage In, Garbage Out"). This means providing both knowledge (information) and capabilities (tools) only when required and helpful.
  • where the format matters: How you present information matters. A concise summary is better than a raw data dump. A clear tool schema is better than a vague instruction.

Conclusion

Building powerful and reliable AI Agents is becoming less about finding a magic prompt or model updates. It is about the engineering of context and providing the right information and tools, in the right format, at the right time. It’s a cross-functional challenge that involves understanding your business use case, defining your outputs, and structuring all the necessary information so that an LLM can “accomplish the task."

Acknowledgements

This overview was created with the help of deep and manual research, drawing inspiration and information from several excellent resources, including:

联系我们 contact @ memedata.com