Skip to content

Commit

Permalink
fix(checkpoint): don't throw on MemorySaver.put if no checkpoint_ns
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincburns committed Oct 24, 2024
1 parent 06b546a commit 64601f8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
3 changes: 0 additions & 3 deletions libs/checkpoint-validation/src/spec/put.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ export function putTests<T extends BaseCheckpointSaver>(
});

it_skipForSomeModules(initializer.checkpointerName, {
// TODO: MemorySaver throws instead of defaulting to empty namespace
// see: https://github.com/langchain-ai/langgraphjs/issues/591
MemorySaver: "TODO: throws instead of defaulting to empty namespace",
// TODO: SqliteSaver stores with undefined namespace instead of empty namespace
// see: https://github.com/langchain-ai/langgraphjs/issues/592
"@langchain/langgraph-checkpoint-sqlite":
Expand Down
7 changes: 1 addition & 6 deletions libs/checkpoint/src/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,12 @@ export class MemorySaver extends BaseCheckpointSaver {
const preparedCheckpoint: Partial<Checkpoint> = copyCheckpoint(checkpoint);
delete preparedCheckpoint.pending_sends;
const threadId = config.configurable?.thread_id;
const checkpointNamespace = config.configurable?.checkpoint_ns;
const checkpointNamespace = config.configurable?.checkpoint_ns ?? "";
if (threadId === undefined) {
throw new Error(
`Failed to put checkpoint. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property.`
);
}
if (checkpointNamespace === undefined) {
throw new Error(
`Failed to put checkpoint. The passed RunnableConfig is missing a required "checkpoint_ns" field in its "configurable" property.`
);
}

if (!this.storage[threadId]) {
this.storage[threadId] = {};
Expand Down

0 comments on commit 64601f8

Please sign in to comment.