Files
myWiki/concepts/context-engineering.md

57 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "Context Engineering上下文工程"
created: 2026-05-30
updated: 2026-05-30
type: concept
tags: [context, engineering, agent]
sources: [[agent-harness-engineering-survey]]
confidence: high
---
# Context Engineering
> 三阶段工程演进的第二阶段2025从优化单次模型输入到管理多步推理中模型每步可见的完整信息状态。
## 核心转变
Context Engineering 的关键转变在于从"输入是什么"到"模型在每一步应该看到什么"。
## 指导原则
找到**最小的高信号 token 集**最大化每一步期望结果的概率Anthropic Applied AI Team, 2025
## 三大技术支柱
- **渐进式披露**Progressive Disclosure按需加载信息而非全量预加载
- **压缩**Compaction移除已完成使命的 token
- **记忆检索**:只拉入与当前任务最相关的记录
## 三种故障模式
参见 [[context-failure-modes|上下文故障模式]]
- **Context Starvation**(信息匮乏):数据过少 → 幻觉
- **Context Overflow**(信息过载):噪音稀释注意力
- **Context Rot**(上下文腐烂):窗口越满质量越退化
## 优化策略
- [[minimum-viable-context|MVC最小可行上下文]]:严控单次请求体积
- [[graphrag|GraphRAG]]:实体关系网络取代向量相似度
- [[just-in-time-retrieval|JIT 检索]]:按需实时加载
- [[prefix-matching-invariant|前缀匹配不变性]]:缓存经济学基础
## 上下文包含的内容
在部署的 Agent 中,上下文包括:系统 prompt + 工具定义 + 历史轮次 + 工具调用结果 + 检索文档 + 动态注入的工作状态。所有这些都在争抢有限的注意力预算。
## 三阶段定位
Context Engineering 位于 [[three-engineering-phases|三阶段工程演进]] 的中层——它包含 Prompt Engineering 的实践,同时被 [[agent-harness-engineering|Harness Engineering]] 所扩展。
## 相关概念
- [[three-engineering-phases]] — 三阶段工程演进
- [[context-management]] — C 层:短/中/长期上下文管理
- [[context-drift]] — 上下文漂移的三种退化机制
- [[prompt-to-harness-evolution]] — 详细演化分析