Skip to content

Revisit memory middleware cache boundaries across model providers #6522

Description

@open-swe

Filed on behalf of Sydney Runkle (@sydney-runkle), at her request, following a discussion with the Managed Deep Agents (MDA) team.

Area

  • deepagents (SDK)

Issue Content

Revisit the prompt-cache boundary in MemoryMiddleware and how it composes with provider-aware prompt caching. MDA's proposed memory middleware copies Deep Agents' Anthropic-only cache-control logic and emits ordinary text for other providers. That avoids sending Anthropic markers to unsupported providers, but does not settle caching behavior for the other models developers can select.

MDA has shared agent memory and private user memory, with per-run allow callbacks deciding which layers are mounted. Its proposed loader refreshes content before each model call and injects it into the request without checkpointing a memory_contents field. Content can therefore differ between callers/runs and after writes within a run.

Questions / desired outcome

  • Evaluate cache boundaries around stable instructions versus changing memory. Quantify cache reads/writes and cost rather than assuming caching memory is always good or always bad.
  • Review middleware ordering and interaction with other cache markers, including Anthropic breakpoint limits and TTL configuration.
  • Account for provider differences: Anthropic explicit markers, OpenAI automatic prefix caching, and Gemini's distinct explicit-cache lifecycle. Unsupported providers should continue to receive valid requests.
  • Decide which behavior belongs in a generalized caching middleware versus memory-specific assembly; document supported providers and no-op behavior clearly.
  • Test unchanged memory, edited memory, switched callers, and denied/removed layers. Cache decisions must not bypass current-run memory authorization.

Related work

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    org:internalIssue or pull request created by a member of the `langchain-ai` GitHub organization.package:deepagentsChanges related to the `deepagents` SDK and agent harness.priority:backlogNot currently planned/prioritized work, often affecting a limited feature or set of users.topic:memoryAgent memory and persistent context.topic:middlewareMiddleware behavior and composition.topic:performancePerformance, resource usage, and cost optimization.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions