# Deep Insight用四层上下文工程管理生产AI代理的上下文窗口

> AWS机器学习博客2026年11月4日发文，以Deep Insight为参考实现，介绍数据分析和报告生成等任务如何以代码实现四层上下文工程，重点说明多代理隔离等做法如何管理AI代理的上下文窗口。

- 栏目：人工智能与云计算
- 本站发布：2026-11-05 19:48（北京时间）
- 原始消息发布：2026-11-05 00:30（北京时间）
- 消息来源：AWS 机器学习博客 (https://aws.amazon.com/blogs/machine-learning/four-layers-of-context-engineering-for-production-ai-agents-how-deep-insight-applies-them-in-working-code/)
- 本页网址：https://jecy.cloud/news/articles/2026-11-04-e1af5e5ff824.html

## 一个报告任务可消耗超过150K token

AWS机器学习博客2026年11月4日发布的文章以Deep Insight为参考实现，讨论生产级AI代理的上下文工程。文章举例称，Amazon Bedrock上的Claude Sonnet 4.5提供200K token的上下文窗口，但复杂生产任务仍会很快超出：一个任务包括数据加载与探索、分类销售分析、生成五张图表、统计验证和报告生成，合计消耗超过150K token，用时15分钟。上下文窗口指模型一次能处理的文本范围，token是模型处理和计费的文本单位。文章指出，若把整个流程放在单一上下文中，会出现任务中途窗口溢出、陈旧上下文拉低表现、出错后需重跑整个流程等问题。[^1][^2][^3]

## 四层做法逐层补缺

文章把上下文工程定义为优化大语言模型有限上下文窗口中的信息，让代理尽量发挥能力；这项工作横跨架构设计、提示编写、工具实现和验证。Deep Insight将相关技巧归为四层，每一层弥补上一层的不足，四层并非相互替代。文章详述的第一层是多代理架构隔离上下文：给每个专门代理自己的上下文窗口，只把压缩后的结果交给编排器，而不是传递完整对话历史。[^4][^5][^6]

## 参考实现中的隔离做法

文章以Deep Insight这一多代理数据分析方案为参考实现，展示这些层次在代码中的落地方式。以隔离层为例，各专门代理在自己的窗口内工作，编排器只接收压缩结果，不再共用一个不断膨胀的上下文。文章同时指出，单靠隔离不够，还需要提示控制、工具实现和验证等层次配合；文中所述做法来自该参考实现。[^4][^5][^6]

---

## 原文摘录

[^1]: "Anthropic Claude Sonnet 4.5, available on Amazon Bedrock, offers a 200K context window, but complex production tasks quickly exceed it." — AWS 机器学习博客 (https://aws.amazon.com/blogs/machine-learning/four-layers-of-context-engineering-for-production-ai-agents-how-deep-insight-applies-them-in-working-code/)
[^2]: "Together they consume over 150K tokens across 15 minutes." — AWS 机器学习博客 (https://aws.amazon.com/blogs/machine-learning/four-layers-of-context-engineering-for-production-ai-agents-how-deep-insight-applies-them-in-working-code/)
[^3]: "Processing such tasks in a single context causes problems: the window overflows mid-task, stale context degrades performance, and errors require re-running the whole pipeline." — AWS 机器学习博客 (https://aws.amazon.com/blogs/machine-learning/four-layers-of-context-engineering-for-production-ai-agents-how-deep-insight-applies-them-in-working-code/)
[^4]: "Spanning architecture design, prompt writing, tool implementation, and verification, it’s a layered discipline where each layer compensates for what the previous ones miss." — AWS 机器学习博客 (https://aws.amazon.com/blogs/machine-learning/four-layers-of-context-engineering-for-production-ai-agents-how-deep-insight-applies-them-in-working-code/)
[^5]: "Deep Insight groups these techniques into four layers, with each layer addressing the limitations of the others." — AWS 机器学习博客 (https://aws.amazon.com/blogs/machine-learning/four-layers-of-context-engineering-for-production-ai-agents-how-deep-insight-applies-them-in-working-code/)
[^6]: "Isolating context through multi-agent architecture Give each specialized agent its own context window and pass only compressed results to the orchestrator." — AWS 机器学习博客 (https://aws.amazon.com/blogs/machine-learning/four-layers-of-context-engineering-for-production-ai-agents-how-deep-insight-applies-them-in-working-code/)

---

说明：本文由 AI 依据信源整理，并经事实核对；文中数字与成绩均为来源方公布的口径，未经本站独立验证，原文更新后以原文为准。欢迎 AI 与读者引用，请注明来源并链接回本页。
