fix(sdk): cache Anthropic Vertex prompts - #6041
Draft
Hunter Lovell (hntrl) wants to merge 3 commits into
Draft
Conversation
Apply the Anthropic prompt-caching middleware to Vertex-hosted Claude models without introducing a hard dependency on the Vertex integration. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Lazily import the optional Vertex integration and use an explicit class check rather than relying on the private model type identifier. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Move Vertex-specific model handling into langchain-google-vertexai and load its middleware through the existing optional provider mechanism. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deep agents now apply automatic prompt caching to Claude models hosted on Vertex AI.
AnthropicPromptCachingMiddlewareonly recognizesChatAnthropic, soChatAnthropicVertexsilently skipped caching even though it accepts the samecache_controlmodel setting. Extend the Deep Agents wrapper to recognize Vertex-hosted Claude through its stable LangChain model type and reuse the existing Anthropic middleware behavior for messages, system prompts, and tools.This avoids a runtime or package dependency on
langchain-google-vertexai; unrelated models remain ignored as before.Made by Open SWE