L1S3 · 模型与编排S6 · 安全与成本Verified: 2026-11-17
Stage 3 · 主从 Subagent Context 隔离与 Map-Reduce 分治模式
解决单一超级 Agent 上下文被 20 个文件检索输出和冗长试错日志淹没导致的“上下文腐烂(Context Rot)”失智难题:由 Orchestrator 派发干净上下文的窄作用域 Subagent 并行研究,仅回传精炼结构化摘要,主线程 Token 消耗下降 70%。
适用场景 (Best For)
大型代码仓重构审计、50 份长财报跨文档比对及多数据源深研综述(Deep Research)等重上下文吞吐任务。
人机边界 (Human-AI Boundary)
主调度器与子代理共享全局步数/预算熔断器与只读沙箱策略,禁止子代理擅自向外部发起未审计的写请求或再次递归拉起无上限子任务。
常见反模式与避坑 (Anti-Patterns)
- Passing full parent conversation history (100k tokens) plus raw web HTML dumps into every worker step sequentially
- Allowing unbounded recursive Subagent spawning without max depth = 1–2 and global token budget limits
延迟成本与评测门禁
Parallel fan-out cuts wall-clock duration by Nx worker count · Sum of isolated narrow worker contexts << single bloated quadratic-cost history
- Context Overhead Compression Ratio: Worker return summary <= 15% of raw retrieved input tokens with >= 95% key-fact recall (Enforce strict Pydantic artifact schema on Subagent handoff payloads)
💰 商业 ROI 模型与证据等级
production_practice对比单线程不断累加历史的 ReAct 长链(每步重算全量上下文),Map-Reduce Context 隔离在多文档审计任务中可将总 Input Token 账单减少 60%–75% 同时提升端到端准确率。
🏗️ 端到端系统架构流水线
Step 1: Map 阶段:按文档/目录分片并派发洁净上下文 Subagent
Orchestrator 将总任务切分为互不重叠切片,每个 Subagent 仅携带任务指令与自身工具配额独立并行执行。
Step 2: Reduce 阶段:Schema 契约回传与冲突消解
Worker 将几十 KB 原始日志压缩为固定字段的证据引用 JSON,Coordinator 校验交叉一致性并生成最终结论。
⚖️ 工程选型与架构权衡矩阵
Orchestrator + Isolated Map-Reduce Workers
适用条件:跨 >5 个大文件/网页、上下文超过 30k tokens 的研究/审计流。
核心权衡:跨边界状态传递需精确定义输入输出 Schema 防止关键背景漏传。
Single-Thread Iterative Agent
适用条件:紧密耦合的单文件局部调试或小于 5 步的连续思考。
核心权衡:状态天然连续零交接损耗,但在大任务中极易发生上下文溢出。
🚨 生产失效模式与可观测特征
- Subagents hallucinating missing global constraints when the coordinator writes vague underspecified shard briefs
- Parallel worker fan-out overwhelming downstream database or API rate limits without concurrency semaphores
⚡
想检验本题的肌肉记忆?进入 3 阶闪卡主动回忆盲测
隐藏答案遮罩,自测:审题锚点 ➔ 数理公式机理 ➔ 工业标杆代码与连环追问。3 分钟攻破认知盲区!
上下游关联知识链路
[L2] L2 系统设计 · 大规模云端 Coding Agent 安全沙箱调度与文件快照架构[L2] L2 行业图谱 · 研发效能平台、代码审查与自动化故障定位全景[L2] L2 业务场景 · SRE 故障告警聚类、日志取证与根因定位 Agent 方案[L2] L2 产品拆解 · Claude Code Agent Harness 设计、Subagent 委派与前缀缓存经济学[L3] 项目实战:带状态机止损门控的 SRE 告警取证与根因定位 Copilot[L0 Card] ReAct / Plan-Execute / Reflexion[L0 Card] Agent 循环硬终止与死循环检测[L0 Card] Multi-Agent 角色扮演与群聊协同[L0] LangGraph 有状态编排、Checkpointer 断点续跑与人工中断原语[L0] Agent 多步轨迹与工具调用失败归因评测原语[L0] SGLang RadixAttention 自动前缀复用与零拷贝调度引擎
站内交互工具与信源依据
- Anthropic — Building Effective Agents (Orchestrator-Workers & Subagent Isolation) (engineering_blog, 2026-11-17)