#3239·deepagents

Generalize caching

Author: mdrxyCreated May 8, 2026Updated Sep 16, 2026
Labelstopic:performancepackage:deepagentsorg:internalpriority:backlogtype:chore

Privileged issue

  • I am a Deep Agents maintainer.

Issue Content

Forward-looking. AnthropicPromptCachingMiddleware is the only vendor-tagged entry in the deep-agents base middleware stack. Concern is generic ("cache reusable prefix"); name leaks the implementation.

Direction

Rename → PromptCachingMiddleware. Anthropic stays the only wired-up provider on day one; structure for additive providers later.

Why

  • unsupported_model_behavior="ignore" already concedes the generic shape — the class anticipates non-Anthropic models.
  • Asymmetric with MemoryMiddleware / SummarizationMiddleware / FilesystemMiddleware, which all describe the concern, not the vendor.
  • Vendor-tagged name pushes if anthropic: ... guards into caller code that shouldn't exist.
  • Provider dispatch fits inside wrap_model_call: branch on the resolved model's provider, delegate to a per-provider helper. Additive for Gemini / OpenAI later, even though their shapes differ (Gemini uses out-of-band CachedContent; OpenAI prefix caching is fully automatic).

Constraints / guardrails

  • Symbol lives in langchain-anthropic today. Coordinate with that package — either rehome to a neutral location or re-export under the new name.
  • Ship PromptCachingMiddleware alongside AnthropicPromptCachingMiddleware as a deprecated alias for at least one minor cycle. No rip-and-replace.
  • Build the dispatch skeleton on day one even though only Anthropic is wired. Otherwise the second provider forces another rename.
  • Docstring must enumerate supported providers ("Currently: Anthropic. Others: no-op.") so the neutral name doesn't mislead users debugging cache hit rate on other providers.
  • Behavior identical for Anthropic in the rename PR. Pure naming + indirection, no semantic drift.

Out of scope

  • Adding Gemini / OpenAI implementations. Separate follow-ups; this issue is the rename + dispatch scaffolding only.

Area (Required)

  • deepagents (SDK)