這是用戶在 2025-7-1 13:41 為 https://www.philschmid.de/context-engineering 保存的雙語快照頁面,由 沉浸式翻譯 提供雙語支持。了解如何保存?

The New Skill in AI is Not Prompting, It's Context Engineering
現在使用 AI 所需的技巧不是提示工程,而是情境工程

June 30, 2025
2025 年 6 月 30 日
5 minute read
閱讀時間 5 分鐘

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.
「情境工程」是 AI 領域中一個正在受到關注的新術語。現在的討論正從「提示詞工程」轉向一個更廣泛、更強大的概念:「情境工程」。Tobi Lutke 將其描述為「提供所有情境,讓大型語言模型 (LLM) 能合理地解決任務的藝術。」他是對的。

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.
隨著 AI 代理 (Agent) 的興起,我們載入「有限工作記憶」中的資訊變得更加重要。我們發現,決定 AI 代理成敗的關鍵在於你提供的情境品質。現在大多數 AI 代理的失敗,不再是模型本身的失敗,而是情境的失敗。

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.
要理解情境工程,我們必須先擴展對「情境」的定義。它不只是你傳送給大型語言模型 (LLM) 的單一提示詞。你可以將其視為模型在生成回應之前所看到的一切。

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.
    檢索資訊(RAG):外部的、最新的知識,來自文件、資料庫或 API 的相關資訊,用於回答特定問題。
  • Available Tools: Definitions of all the functions or built-in tools it can call (e.g., check_inventory, send_email).
    可用工具:所有它能呼叫的功能或內建工具的定義(例如:check_inventory、send_email)。
  • Structured Output: Definitions on the format of the model's response, e.g. a JSON object.
    結構化輸出:模型回應格式的定義,例如 JSON 物件。

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.
打造真正有效的 AI 代理,其秘訣與你撰寫的程式碼複雜度關係不大,而與你提供的上下文品質息息相關。

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:
打造代理與你撰寫的程式碼或使用的框架關係不大。「廉價展示」與「神奇」代理之間的差異,在於你提供的上下文品質。想像一個 AI 助理被要求根據一封簡單的電子郵件安排會議:

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.
    用於 send_invite 或 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.
嘿,Jim!我明天行程滿檔,整天都排滿了。如果你週四上午有空的話,那樣可以嗎?我寄了邀請,如果可以的話再跟我說。

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.
這種「魔法」並不在於更聰明的模型或更巧妙的演算法。它在於為正確的任務提供正確的上下文。這就是為什麼上下文工程會很重要。代理(Agent)的失敗不只是模型失敗;它們是上下文的失敗。

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.
情境工程是一門學問,它在設計並建構動態系統,這些系統能夠在正確的時間、以正確的格式提供正確的資訊和工具,讓大型語言模型(LLM)擁有完成任務所需的一切。

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.
    是一個系統,而不是一段字串:情境不只是一個靜態的提示模板。它是主 LLM 呼叫前運行的系統所產生的輸出。
  • 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."
打造強大又可靠的 AI 代理人,越來越不單單是關於找到一個神奇的提示詞或模型更新。而是關於情境工程,以及在正確的時機,以正確的格式提供正確的資訊和工具。這是一個跨職能的挑戰,牽涉到了解你的業務應用情境、定義你的產出,並組織所有必要的資訊,這樣大型語言模型 (LLM) 才能「完成任務」。

Acknowledgements
致謝

This overview was created with the help of deep and manual research, drawing inspiration and information from several excellent resources, including:
這份概述是透過深入的人工研究,並從多個優秀資源中汲取靈感和資訊而完成的,這些資源包括: