Skip to content

fix(deepagents): store full message copies by default, deltas by choice - #1086

Draft
Baihao Wang (byhow) wants to merge 1 commit into
mainfrom
byhow/deepagents/delta-messages-opt-in
Draft

Baihao Wang (byhow) wants to merge 1 commit into
mainfrom
byhow/deepagents/delta-messages-opt-in

Conversation

@byhow

@byhow Baihao Wang (byhow) commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

TL;DR

createDeepAgent stores a full copy of messages in every checkpoint again, as it did before 1.17.0. Storing them as deltas becomes something the caller chooses. This fixes silent message loss in 1.17.0 on checkpoint savers that delete or expire old checkpoints.

Review guide

One commit, 7 files, +102 / -204.

File What to look at
libs/deepagents/src/agent.ts (+1 -2) The change. stateSchema is passed through again.
libs/deepagents/src/values.ts (+1 -70) Deletion only. deepAgentStateSchema and the delta value go, since nothing calls them.
libs/deepagents/src/agent.test.ts (+39) New test: every checkpoint holds the conversation so far. It fails if the default goes back to deltas.
libs/deepagents/src/checkpoints.test.ts (+36 -120) Mostly mechanical. The delta tests now pass a delta stateSchema. The two tests for deepAgentStateSchema are deleted with it.
agent.test-d.ts, middleware/subagent.test.ts Back to their state before #1058.
.changeset/delta-messages-opt-in.md The user-facing note, including saver versions.

agent.ts and values.ts are byte-identical to the code before #1058.

Two choices worth a reviewer's opinion:

The problem

#1058 made deep agents store messages in LangGraph's delta channel by default. Each checkpoint then holds only that step's new messages, and loading a thread walks back through earlier checkpoints to rebuild the list. A saver that removes old checkpoints removes part of the conversation, and the load returns what is left without an error.

Measured on the published packages, with a scripted model and local databases:

Saver Run Expected 1.16.5 1.17.0 This PR
ShallowRedisSaver 3 invokes 18 18 0 18
RedisSaver, 5 s TTL 8 invokes, 1.5 s apart 32 32 12 32
MongoDBSaver, 5 s TTL 8 invokes, 1.5 s apart 32 32 12 32
  • On the shallow saver the model received only the new human message on every invoke.
  • The TTL is short to keep the test quick. A thread loses history when it takes longer than the TTL to reach its next full copy.
  • Plain LangGraph with MessagesDeltaValue and no deepagents loses messages the same way, and so does Python deepagents 0.7.40. The cause is in the delta channel's load and the savers. This PR does not fix that. It stops deep agents from depending on it by default.

A second difference showed up on saver releases older than October 12. With @langchain/langgraph-checkpoint-postgres 1.0.6 or @langchain/langgraph-checkpoint-mongodb 1.4.2, 1.17.0 reloads the results of parallel tool calls in a different order than the calls. Nothing in deepagents' dependencies requires a newer saver.

What changes

const agent = createDeepAgent({
  stateSchema: new StateSchema({ messages: MessagesDeltaValue }),
});
  • Removing a message whose id is not in the state throws again, unless the caller stores deltas.

What stays from #1058

  • The delta tests in checkpoints.test.ts. They now run through that stateSchema, so the path stays covered: full copy cadence, reload matching full copies with stable ids, parallel tool results in call order, tool approval past a full copy, summarization, and continuing a full-copy thread.
  • The deepagents-acp change that reads session/load history through the agent's state. Threads saved by 1.17.0 still hold delta checkpoints.
  • The dependency floors. An older @langchain/langgraph-checkpoint reloads the parallel tool results of a 1.17.0 thread out of call order.

Threads already saved by 1.17.0

They still load. LangGraph rebuilds the list from the stored deltas, and the next checkpoint stores a full copy.

I ran 9 thread shapes on Postgres, Redis and MongoDB: threads written by 1.17.0, then read and continued by this build. The shapes are plain turns with parallel tool calls, a pending tool approval, a tool failure followed by new input, a model failure followed by new input, a subagent call, summarization, more than 100 updates, updateState edits, and a fork from an earlier checkpoint. Message content matched a 1.16.5-only run in all 81 threads. On the failed-tool threads, one pending tool result has a different id, and one state-history entry counts one message more. That history difference showed on Postgres in all three takeover runs and on Redis in one. Messages a saver already removed do not come back.

I also ran this on a deployed Agent Server. One LangSmith dev deployment was redeployed from 1.16.5 to 1.17.0 and then to this PR's build. Five threads were created on 1.16.5: parallel tool calls, a pending tool approval, a tool error, more than 100 updates, and a subagent call. At both switches every thread read back identical, ids included, and then continued. The pending approval resumed on the next build each time.

Verification

  • libs/deepagents: 1,820 passed, 12 skipped. libs/acp: 172 passed.
  • Typecheck, lint and format are clean for libs/deepagents.
  • The table above and the 81 takeover threads ran against a build of this branch, on @langchain/langgraph 1.7.5 with the Postgres 1.1.4, Redis 1.1.2 and MongoDB 1.5.2 savers.

Not covered

  • On the deployed Agent Server: forks, updateState edits, summarization, and a run that crashes mid-step.
  • SQLite.
  • This build on the older Postgres and MongoDB savers. The changeset tells anyone with threads saved by 1.17.0 to use the newer releases.
  • With full copies, the kept acp test also passes without the acp change, so no committed test guards that change for 1.17.0 threads.

Related

🤖 Generated with Claude Code

createDeepAgent 1.17.0 stored messages in a delta channel by default. A
checkpoint saver that deletes or expires old checkpoints (a shallow saver, or
one with a TTL) then loses the messages held only in the checkpoints it
removed, without an error.

createDeepAgent passes the caller's stateSchema through again, so messages
are full copies unless the schema declares them with LangGraph's
MessagesDeltaValue. The delta tests stay and run through that schema. The
acp session/load read through graph.getState and the dependency floors stay,
because threads saved by 1.17.0 still hold delta checkpoints.
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
deepagentsjs-ui Ready Ready Preview Nov 19, 2026 1:28am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c1a1e6e

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

This PR includes changesets to release 2 packages
Name Type
deepagents Patch
deepagents-acp 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

@robin-agent robin-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Robin Review: No issues found

Robin reviewed this PR and found no potential bugs to report.

Open in Robin

@pkg-pr-new

pkg-pr-new Bot commented Nov 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

deepagents-acp

npm i https://pkg.pr.new/deepagents-acp@1086

deepagents

npm i https://pkg.pr.new/deepagents@1086

@langchain/sandbox-standard-tests

npm i https://pkg.pr.new/@langchain/sandbox-standard-tests@1086

@langchain/daytona

npm i https://pkg.pr.new/@langchain/daytona@1086

@langchain/deno

npm i https://pkg.pr.new/@langchain/deno@1086

@langchain/modal

npm i https://pkg.pr.new/@langchain/modal@1086

@langchain/node-vfs

npm i https://pkg.pr.new/@langchain/node-vfs@1086

@langchain/quickjs

npm i https://pkg.pr.new/@langchain/quickjs@1086

commit: c1a1e6e

This branch was successfully deployed

1 active deployment
Preview — c1a1e6e5 Deployed Nov 19, 2026 by vercel[bot]
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