File tree Expand file tree Collapse file tree
libs/deepagents/deepagents Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -135,10 +135,10 @@ def create_deep_agent( # noqa: C901, PLR0912 # Complex graph assembly logic wi
135135 prompt.
136136
137137 If a string, it's concatenated with the base prompt.
138- middleware: Additional middleware to apply after the standard middleware stack
138+ middleware: Additional middleware to apply after the base stack
139139 (`TodoListMiddleware`, `FilesystemMiddleware`, `SubAgentMiddleware`,
140- `SummarizationMiddleware`, `AnthropicPromptCachingMiddleware`,
141- `PatchToolCallsMiddleware`) .
140+ `SummarizationMiddleware`, `PatchToolCallsMiddleware`) but before
141+ `AnthropicPromptCachingMiddleware` and `MemoryMiddleware` .
142142 subagents: Optional subagent specs available to the main agent.
143143
144144 This collection supports three forms:
@@ -291,6 +291,8 @@ def create_deep_agent( # noqa: C901, PLR0912 # Complex graph assembly logic wi
291291
292292 if middleware :
293293 deepagent_middleware .extend (middleware )
294+ # Caching + memory after all other middleware so memory updates don't
295+ # invalidate the Anthropic prompt cache prefix.
294296 deepagent_middleware .append (AnthropicPromptCachingMiddleware (unsupported_model_behavior = "ignore" ))
295297 if memory is not None :
296298 deepagent_middleware .append (MemoryMiddleware (backend = backend , sources = memory ))
You can’t perform that action at this time.
0 commit comments