Skip to content

Commit

Permalink
fix: PostgresSaver doesn't store channel_values correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincburns committed Oct 10, 2024
1 parent 45e59e6 commit c8ae5dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 5 additions & 4 deletions libs/checkpoint-postgres/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ export class PostgresSaver extends BaseCheckpointSaver {
* @param config The config to use for retrieving the checkpoint.
* @returns The retrieved checkpoint tuple, or undefined.
*/
async getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined> {
async getTuple(
config: RunnableConfig
): Promise<CheckpointTuple | undefined> {
const {
thread_id,
checkpoint_ns = "",
Expand Down Expand Up @@ -416,8 +418,7 @@ export class PostgresSaver extends BaseCheckpointSaver {
async put(
config: RunnableConfig,
checkpoint: Checkpoint,
metadata: CheckpointMetadata,
newVersions: ChannelVersions
metadata: CheckpointMetadata
): Promise<RunnableConfig> {
if (config.configurable === undefined) {
throw new Error(`Missing "configurable" field in "config" param`);
Expand All @@ -443,7 +444,7 @@ export class PostgresSaver extends BaseCheckpointSaver {
thread_id,
checkpoint_ns,
checkpoint.channel_values,
newVersions
checkpoint.channel_versions
);
for (const serializedBlob of serializedBlobs) {
await client.query(UPSERT_CHECKPOINT_BLOBS_SQL, serializedBlob);
Expand Down
6 changes: 2 additions & 4 deletions libs/checkpoint-postgres/src/tests/checkpoints.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ describe("PostgresSaver", () => {
const runnableConfig = await postgresSaver.put(
{ configurable: { thread_id: "1" } },
checkpoint1,
{ source: "update", step: -1, writes: null, parents: {} },
checkpoint1.channel_versions
{ source: "update", step: -1, writes: null, parents: {} }
);
expect(runnableConfig).toEqual({
configurable: {
Expand Down Expand Up @@ -168,8 +167,7 @@ describe("PostgresSaver", () => {
},
},
checkpoint2,
{ source: "update", step: -1, writes: null, parents: {} },
checkpoint2.channel_versions
{ source: "update", step: -1, writes: null, parents: {} }
);

// verify that parentTs is set and retrieved correctly for second checkpoint
Expand Down

0 comments on commit c8ae5dd

Please sign in to comment.