@langchain/langgraph 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/channels/base.cjs +10 -3
  2. package/dist/channels/base.cjs.map +1 -1
  3. package/dist/channels/base.d.cts.map +1 -1
  4. package/dist/channels/base.d.ts.map +1 -1
  5. package/dist/channels/base.js +10 -3
  6. package/dist/channels/base.js.map +1 -1
  7. package/dist/channels/binop.cjs +2 -1
  8. package/dist/channels/binop.cjs.map +1 -1
  9. package/dist/channels/binop.d.cts.map +1 -1
  10. package/dist/channels/binop.d.ts.map +1 -1
  11. package/dist/channels/binop.js +2 -1
  12. package/dist/channels/binop.js.map +1 -1
  13. package/dist/errors.cjs +22 -0
  14. package/dist/errors.cjs.map +1 -1
  15. package/dist/errors.d.cts +10 -1
  16. package/dist/errors.d.cts.map +1 -1
  17. package/dist/errors.d.ts +10 -1
  18. package/dist/errors.d.ts.map +1 -1
  19. package/dist/errors.js +21 -1
  20. package/dist/errors.js.map +1 -1
  21. package/dist/graph/messages_reducer.cjs +23 -6
  22. package/dist/graph/messages_reducer.cjs.map +1 -1
  23. package/dist/graph/messages_reducer.d.cts +4 -2
  24. package/dist/graph/messages_reducer.d.cts.map +1 -1
  25. package/dist/graph/messages_reducer.d.ts +4 -2
  26. package/dist/graph/messages_reducer.d.ts.map +1 -1
  27. package/dist/graph/messages_reducer.js +24 -7
  28. package/dist/graph/messages_reducer.js.map +1 -1
  29. package/dist/index.cjs +2 -0
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.js +2 -2
  33. package/dist/interrupt.cjs +9 -1
  34. package/dist/interrupt.cjs.map +1 -1
  35. package/dist/interrupt.d.cts.map +1 -1
  36. package/dist/interrupt.d.ts.map +1 -1
  37. package/dist/interrupt.js +10 -2
  38. package/dist/interrupt.js.map +1 -1
  39. package/dist/pregel/debug.cjs +1 -0
  40. package/dist/pregel/debug.cjs.map +1 -1
  41. package/dist/pregel/debug.js +1 -0
  42. package/dist/pregel/debug.js.map +1 -1
  43. package/dist/pregel/loop.cjs +15 -8
  44. package/dist/pregel/loop.cjs.map +1 -1
  45. package/dist/pregel/loop.js +15 -8
  46. package/dist/pregel/loop.js.map +1 -1
  47. package/dist/pregel/runner.cjs +1 -1
  48. package/dist/pregel/runner.cjs.map +1 -1
  49. package/dist/pregel/runner.js +2 -2
  50. package/dist/pregel/runner.js.map +1 -1
  51. package/dist/web.cjs +2 -0
  52. package/dist/web.d.cts +2 -2
  53. package/dist/web.d.ts +2 -2
  54. package/dist/web.js +2 -2
  55. package/package.json +2 -2
@@ -233,9 +233,11 @@ var PregelLoop = class PregelLoop {
233
233
  _resumeLoadedWrites = [];
234
234
  /** Tasks a resume handed loaded writes back to. */
235
235
  _reappliedTaskIds = /* @__PURE__ */ new Set();
236
+ /** Tasks that wrote during this run, the only ones exit mode saves at exit. */
237
+ _writtenTaskIds = /* @__PURE__ */ new Set();
236
238
  /**
237
- * An update or fork checkpoint addressed by `checkpoint_id` that the thread
238
- * has moved past, so it may already have children.
239
+ * A checkpoint addressed by `checkpoint_id` that the thread has moved past,
240
+ * so it may already have children.
239
241
  */
240
242
  addressedCheckpointSuperseded;
241
243
  /** Whether a real checkpoint was loaded from the saver at initialization. */
@@ -264,7 +266,9 @@ var PregelLoop = class PregelLoop {
264
266
  outputKeys;
265
267
  streamKeys;
266
268
  nodes;
267
- skipDoneTasks;
269
+ /** Whether the run points this loop at a checkpoint. */
270
+ addressed;
271
+ skipDoneTasks = true;
268
272
  prevCheckpointConfig;
269
273
  updatedChannels;
270
274
  status = "pending";
@@ -365,7 +369,7 @@ var PregelLoop = class PregelLoop {
365
369
  this.outputKeys = params.outputKeys;
366
370
  this.streamKeys = params.streamKeys;
367
371
  this.nodes = params.nodes;
368
- this.skipDoneTasks = params.skipDoneTasks;
372
+ this.addressed = params.addressed;
369
373
  this.store = params.store;
370
374
  this.cache = params.cache ? new AsyncBatchedCache(params.cache) : void 0;
371
375
  this.stream = params.stream;
@@ -387,7 +391,6 @@ var PregelLoop = class PregelLoop {
387
391
  static async initialize(params) {
388
392
  let { config, stream } = params;
389
393
  if (stream !== void 0 && config.configurable?.["__pregel_stream"] !== void 0) stream = createDuplexStream(stream, config.configurable[CONFIG_KEY_STREAM]);
390
- const skipDoneTasks = config.configurable ? !("checkpoint_id" in config.configurable) : true;
391
394
  const scratchpad = config.configurable?.[CONFIG_KEY_SCRATCHPAD];
392
395
  if (config.configurable && scratchpad) {
393
396
  if (scratchpad.subgraphCounter > 0) config = patchConfigurable(config, { [CONFIG_KEY_CHECKPOINT_NS]: [config.configurable[CONFIG_KEY_CHECKPOINT_NS], scratchpad.subgraphCounter.toString()].join("|") });
@@ -400,6 +403,7 @@ var PregelLoop = class PregelLoop {
400
403
  });
401
404
  let checkpointConfig = config;
402
405
  if (config.configurable?.checkpoint_id === void 0 && config.configurable?.["checkpoint_map"] !== void 0 && config.configurable?.["checkpoint_map"]?.[config.configurable?.checkpoint_ns]) checkpointConfig = patchConfigurable(config, { checkpoint_id: config.configurable[CONFIG_KEY_CHECKPOINT_MAP][config.configurable?.checkpoint_ns] });
406
+ const addressed = Boolean(checkpointConfig.configurable?.["checkpoint_id"] || config.configurable?.["__pregel_replay_state"]);
403
407
  const checkpointNamespace = checkpointNamespaceFromNs(config.configurable?.checkpoint_ns);
404
408
  let saved;
405
409
  let loadedLatest = false;
@@ -446,7 +450,7 @@ var PregelLoop = class PregelLoop {
446
450
  const superseded = await checkpointSuperseded(params.checkpointer, addressedConfig, saved);
447
451
  const isUpdateOrFork = checkpointMetadata.source === "update" || checkpointMetadata.source === "fork";
448
452
  resumeAtHead = addressedConfig.configurable?.checkpoint_id !== void 0 && !superseded && !isUpdateOrFork;
449
- addressedCheckpointSuperseded = superseded && isUpdateOrFork;
453
+ addressedCheckpointSuperseded = superseded;
450
454
  }
451
455
  const deltaWritesVersioned = Object.values(params.channelSpecs).some(isDeltaChannel) && (!hasPersistedParent || isDeltaWritesVersioned(saved.metadata));
452
456
  const channels = await channelsFromCheckpoint(params.channelSpecs, checkpoint, {
@@ -474,7 +478,7 @@ var PregelLoop = class PregelLoop {
474
478
  addressedCheckpointSuperseded,
475
479
  manager: params.manager,
476
480
  hasGraphCallbacks: params.hasGraphCallbacks,
477
- skipDoneTasks,
481
+ addressed,
478
482
  step,
479
483
  stop,
480
484
  checkpointPreviousVersions,
@@ -513,6 +517,7 @@ var PregelLoop = class PregelLoop {
513
517
  putWrites(taskId, writes, cached = false) {
514
518
  let writesCopy = writes;
515
519
  if (writesCopy.length === 0) return;
520
+ this._writtenTaskIds.add(taskId);
516
521
  const deltaWrites = ensureDeltaMessageIds(this.channels, writes);
517
522
  if (writesCopy.every(([key]) => key in WRITES_IDX_MAP)) writesCopy = Array.from(new Map(writesCopy.map((w) => [w[0], w])).values());
518
523
  let hasUntrackedChannels = false;
@@ -835,7 +840,8 @@ var PregelLoop = class PregelLoop {
835
840
  async _first(inputKeys) {
836
841
  const { configurable } = this.config;
837
842
  const inputIsCommand = isCommand(this.input);
838
- const isTimeTraveling = this.isReplaying && (this.isNested && configurable?.["checkpoint_ns"] !== void 0 && configurable?.["checkpoint_ns"] !== "" && configurable?.["checkpoint_map"] !== void 0 && configurable["checkpoint_ns"] in configurable["checkpoint_map"] || !(inputIsCommand && this.input.resume != null || configurable?.["__pregel_resuming"] === true || this.resumeAtHead));
843
+ const isTimeTraveling = this.addressed && (this.isNested && configurable?.["checkpoint_ns"] !== void 0 && configurable?.["checkpoint_ns"] !== "" && configurable?.["checkpoint_map"] !== void 0 && configurable["checkpoint_ns"] in configurable["checkpoint_map"] || !(inputIsCommand && this.input.resume != null || configurable?.["__pregel_resuming"] === true || this.resumeAtHead));
844
+ this.skipDoneTasks = !(isTimeTraveling || this.addressedCheckpointSuperseded);
839
845
  const isUpdateOrFork = this.checkpointMetadata.source === "update" || this.checkpointMetadata.source === "fork";
840
846
  const forks = isTimeTraveling && (inputIsCommand || this.isResuming) && (!isUpdateOrFork || this.addressedCheckpointSuperseded);
841
847
  const carried = [];
@@ -1162,6 +1168,7 @@ var PregelLoop = class PregelLoop {
1162
1168
  });
1163
1169
  const byTask = {};
1164
1170
  for (const [tid, key, value] of this.checkpointPendingWrites) {
1171
+ if (!this._writtenTaskIds.has(tid)) continue;
1165
1172
  byTask[tid] ??= [];
1166
1173
  byTask[tid].push([key, value]);
1167
1174
  }