[PR #471] [MERGED] feat(checkpoint-postgres): Postgres checkpointer #786

Closed
opened 2026-02-15 19:15:53 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/471
Author: @l4b4r4b4b4
Created: 9/8/2024
Status: Merged
Merged: 10/8/2024
Merged by: @jacoblee93

Base: mainHead: feature/checkpoint-postgres


📝 Commits (10+)

📊 Changes

26 files changed (+1475 additions, -11 deletions)

View changed files

📝 .gitignore (+2 -1)
int-test-deps-docker-compose.yml (+18 -0)
libs/checkpoint-postgres/.env.example (+6 -0)
libs/checkpoint-postgres/.eslintrc.cjs (+69 -0)
libs/checkpoint-postgres/.gitignore (+7 -0)
libs/checkpoint-postgres/.prettierrc (+19 -0)
libs/checkpoint-postgres/.release-it.json (+13 -0)
libs/checkpoint-postgres/LICENSE (+21 -0)
libs/checkpoint-postgres/README.md (+75 -0)
libs/checkpoint-postgres/docker-compose.yml (+16 -0)
libs/checkpoint-postgres/jest.config.cjs (+20 -0)
libs/checkpoint-postgres/jest.env.cjs (+12 -0)
libs/checkpoint-postgres/langchain.config.js (+21 -0)
libs/checkpoint-postgres/package.json (+92 -0)
libs/checkpoint-postgres/src/index.ts (+476 -0)
libs/checkpoint-postgres/src/migrations.ts (+40 -0)
libs/checkpoint-postgres/src/sql.ts (+66 -0)
libs/checkpoint-postgres/src/tests/checkpoints.int.test.ts (+207 -0)
libs/checkpoint-postgres/tsconfig.cjs.json (+8 -0)
libs/checkpoint-postgres/tsconfig.json (+23 -0)

...and 6 more files

📄 Description

Add PostgreSQL Checkpoint Saver Implementation

This PR introduces a PostgreSQL-based checkpoint saver implementation for LangGraph.js. This new PostgresSaver class provides an alternative to the existing SqliteSaver, allowing users to leverage PostgreSQL databases for storing and managing checkpoints in their LangGraph applications.

Key Changes

  1. Added PostgresSaver class that implements the BaseCheckpointSaver interface.
  2. Implemented PostgreSQL-specific versions of setup, getTuple, list, put, and putWrites methods.
  3. Updated the checkpointer to use PostgreSQL connection pooling for improved performance and resource management.
  4. Added support for checkpoint_ns (namespace) in all relevant methods and database operations.
  5. Ported unit tests from SqliteSaver for the new PostgresSaver class.

Benefits

  • Allows users to integrate LangGraph.js with existing PostgreSQL infrastructure.
  • Provides better scalability and concurrent access compared to SQLite for larger applications.
  • Maintains feature parity with the existing SqliteSaver implementation.

Testing

The PR includes a full suite of unit tests that cover all major functionalities of the PostgresSaver class. These tests ensure that the PostgreSQL implementation behaves consistently with the existing SQLite implementation.

Start up PosgreSQL test instance by running the following command in the module directory.

docker-compose up -d && docker-compose logs -f
yarn && yarn test

grafik
grafik

Usage

Users can create a PostgresSaver instance like this:

import { PostgresSaver } from "@langchain/langgraph-checkpoint";

const postgresSaver = PostgresSaver.fromConnString("postgresql://user:password@localhost:5432/dbname");

---

<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraphjs/pull/471 **Author:** [@l4b4r4b4b4](https://github.com/l4b4r4b4b4) **Created:** 9/8/2024 **Status:** ✅ Merged **Merged:** 10/8/2024 **Merged by:** [@jacoblee93](https://github.com/jacoblee93) **Base:** `main` ← **Head:** `feature/checkpoint-postgres` --- ### 📝 Commits (10+) - [`f704d32`](https://github.com/langchain-ai/langgraphjs/commit/f704d32b4b894e306460ceb6d9a518d82a0368e5) postgres sceleton - [`8a3ad9d`](https://github.com/langchain-ai/langgraphjs/commit/8a3ad9d9696af9f82e95d18dcb3b5fe7e8ed5848) postgres checkpoint - [`ec49a5d`](https://github.com/langchain-ai/langgraphjs/commit/ec49a5d78224ebdc38ed1329c95d0a9cb5bc58ac) changed container name - [`4cf7651`](https://github.com/langchain-ai/langgraphjs/commit/4cf76518bf77d5428432d504079dfcee83f4287b) Merge branch 'main' into feature/checkpoint-postgres - [`447ae8b`](https://github.com/langchain-ai/langgraphjs/commit/447ae8baf0a4ea843482c5e93efeb2ccc45e5a52) yarn.lock - [`3b94778`](https://github.com/langchain-ai/langgraphjs/commit/3b9477810a4ccf20c800f78b578039bf53403beb) Merge - [`95ba4a5`](https://github.com/langchain-ai/langgraphjs/commit/95ba4a5e71ce1a3c8c776eb7aa7ba0f87b3d03f1) Add migration support, checkpoint_blobs table, refactor other methods - [`167cd1c`](https://github.com/langchain-ai/langgraphjs/commit/167cd1c1d94cef18a082490bbcec477d63382914) Merge branch 'main' of https://github.com/langchain-ai/langgraphjs into 471 - [`e237684`](https://github.com/langchain-ai/langgraphjs/commit/e2376847aa9adc5383757e8d49e97f8b076be95a) Extends Postgres checkpointer - [`71ff5e5`](https://github.com/langchain-ai/langgraphjs/commit/71ff5e53737c3af2aa9bcb3823c31a2f0b4ef29e) Add int test ### 📊 Changes **26 files changed** (+1475 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+2 -1) ➕ `int-test-deps-docker-compose.yml` (+18 -0) ➕ `libs/checkpoint-postgres/.env.example` (+6 -0) ➕ `libs/checkpoint-postgres/.eslintrc.cjs` (+69 -0) ➕ `libs/checkpoint-postgres/.gitignore` (+7 -0) ➕ `libs/checkpoint-postgres/.prettierrc` (+19 -0) ➕ `libs/checkpoint-postgres/.release-it.json` (+13 -0) ➕ `libs/checkpoint-postgres/LICENSE` (+21 -0) ➕ `libs/checkpoint-postgres/README.md` (+75 -0) ➕ `libs/checkpoint-postgres/docker-compose.yml` (+16 -0) ➕ `libs/checkpoint-postgres/jest.config.cjs` (+20 -0) ➕ `libs/checkpoint-postgres/jest.env.cjs` (+12 -0) ➕ `libs/checkpoint-postgres/langchain.config.js` (+21 -0) ➕ `libs/checkpoint-postgres/package.json` (+92 -0) ➕ `libs/checkpoint-postgres/src/index.ts` (+476 -0) ➕ `libs/checkpoint-postgres/src/migrations.ts` (+40 -0) ➕ `libs/checkpoint-postgres/src/sql.ts` (+66 -0) ➕ `libs/checkpoint-postgres/src/tests/checkpoints.int.test.ts` (+207 -0) ➕ `libs/checkpoint-postgres/tsconfig.cjs.json` (+8 -0) ➕ `libs/checkpoint-postgres/tsconfig.json` (+23 -0) _...and 6 more files_ </details> ### 📄 Description # Add PostgreSQL Checkpoint Saver Implementation This PR introduces a PostgreSQL-based checkpoint saver implementation for LangGraph.js. This new `PostgresSaver` class provides an alternative to the existing `SqliteSaver`, allowing users to leverage PostgreSQL databases for storing and managing checkpoints in their LangGraph applications. ## Key Changes 1. Added `PostgresSaver` class that implements the `BaseCheckpointSaver` interface. 2. Implemented PostgreSQL-specific versions of `setup`, `getTuple`, `list`, `put`, and `putWrites` methods. 3. Updated the checkpointer to use PostgreSQL connection pooling for improved performance and resource management. 4. Added support for `checkpoint_ns` (namespace) in all relevant methods and database operations. 5. Ported unit tests from SqliteSaver for the new `PostgresSaver` class. ## Benefits - Allows users to integrate LangGraph.js with existing PostgreSQL infrastructure. - Provides better scalability and concurrent access compared to SQLite for larger applications. - Maintains feature parity with the existing `SqliteSaver` implementation. ## Testing The PR includes a full suite of unit tests that cover all major functionalities of the `PostgresSaver` class. These tests ensure that the PostgreSQL implementation behaves consistently with the existing SQLite implementation. Start up PosgreSQL test instance by running the following command in the module directory. ```bash docker-compose up -d && docker-compose logs -f yarn && yarn test ``` ![grafik](https://github.com/user-attachments/assets/780b2b03-a466-41cb-930e-b8dcdb6fef4c) ![grafik](https://github.com/user-attachments/assets/75dec0e5-0e7d-46a5-9b78-1480ecb7f062) ## Usage Users can create a `PostgresSaver` instance like this: ```typescript import { PostgresSaver } from "@langchain/langgraph-checkpoint"; const postgresSaver = PostgresSaver.fromConnString("postgresql://user:password@localhost:5432/dbname"); --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 19:15:53 -05:00
yindo closed this issue 2026-02-15 19:15:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#786