Repository navigation
fix(deepagents): store full message copies by default, deltas by choice - #1086
Draft
Baihao Wang (byhow) wants to merge 1 commit into
Draft
Baihao Wang (byhow) wants to merge 1 commit into
Baihao Wang (byhow) wants to merge 1 commit into
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: c1a1e6e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
deepagents-acp
deepagents
@langchain/sandbox-standard-tests
@langchain/daytona
@langchain/deno
@langchain/modal
@langchain/node-vfs
@langchain/quickjs
commit: |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
createDeepAgentstores a full copy ofmessagesin 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.
libs/deepagents/src/agent.ts(+1 -2)stateSchemais passed through again.libs/deepagents/src/values.ts(+1 -70)deepAgentStateSchemaand the delta value go, since nothing calls them.libs/deepagents/src/agent.test.ts(+39)libs/deepagents/src/checkpoints.test.ts(+36 -120)stateSchema. The two tests fordeepAgentStateSchemaare deleted with it.agent.test-d.ts,middleware/subagent.test.ts.changeset/delta-messages-opt-in.mdagent.tsandvalues.tsare byte-identical to the code before #1058.Two choices worth a reviewer's opinion:
MessagesDeltaValuethroughstateSchema, so this adds no deepagents API. That value stores a full copy every 100 updates. 1.17.0 stored one every 50.deepagents-acpchange and the dependency floors from fix(deepagents): store deep agent messages as deltas, snapshot every 50 #1058 stay. See "What stays from fix(deepagents): store deep agent messages as deltas, snapshot every 50 #1058".The problem
#1058 made deep agents store
messagesin 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:
ShallowRedisSaverRedisSaver, 5 s TTLMongoDBSaver, 5 s TTLMessagesDeltaValueand 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-postgres1.0.6 or@langchain/langgraph-checkpoint-mongodb1.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
createDeepAgentpasses the caller'sstateSchemathrough unchanged.agent.tsandvalues.tsare byte-identical to the code before fix(deepagents): store deep agent messages as deltas, snapshot every 50 #1058.messageswith LangGraph's ownMessagesDeltaValueinstateSchema. No new deepagents API:What stays from #1058
checkpoints.test.ts. They now run through thatstateSchema, 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.deepagents-acpchange that readssession/loadhistory through the agent's state. Threads saved by 1.17.0 still hold delta checkpoints.@langchain/langgraph-checkpointreloads 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,
updateStateedits, 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.libs/deepagents.@langchain/langgraph1.7.5 with the Postgres 1.1.4, Redis 1.1.2 and MongoDB 1.5.2 savers.Not covered
updateStateedits, summarization, and a run that crashes mid-step.Related
messagesandfilesin checkpoints by default deepagents#7841 makes the same change in Python, wherefilesare affected too. It depends on chore(deps): requirelanggraph1.2.16 or newer indeepagentsdeepagents#7840.🤖 Generated with Claude Code