> ## 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.

# Middleware

> Zeus DeepAgents Middleware System

## Overview

Zeus uses the DeepAgents framework's middleware mechanism to inject additional capabilities during Agent execution. Middleware executes in order, each handling specific concerns.

## Middleware List

### SummarizationMiddleware

Automatically summarizes long conversation histories to avoid exceeding the model's context window.

* **Model Profiles**: The system includes built-in context window configurations for common models (e.g., gpt-4-turbo: 128K input / 4K output, gpt-4o: 128K input / 16K output, claude-3-5-sonnet: 200K input / 8K output). Default configuration is used when a model is not in the predefined list.
* **Trigger Condition**: Summarization is triggered when token count reaches 85% of `max_input_tokens`.
* **Retention Policy**: Always retains the most recent 5 messages; older messages are compressed into summaries.

### FilesystemMiddleware

Provides filesystem operation capabilities, supporting configuration of working directories and allowed file extensions.

### AnthropicPromptCachingMiddleware

Enables prompt caching (ephemeral mode) for Anthropic models, reducing repeated System Prompt token billing across multi-turn conversations.

### PatchToolCallsMiddleware

Automatically repairs malformed JSON tool calls, supporting up to 3 automatic retries.
