Skip to content

fix(langgraph-checkpoint-sqlite): store channel deltas - #2408

Open
Pragnyan Ramtha (pragnyanramtha) wants to merge 5 commits into
langchain-ai:mainfrom
pragnyanramtha:codex/sqlite-newversions-deltas
Open

fix(langgraph-checkpoint-sqlite): store channel deltas#2408
Pragnyan Ramtha (pragnyanramtha) wants to merge 5 commits into
langchain-ai:mainfrom
pragnyanramtha:codex/sqlite-newversions-deltas

Conversation

@pragnyanramtha

Copy link
Copy Markdown
Contributor

Summary

  • respect newVersions in SqliteSaver.put so SQLite checkpoint rows only store changed channel_values
  • keep legacy full checkpoint writes when callers omit newVersions
  • enable the existing checkpoint-validation delta storage conformance test for SQLite
  • add a patch changeset for @langchain/langgraph-checkpoint-sqlite

Fixes #594.

Validation

  • pnpm --filter @langchain/langgraph-checkpoint build:internal
  • pnpm --filter @langchain/langgraph-checkpoint-sqlite build:internal
  • pnpm --filter @langchain/langgraph-checkpoint-sqlite test
  • pnpm --filter @langchain/langgraph-checkpoint-validation exec vitest run src/tests/sqlite.spec.ts
  • pnpm exec oxfmt --check libs/checkpoint-sqlite/src/index.ts libs/checkpoint-validation/src/spec/put.ts .changeset/swift-sqlite-deltas.md
  • pnpm exec oxlint libs/checkpoint-sqlite/src/index.ts libs/checkpoint-validation/src/spec/put.ts
  • git diff --check

@changeset-bot

changeset-bot Bot commented May 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4b8214c

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

This PR includes changesets to release 1 package
Name Type
@langchain/langgraph-checkpoint-sqlite 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

pkg-pr-new Bot commented May 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

@langchain/langgraph-checkpoint

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint@2408

@langchain/langgraph-checkpoint-mongodb

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-mongodb@2408

@langchain/langgraph-checkpoint-postgres

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-postgres@2408

@langchain/langgraph-checkpoint-redis

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-redis@2408

@langchain/langgraph-checkpoint-sqlite

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-sqlite@2408

@langchain/langgraph-checkpoint-validation

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-validation@2408

create-langgraph

npm i https://pkg.pr.new/langchain-ai/langgraphjs/create-langgraph@2408

@langchain/langgraph-api

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-api@2408

@langchain/langgraph-cli

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-cli@2408

@langchain/langgraph

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph@2408

@langchain/langgraph-cua

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-cua@2408

@langchain/langgraph-supervisor

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-supervisor@2408

@langchain/langgraph-swarm

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-swarm@2408

@langchain/langgraph-ui

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-ui@2408

@langchain/langgraph-sdk

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-sdk@2408

@langchain/angular

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/angular@2408

@langchain/react

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/react@2408

@langchain/svelte

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/svelte@2408

@langchain/vue

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/vue@2408

commit: 4b8214c

@pragnyanramtha Pragnyan Ramtha (pragnyanramtha) changed the title fix(checkpoint-sqlite): store channel deltas fix(langgraph-checkpoint-sqlite): store channel deltas May 16, 2026
@pragnyanramtha
Pragnyan Ramtha (pragnyanramtha) marked this pull request as ready for review May 16, 2026 20:17
Copilot AI review requested due to automatic review settings May 16, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@pragnyanramtha

Copy link
Copy Markdown
Contributor Author

After the base refresh, the only red check I see is Browser Tests / sdk-vue.

I checked the job log: the Vue test suite itself passed (103 passed), then Vitest reported an unhandled browser infrastructure error: Failed to connect to the browser session ... [chrome] within the timeout. The same browser suite passed on the adjacent refreshed LangGraphJS PRs, so this looks like a flaky Chrome/session startup failure rather than a SQLite checkpoint regression.

I tried to rerun the failed job/run, but GitHub rejected reruns without repository admin rights. The branch is current with main; all other checks are passing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SqliteSaver serializes the whole checkpoint (including channel_values) into the single checkpoint BLOB and getTuple/list return it verbatim with no parent merge. Filtering channel_values by newVersions at write time, without a version-keyed blob table to reconstruct from on read, means reading checkpoint N returns only the channels that changed in step N — every unchanged channel from prior steps is lost.

This breaks real graph state: channelsFromCheckpoint rebuilds regular (non-Delta) channels purely from checkpoint.channel_values (emptyChannels), so a dropped channel becomes fromCheckpoint(undefined) → empty channel on resume/time-travel/getState.

The correct pattern is already in checkpoint-postgres: _dumpCheckpoint strips channel_values, blobs are stored keyed by (thread_id, ns, channel, version), and _loadCheckpoint/_loadBlobs reconstruct the full channel_values on read via channel_versions. SQLite has none of this.

CI is green because the un-skipped test only stores independent checkpoints and asserts each one's own delta — it never chains checkpoints and reads a later one back to verify full reconstructed state.

Suggested fix: add a version-keyed checkpoint_blobs table, strip channel_values from the checkpoint blob, upsert changed channels in put, reconstruct in getTuple/list from channel_versions, and handle migration of existing inline-channel_values rows. Also extend the conformance test to chain checkpoints and assert the full state on read. As a stopgap, revert to storing full channel_values and keep the test skipped rather than ship lossy persistence.

(Minor: newVersions? is optional here but required in the base class / Postgres.)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SqliteSaver ignores newVersions argument on put - not storing deltas

3 participants