Skip to content

Commit c1c1fc8

Browse files
committed
update comments
1 parent f2bb9d7 commit c1c1fc8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

libs/deepagents/deepagents/graph.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff 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))

0 commit comments

Comments
 (0)