> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeus.agentspro.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 中间件

> Zeus DeepAgents 中间件系统

## 概述

Zeus 使用 DeepAgents 框架的中间件机制，在 Agent 执行过程中注入额外能力。中间件按顺序执行，各自处理特定的关注点。

## 中间件列表

### SummarizationMiddleware

自动摘要长对话历史，避免超出模型上下文窗口。

* **模型 Profile**：系统内置了常见模型的上下文窗口配置（如 gpt-4-turbo: 128K input / 4K output，gpt-4o: 128K input / 16K output，claude-3-5-sonnet: 200K input / 8K output）。当模型不在预定义列表中时，使用默认配置。
* **触发条件**：当 token 数达到 `max_input_tokens` 的 85% 时触发摘要。
* **保留策略**：始终保留最近的 5 条消息，较早的消息被压缩为摘要。

### FilesystemMiddleware

提供文件系统操作能力，支持配置工作目录和允许的文件扩展名。

### AnthropicPromptCachingMiddleware

为 Anthropic 模型启用提示词缓存（ephemeral 模式），减少多轮对话中 System Prompt 的重复 token 计费。

### PatchToolCallsMiddleware

自动修复畸形的 JSON 工具调用，支持最多 3 次自动重试。
