The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
docs(anthropic): clarify prompt caching middleware docstring (#38206)
Mason Daughertyf88d4f02126d
diff --git a/libs/partners/anthropic/langchain_anthropic/middleware/prompt_caching.py b/libs/partners/anthropic/langchain_anthropic/middleware/prompt_caching.pyindex 395e742173..db265bbc57 100644--- a/libs/partners/anthropic/langchain_anthropic/middleware/prompt_caching.py+++ b/libs/partners/anthropic/langchain_anthropic/middleware/prompt_caching.py@@ -39,14 +39,17 @@ class AnthropicPromptCachingMiddleware(AgentMiddleware):Requires both `langchain` and `langchain-anthropic` packages to be installed.- Applies cache control breakpoints to:+ The middleware tags stable agent content and passes `cache_control` through+ `model_settings`:- **System message**: Tags the last content block of the system messagewith `cache_control` so static system prompt content is cached.- - **Tools**: Tags all tool definitions with `cache_control` so tool- schemas are cached across turns.- - **Last cacheable block**: Tags last cacheable block of message sequence using- Anthropic's automatic caching feature.+ - **Tools**: Tags the last tool definition with `cache_control`. Because+ tool definitions are sent as one contiguous block, a single trailing+ breakpoint caches the entire tool set across turns.+ - **`model_settings`**: Passes `cache_control` to the chat model. The chat+ model/provider then applies the correct message-tail and+ provider-specific behavior at request time.Learn more about Anthropic prompt caching[here](https://platform.claude.com/docs/en/build-with-claude/prompt-caching).