Skip to content

fix(sdk): cache Anthropic Vertex prompts - #6041

Draft
Hunter Lovell (hntrl) wants to merge 3 commits into
mainfrom
hntrl/deepagents/vertex-prompt-caching
Draft

fix(sdk): cache Anthropic Vertex prompts#6041
Hunter Lovell (hntrl) wants to merge 3 commits into
mainfrom
hntrl/deepagents/vertex-prompt-caching

Conversation

@hntrl

@hntrl Hunter Lovell (hntrl) commented Sep 3, 2026

Copy link
Copy Markdown
Member

Deep agents now apply automatic prompt caching to Claude models hosted on Vertex AI.


AnthropicPromptCachingMiddleware only recognizes ChatAnthropic, so ChatAnthropicVertex silently skipped caching even though it accepts the same cache_control model 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

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>
@github-actions github-actions Bot changed the title fix(deepagents): cache Anthropic Vertex prompts fix(sdk): cache Anthropic Vertex prompts Sep 3, 2026
@github-actions github-actions Bot added deepagents Related to the `deepagents` SDK / agent harness fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: S 50-199 LOC labels Sep 3, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepagents Related to the `deepagents` SDK / agent harness fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant