MongoDB CheckpointSaver: Support extending and persisting of extra fields documents #359

Open
opened 2026-02-15 18:16:11 -05:00 by yindo · 1 comment
Owner

Originally created by @damilolaA on GitHub (Sep 16, 2025).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).

Example Code

const saver = new MongoDBSaver({
  client: mongoClient,
  dbName: "langgraph",
  collectionName: "checkpoints",
  extraFields: ({ config, metadata }) => ({
    userId: config.configurable?.userId,
    topic: metadata.topic,
  }),
});

await app.invoke(
  { messages: [{ role: "user", content: "hello" }] },
  {
    configurable: { userId: "u123" },
    metadata: { topic: "support" },
  }
);

const tuple = await saver.getTuple({
  filter: { userId: "u123", topic: "support" },
});

Error Message and Stack Trace (if applicable)

No response

Description

The MongoDB checkpointer currently has a fixed schema that cannot be extended, which prevents the persisting and querying of documents using application specific fields e.g userId etc. This is limiting for multi-tenant applications where checkpoints need to be scoped and retrieved by tenant or user.

A proposed improvement is to add support for an extraFields hook that allows custom fields to be written as plain JSON into both the checkpoints and checkpoint_writes collections and to also extend querying of these collections to filter by those fields.

System Info

{
    "@langchain/core": "^0.3.75",
    "@langchain/langgraph": "^0.4.9",
    "@langchain/langgraph-checkpoint": "^0.1.1",
    "@langchain/langgraph-checkpoint-mongodb": "^0.1.1",
    "@langchain/langgraph-supervisor": "^0.0.20",
    "@langchain/mcp-adapters": "^0.6.0",
}
Originally created by @damilolaA on GitHub (Sep 16, 2025). ### Checked other resources - [x] I added a very descriptive title to this issue. - [x] I searched the LangGraph.js documentation with the integrated search. - [x] I used the GitHub search to find a similar question and didn't find it. - [x] I am sure that this is a bug in LangGraph.js rather than my code. - [x] The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package). ### Example Code ```typescript const saver = new MongoDBSaver({ client: mongoClient, dbName: "langgraph", collectionName: "checkpoints", extraFields: ({ config, metadata }) => ({ userId: config.configurable?.userId, topic: metadata.topic, }), }); await app.invoke( { messages: [{ role: "user", content: "hello" }] }, { configurable: { userId: "u123" }, metadata: { topic: "support" }, } ); const tuple = await saver.getTuple({ filter: { userId: "u123", topic: "support" }, }); ``` ### Error Message and Stack Trace (if applicable) _No response_ ### Description The MongoDB checkpointer currently has a fixed schema that cannot be extended, which prevents the persisting and querying of documents using application specific fields e.g `userId` etc. This is limiting for multi-tenant applications where checkpoints need to be scoped and retrieved by tenant or user. A proposed improvement is to add support for an `extraFields` hook that allows custom fields to be written as plain JSON into both the `checkpoints` and `checkpoint_writes` collections and to also extend querying of these collections to filter by those fields. ### System Info ```typescript { "@langchain/core": "^0.3.75", "@langchain/langgraph": "^0.4.9", "@langchain/langgraph-checkpoint": "^0.1.1", "@langchain/langgraph-checkpoint-mongodb": "^0.1.1", "@langchain/langgraph-supervisor": "^0.0.20", "@langchain/mcp-adapters": "^0.6.0", } ```
Author
Owner

@SunHuawei commented on GitHub (Sep 27, 2025):

Looks like none of the existing savers—Memory, Postgres, or MongoDB, in JS or Python—expose an extraFields hook today. So this really is a new capability request across the whole checkpointing stack. Agreed it would be a valuable addition for multi-tenant scenarios; hopefully the core team can prioritize it.

@SunHuawei commented on GitHub (Sep 27, 2025): Looks like none of the existing savers—Memory, Postgres, or MongoDB, in JS or Python—expose an extraFields hook today. So this really is a new capability request across the whole checkpointing stack. Agreed it would be a valuable addition for multi-tenant scenarios; hopefully the core team can prioritize it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#359