逐日AI

面试题库

共 328 题,当前筛选 1 题。

5 天上下文工程

D1 上下文是最稀缺的资源:窗口、注意力衰减与成本,从提示词工程走到上下文工程

  • 提示词工程和上下文工程的分界在哪?什么时候该从前者切换到后者?Where is the line between prompt engineering and context engineering, and when do you switch?
    国内高频海外高频进阶#prompt-engineering#context-engineering#scoping

    分析过程 · 先想清楚再作答

    1. 这题最容易答成「上下文工程是提示词工程的升级版」,那是营销话术。面试官想听的是一条能当场用来分类问题的判据。
    2. 怎么拆:先给对象的差别。提示词工程处理的是内容——一段话怎么写才准确;上下文工程处理的是预算分配——整只箱子里各块占多少、什么时候该扔。前者是单次调用内的优化,后者是跨多轮的状态管理。
    3. 再给一条现场可用的分类法,用症状反推:同一个问题问一次答错、换个说法就对,是提示词问题;前五轮正常、第二十轮开始违反最初约束,是上下文问题;明明查到了数据模型却说没有,也是上下文问题——信息在窗口里,只是被淹没了。
    4. 结论:切换的时机不是「提示词写得够好了」,而是「问题的成因从单次表达变成了多轮累积」。加了工具、加了检索、开始多轮长跑,这三件事任何一件发生,都意味着该切换了。
    5. 可预期的追问:那上下文工程包含提示词工程吗?答:系统提示是上下文四块里的一块,所以提示词工程是上下文工程的一个子问题,但它解决不了另外三块——工具定义、历史和工具结果都不是靠把话写好能管住的。

    How to reason about it · think before answering

    1. The trap is answering that context engineering is just prompt engineering leveled up. Interviewers want a rule they can apply to classify a live problem.
    2. Start with the object of each. Prompt engineering shapes content: how to phrase one instruction precisely. Context engineering allocates budget: how much of the window each part gets and when to drop things. One optimizes inside a single call, the other manages state across turns.
    3. Then give a symptom-based test. Wrong once but right after rephrasing means a prompt problem. Fine for five turns and violating the original constraints by turn twenty means a context problem. Retrieving the data and then claiming it does not exist is also a context problem: the information is in the window but buried.
    4. Conclusion: you switch not when the prompt is good enough, but when the cause moves from single-turn phrasing to multi-turn accumulation. Adding tools, adding retrieval, or running long sessions each trigger the switch.
    5. Expect the follow-up: does context engineering subsume prompt engineering? The system prompt is one of the four parts, so prompt engineering is a subproblem, but it cannot touch tool definitions, history, or tool results.

    答题要点

    • 提示词工程处理内容,上下文工程处理预算分配;一个在单次调用内,一个跨多轮。
    • 症状分类法:换个说法就对是提示词问题;跑久了开始违反约束是上下文问题;查到了却说没有也是上下文问题。
    • 切换时机是问题成因从单次表达变成多轮累积,通常发生在加工具、加检索、开始长跑之后。
    • 系统提示只是上下文四块之一,所以写好提示词管不住另外三块。

    Key points

    • Prompt engineering shapes content; context engineering allocates budget across turns.
    • Classify by symptom: fixed by rephrasing is a prompt issue; drifting after many turns is a context issue; retrieved but reported missing is also a context issue.
    • Switch when the cause moves from single-turn phrasing to multi-turn accumulation, typically after adding tools, retrieval, or long-running sessions.
    • The system prompt is one of four parts, so good phrasing alone cannot control the other three.