You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context
Multiple agent instances write to the same collection and are only filtered by thread_id, causing collisions when agents share a thread.
Interface clarification
Socket (and CheckpointerService filters) use { agentId?, threadId? }.
Internally, agentId maps 1:1 to checkpoint_ns and should equal the runtime node id.
Correct approach (no saver namespace)
@langchain/langgraph-checkpoint-mongodb MongoDBSaver does not take a namespace option. The correct way to scope writes is to set configurable.checkpoint_ns in the RunnableConfig passed to LangGraph.
Tasks
Pass checkpoint_ns (agentId) in RunnableConfig
apps/server/src/agents/simple.agent.ts
Update SimpleAgent to accept agentId in constructor.
In init(), set default _config to include configurable: { checkpoint_ns: agentId } while preserving recursionLimit.
BaseAgent.invoke already merges thread_id each call, so checkpoint_ns remains set.
agentId-aware filtering in DB layer
apps/server/src/services/checkpointer.service.ts
Add checkpointNs?: string to CheckpointWriteNormalized; map from raw.checkpoint_ns.
fetchLatestWrites({ threadId?, agentId? }, limit): apply both fields (agentId -> checkpoint_ns) to Mongo filter.
watchInserts({ threadId?, agentId? }): add to $match as fullDocument.checkpoint_ns.
Wire agentId from template registry
apps/server/src/templates.ts: simpleAgent factory uses ctx.nodeId as agentId and passes it to constructor.
Socket init supports agentId
apps/server/src/services/socket.service.ts
Extend InitPayload with agentId?: string and threadId?: string; pass through to checkpointer with mapping agentId -> checkpoint_ns.
Acceptance Criteria
Two agents produce checkpoint_writes with distinct checkpoint_ns (matching agentId/nodeId) without modifying MongoDBSaver constructor.
fetch/watch with agentId filter returns only matching writes.
Socket init with agentId streams only that agent’s writes; no regression when agentId omitted.
Context
Multiple agent instances write to the same collection and are only filtered by thread_id, causing collisions when agents share a thread.
Interface clarification
Correct approach (no saver namespace)
Tasks
Acceptance Criteria
Relationships