Skip to content

fix(deepagents): reorder middleware so prompt caching and memory run last#331

Merged
Hunter Lovell (hntrl) merged 2 commits intomainfrom
hunter/middleware-reorder
Mar 20, 2026
Merged

fix(deepagents): reorder middleware so prompt caching and memory run last#331
Hunter Lovell (hntrl) merged 2 commits intomainfrom
hunter/middleware-reorder

Conversation

@hntrl
Copy link
Copy Markdown
Member

Summary

Port of langchain-ai/deepagents#2070 to JS.

  • Move anthropicPromptCachingMiddleware and memoryMiddleware after all static and user-supplied middleware
  • Ensures updates to memory contents do not invalidate Anthropic prompt caches

System message ordering becomes:

base prompt
todos
skills
filesystem
task
(any user-supplied / custom middleware)
<cache point> <---
memory contents and guidelines

…last

Move anthropicPromptCachingMiddleware and memoryMiddleware after all static
and user-supplied middleware so that updates to memory contents do not
invalidate Anthropic prompt caches.

Port of langchain-ai/deepagents#2070.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 19, 2026

🦋 Changeset detected

Latest commit: 775562f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
deepagents Patch
deepagents-acp Patch
@deepagents/evals Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 20, 2026

Open in StackBlitz

npm i https://pkg.pr.new/deepagents-acp@331
npm i https://pkg.pr.new/deepagents@331
npm i https://pkg.pr.new/@langchain/sandbox-standard-tests@331

commit: 775562f

@hntrl Hunter Lovell (hntrl) merged commit 759fe19 into main Mar 20, 2026
15 checks passed
@hntrl Hunter Lovell (hntrl) deleted the hunter/middleware-reorder branch March 20, 2026 18:36
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
Colin Francis (colifran) pushed a commit that referenced this pull request Mar 24, 2026
…last (#331)

* fix(deepagents): reorder middleware so prompt caching and memory run last

Move anthropicPromptCachingMiddleware and memoryMiddleware after all static
and user-supplied middleware so that updates to memory contents do not
invalidate Anthropic prompt caches.

Port of langchain-ai/deepagents#2070.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant