@langchain/langgraph 0.2.13 → 0.2.14
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.
- package/dist/errors.cjs +25 -1
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +22 -0
- package/dist/graph/graph.cjs +1 -0
- package/dist/graph/graph.d.ts +15 -13
- package/dist/graph/graph.js +1 -0
- package/dist/graph/state.d.ts +4 -3
- package/dist/pregel/index.cjs +5 -1
- package/dist/pregel/index.d.ts +1 -1
- package/dist/pregel/index.js +5 -1
- package/dist/pregel/io.cjs +1 -1
- package/dist/pregel/io.js +1 -1
- package/dist/pregel/loop.cjs +14 -0
- package/dist/pregel/loop.d.ts +1 -0
- package/dist/pregel/loop.js +15 -1
- package/dist/pregel/retry.cjs +11 -0
- package/dist/pregel/retry.js +12 -1
- package/dist/pregel/runnable_types.d.ts +1 -1
- package/dist/pregel/types.d.ts +1 -1
- package/package.json +3 -3
package/dist/errors.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidUpdateError = exports.EmptyChannelError = exports.EmptyInputError = exports.isGraphInterrupt = exports.NodeInterrupt = exports.GraphInterrupt = exports.GraphValueError = exports.GraphRecursionError = void 0;
|
|
3
|
+
exports.getSubgraphsSeenSet = exports.MultipleSubgraphsError = exports.InvalidUpdateError = exports.EmptyChannelError = exports.EmptyInputError = exports.isGraphInterrupt = exports.NodeInterrupt = exports.GraphInterrupt = exports.GraphValueError = exports.GraphRecursionError = void 0;
|
|
4
4
|
class GraphRecursionError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -92,3 +92,27 @@ class InvalidUpdateError extends Error {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
exports.InvalidUpdateError = InvalidUpdateError;
|
|
95
|
+
class MultipleSubgraphsError extends Error {
|
|
96
|
+
constructor(message) {
|
|
97
|
+
super(message);
|
|
98
|
+
this.name = "MultipleSubgraphError";
|
|
99
|
+
}
|
|
100
|
+
static get unminifiable_name() {
|
|
101
|
+
return "MultipleSubgraphError";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.MultipleSubgraphsError = MultipleSubgraphsError;
|
|
105
|
+
/**
|
|
106
|
+
* Used for subgraph detection.
|
|
107
|
+
*/
|
|
108
|
+
const getSubgraphsSeenSet = () => {
|
|
109
|
+
if (
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")] === undefined) {
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")] = new Set();
|
|
114
|
+
}
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
|
+
return globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")];
|
|
117
|
+
};
|
|
118
|
+
exports.getSubgraphsSeenSet = getSubgraphsSeenSet;
|
package/dist/errors.d.ts
CHANGED
|
@@ -30,3 +30,11 @@ export declare class InvalidUpdateError extends Error {
|
|
|
30
30
|
constructor(message?: string);
|
|
31
31
|
static get unminifiable_name(): string;
|
|
32
32
|
}
|
|
33
|
+
export declare class MultipleSubgraphsError extends Error {
|
|
34
|
+
constructor(message?: string);
|
|
35
|
+
static get unminifiable_name(): string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Used for subgraph detection.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getSubgraphsSeenSet: () => any;
|
package/dist/errors.js
CHANGED
|
@@ -81,3 +81,25 @@ export class InvalidUpdateError extends Error {
|
|
|
81
81
|
return "InvalidUpdateError";
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
export class MultipleSubgraphsError extends Error {
|
|
85
|
+
constructor(message) {
|
|
86
|
+
super(message);
|
|
87
|
+
this.name = "MultipleSubgraphError";
|
|
88
|
+
}
|
|
89
|
+
static get unminifiable_name() {
|
|
90
|
+
return "MultipleSubgraphError";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Used for subgraph detection.
|
|
95
|
+
*/
|
|
96
|
+
export const getSubgraphsSeenSet = () => {
|
|
97
|
+
if (
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")] === undefined) {
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
101
|
+
globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")] = new Set();
|
|
102
|
+
}
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
return globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")];
|
|
105
|
+
};
|
package/dist/graph/graph.cjs
CHANGED
package/dist/graph/graph.d.ts
CHANGED
|
@@ -7,21 +7,23 @@ import type { PregelParams } from "../pregel/types.js";
|
|
|
7
7
|
import { BaseChannel } from "../channels/base.js";
|
|
8
8
|
import { Send } from "../constants.js";
|
|
9
9
|
import { RunnableCallable } from "../utils.js";
|
|
10
|
+
import { StateDefinition, StateType } from "./annotation.js";
|
|
11
|
+
import type { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
|
|
10
12
|
/** Special reserved node name denoting the start of a graph. */
|
|
11
13
|
export declare const START = "__start__";
|
|
12
14
|
/** Special reserved node name denoting the end of a graph. */
|
|
13
15
|
export declare const END = "__end__";
|
|
14
|
-
export interface BranchOptions<IO, N extends string> {
|
|
16
|
+
export interface BranchOptions<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {
|
|
15
17
|
source: N;
|
|
16
|
-
path: Branch<IO, N>["condition"];
|
|
18
|
+
path: Branch<IO, N, CallOptions>["condition"];
|
|
17
19
|
pathMap?: Record<string, N | typeof END> | (N | typeof END)[];
|
|
18
20
|
}
|
|
19
|
-
export declare class Branch<IO, N extends string> {
|
|
20
|
-
condition: (input: IO, config
|
|
21
|
+
export declare class Branch<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {
|
|
22
|
+
condition: (input: IO, config: CallOptions) => string | Send | (string | Send)[] | Promise<string | Send | (string | Send)[]>;
|
|
21
23
|
ends?: Record<string, N | typeof END>;
|
|
22
|
-
constructor(options: Omit<BranchOptions<IO, N>, "source">);
|
|
23
|
-
compile(writer: (dests: (string | Send)[]) => Runnable | undefined, reader?: (config:
|
|
24
|
-
_route(input: IO, config:
|
|
24
|
+
constructor(options: Omit<BranchOptions<IO, N, CallOptions>, "source">);
|
|
25
|
+
compile(writer: (dests: (string | Send)[]) => Runnable | undefined, reader?: (config: CallOptions) => IO): RunnableCallable<unknown, unknown>;
|
|
26
|
+
_route(input: IO, config: CallOptions, writer: (dests: (string | Send)[]) => Runnable | undefined, reader?: (config: CallOptions) => IO): Promise<Runnable | undefined>;
|
|
25
27
|
}
|
|
26
28
|
export type NodeSpec<RunInput, RunOutput> = {
|
|
27
29
|
runnable: Runnable<RunInput, RunOutput>;
|
|
@@ -30,19 +32,19 @@ export type NodeSpec<RunInput, RunOutput> = {
|
|
|
30
32
|
export type AddNodeOptions = {
|
|
31
33
|
metadata?: Record<string, unknown>;
|
|
32
34
|
};
|
|
33
|
-
export declare class Graph<N extends string = typeof END, RunInput = any, RunOutput = any, NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<RunInput, RunOutput
|
|
35
|
+
export declare class Graph<N extends string = typeof END, RunInput = any, RunOutput = any, NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<RunInput, RunOutput>, C extends StateDefinition = StateDefinition> {
|
|
34
36
|
nodes: Record<N, NodeSpecType>;
|
|
35
37
|
edges: Set<[N | typeof START, N | typeof END]>;
|
|
36
|
-
branches: Record<string, Record<string, Branch<RunInput, N>>>;
|
|
38
|
+
branches: Record<string, Record<string, Branch<RunInput, N, any>>>;
|
|
37
39
|
entryPoint?: string;
|
|
38
40
|
compiled: boolean;
|
|
39
41
|
constructor();
|
|
40
42
|
protected warnIfCompiled(message: string): void;
|
|
41
43
|
get allEdges(): Set<[string, string]>;
|
|
42
|
-
addNode<K extends string, NodeInput = RunInput>(key: K, action: RunnableLike<NodeInput, RunOutput
|
|
44
|
+
addNode<K extends string, NodeInput = RunInput>(key: K, action: RunnableLike<NodeInput, RunOutput extends object ? RunOutput & Record<string, any> : RunOutput, LangGraphRunnableConfig<StateType<C>>>, options?: AddNodeOptions): Graph<N | K, RunInput, RunOutput>;
|
|
43
45
|
addEdge(startKey: N | typeof START, endKey: N | typeof END): this;
|
|
44
|
-
addConditionalEdges(source: BranchOptions<RunInput, N
|
|
45
|
-
addConditionalEdges(source: N, path: Branch<RunInput, N
|
|
46
|
+
addConditionalEdges(source: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>): this;
|
|
47
|
+
addConditionalEdges(source: N, path: Branch<RunInput, N, LangGraphRunnableConfig<StateType<C>>>["condition"], pathMap?: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>["pathMap"]): this;
|
|
46
48
|
/**
|
|
47
49
|
* @deprecated use `addEdge(START, key)` instead
|
|
48
50
|
*/
|
|
@@ -52,7 +54,7 @@ export declare class Graph<N extends string = typeof END, RunInput = any, RunOut
|
|
|
52
54
|
*/
|
|
53
55
|
setFinishPoint(key: N): this;
|
|
54
56
|
compile({ checkpointer, interruptBefore, interruptAfter, }?: {
|
|
55
|
-
checkpointer?: BaseCheckpointSaver;
|
|
57
|
+
checkpointer?: BaseCheckpointSaver | false;
|
|
56
58
|
interruptBefore?: N[] | All;
|
|
57
59
|
interruptAfter?: N[] | All;
|
|
58
60
|
}): CompiledGraph<N>;
|
package/dist/graph/graph.js
CHANGED
package/dist/graph/state.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { END, CompiledGraph, Graph, START, Branch, AddNodeOptions, NodeSpec } fr
|
|
|
5
5
|
import { AnnotationRoot, SingleReducer, StateDefinition, StateType, UpdateType } from "./annotation.js";
|
|
6
6
|
import type { RetryPolicy } from "../pregel/utils/index.js";
|
|
7
7
|
import { ManagedValueSpec } from "../managed/base.js";
|
|
8
|
+
import type { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
|
|
8
9
|
export type ChannelReducers<Channels extends object> = {
|
|
9
10
|
[K in keyof Channels]: SingleReducer<Channels[K], any>;
|
|
10
11
|
};
|
|
@@ -94,7 +95,7 @@ export type StateGraphArgsWithInputOutputSchemas<SD extends StateDefinition, O e
|
|
|
94
95
|
* // }
|
|
95
96
|
* ```
|
|
96
97
|
*/
|
|
97
|
-
export declare class StateGraph<SD extends StateDefinition | unknown, S = SD extends StateDefinition ? StateType<SD> : SD, U = SD extends StateDefinition ? UpdateType<SD> : Partial<S>, N extends string = typeof START, I extends StateDefinition = SD extends StateDefinition ? SD : StateDefinition, O extends StateDefinition = SD extends StateDefinition ? SD : StateDefinition, C extends StateDefinition = StateDefinition> extends Graph<N, S, U, StateGraphNodeSpec<S, U
|
|
98
|
+
export declare class StateGraph<SD extends StateDefinition | unknown, S = SD extends StateDefinition ? StateType<SD> : SD, U = SD extends StateDefinition ? UpdateType<SD> : Partial<S>, N extends string = typeof START, I extends StateDefinition = SD extends StateDefinition ? SD : StateDefinition, O extends StateDefinition = SD extends StateDefinition ? SD : StateDefinition, C extends StateDefinition = StateDefinition> extends Graph<N, S, U, StateGraphNodeSpec<S, U>, C> {
|
|
98
99
|
channels: Record<string, BaseChannel | ManagedValueSpec>;
|
|
99
100
|
waitingEdges: Set<[N[], N]>;
|
|
100
101
|
/** @internal */
|
|
@@ -113,10 +114,10 @@ export declare class StateGraph<SD extends StateDefinition | unknown, S = SD ext
|
|
|
113
114
|
constructor(fields: SD extends StateDefinition ? SD | AnnotationRoot<SD> | StateGraphArgs<S> | StateGraphArgsWithStateSchema<SD, I, O> | StateGraphArgsWithInputOutputSchemas<SD, O> : StateGraphArgs<S>, configSchema?: AnnotationRoot<C>);
|
|
114
115
|
get allEdges(): Set<[string, string]>;
|
|
115
116
|
_addSchema(stateDefinition: StateDefinition): void;
|
|
116
|
-
addNode<K extends string, NodeInput = S>(key: K, action: RunnableLike<NodeInput, U extends object ? U & Record<string, any> : U
|
|
117
|
+
addNode<K extends string, NodeInput = S>(key: K, action: RunnableLike<NodeInput, U extends object ? U & Record<string, any> : U, LangGraphRunnableConfig<StateType<C>>>, options?: StateGraphAddNodeOptions): StateGraph<SD, S, U, N | K, I, O, C>;
|
|
117
118
|
addEdge(startKey: typeof START | N | N[], endKey: N | typeof END): this;
|
|
118
119
|
compile({ checkpointer, store, interruptBefore, interruptAfter, }?: {
|
|
119
|
-
checkpointer?: BaseCheckpointSaver;
|
|
120
|
+
checkpointer?: BaseCheckpointSaver | false;
|
|
120
121
|
store?: BaseStore;
|
|
121
122
|
interruptBefore?: N[] | All;
|
|
122
123
|
interruptAfter?: N[] | All;
|
package/dist/pregel/index.cjs
CHANGED
|
@@ -609,7 +609,10 @@ class Pregel extends runnables_1.Runnable {
|
|
|
609
609
|
defaultStreamMode = ["values"];
|
|
610
610
|
}
|
|
611
611
|
let defaultCheckpointer;
|
|
612
|
-
if (
|
|
612
|
+
if (this.checkpointer === false) {
|
|
613
|
+
defaultCheckpointer = undefined;
|
|
614
|
+
}
|
|
615
|
+
else if (config !== undefined &&
|
|
613
616
|
config.configurable?.[constants_js_1.CONFIG_KEY_CHECKPOINTER] !== undefined) {
|
|
614
617
|
defaultCheckpointer = config.configurable[constants_js_1.CONFIG_KEY_CHECKPOINTER];
|
|
615
618
|
}
|
|
@@ -699,6 +702,7 @@ class Pregel extends runnables_1.Runnable {
|
|
|
699
702
|
throw new Error(`Passed "recursionLimit" must be at least 1.`);
|
|
700
703
|
}
|
|
701
704
|
if (this.checkpointer !== undefined &&
|
|
705
|
+
this.checkpointer !== false &&
|
|
702
706
|
inputConfig.configurable === undefined) {
|
|
703
707
|
throw new Error(`Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"`);
|
|
704
708
|
}
|
package/dist/pregel/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare class Pregel<Nn extends StrRecord<string, PregelNode>, Cc extends
|
|
|
56
56
|
interruptBefore?: Array<keyof Nn> | All;
|
|
57
57
|
stepTimeout?: number;
|
|
58
58
|
debug: boolean;
|
|
59
|
-
checkpointer?: BaseCheckpointSaver;
|
|
59
|
+
checkpointer?: BaseCheckpointSaver | false;
|
|
60
60
|
retryPolicy?: RetryPolicy;
|
|
61
61
|
config?: LangGraphRunnableConfig;
|
|
62
62
|
store?: BaseStore;
|
package/dist/pregel/index.js
CHANGED
|
@@ -602,7 +602,10 @@ export class Pregel extends Runnable {
|
|
|
602
602
|
defaultStreamMode = ["values"];
|
|
603
603
|
}
|
|
604
604
|
let defaultCheckpointer;
|
|
605
|
-
if (
|
|
605
|
+
if (this.checkpointer === false) {
|
|
606
|
+
defaultCheckpointer = undefined;
|
|
607
|
+
}
|
|
608
|
+
else if (config !== undefined &&
|
|
606
609
|
config.configurable?.[CONFIG_KEY_CHECKPOINTER] !== undefined) {
|
|
607
610
|
defaultCheckpointer = config.configurable[CONFIG_KEY_CHECKPOINTER];
|
|
608
611
|
}
|
|
@@ -692,6 +695,7 @@ export class Pregel extends Runnable {
|
|
|
692
695
|
throw new Error(`Passed "recursionLimit" must be at least 1.`);
|
|
693
696
|
}
|
|
694
697
|
if (this.checkpointer !== undefined &&
|
|
698
|
+
this.checkpointer !== false &&
|
|
695
699
|
inputConfig.configurable === undefined) {
|
|
696
700
|
throw new Error(`Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"`);
|
|
697
701
|
}
|
package/dist/pregel/io.cjs
CHANGED
|
@@ -64,7 +64,7 @@ chunk
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
else if (Array.isArray(inputChannels)) {
|
|
67
|
-
throw new Error(
|
|
67
|
+
throw new Error(`Input chunk must be an object when "inputChannels" is an array`);
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
70
|
yield [inputChannels, chunk];
|
package/dist/pregel/io.js
CHANGED
|
@@ -59,7 +59,7 @@ chunk
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
else if (Array.isArray(inputChannels)) {
|
|
62
|
-
throw new Error(
|
|
62
|
+
throw new Error(`Input chunk must be an object when "inputChannels" is an array`);
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
65
|
yield [inputChannels, chunk];
|
package/dist/pregel/loop.cjs
CHANGED
|
@@ -241,6 +241,7 @@ class PregelLoop {
|
|
|
241
241
|
}
|
|
242
242
|
static async initialize(params) {
|
|
243
243
|
let { config, stream } = params;
|
|
244
|
+
const { checkSubgraphs = true } = params;
|
|
244
245
|
if (stream !== undefined &&
|
|
245
246
|
config.configurable?.[constants_js_1.CONFIG_KEY_STREAM] !== undefined) {
|
|
246
247
|
stream = createDuplexStream(stream, config.configurable[constants_js_1.CONFIG_KEY_STREAM]);
|
|
@@ -297,6 +298,19 @@ class PregelLoop {
|
|
|
297
298
|
// Start the store. This is a batch store, so it will run continuously
|
|
298
299
|
store.start();
|
|
299
300
|
}
|
|
301
|
+
if (checkSubgraphs && isNested && params.checkpointer !== undefined) {
|
|
302
|
+
if ((0, errors_js_1.getSubgraphsSeenSet)().has(config.configurable?.checkpoint_ns)) {
|
|
303
|
+
throw new errors_js_1.MultipleSubgraphsError([
|
|
304
|
+
"Detected the same subgraph called multiple times by the same node.",
|
|
305
|
+
"This is not allowed if checkpointing is enabled.",
|
|
306
|
+
"",
|
|
307
|
+
`You can disable checkpointing for a subgraph by compiling it with ".compile({ checkpointer: false });"`,
|
|
308
|
+
].join("\n"));
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
(0, errors_js_1.getSubgraphsSeenSet)().add(config.configurable?.checkpoint_ns);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
300
314
|
return new PregelLoop({
|
|
301
315
|
input: params.input,
|
|
302
316
|
config,
|
package/dist/pregel/loop.d.ts
CHANGED
package/dist/pregel/loop.js
CHANGED
|
@@ -4,7 +4,7 @@ import { CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_R
|
|
|
4
4
|
import { _applyWrites, _prepareNextTasks, increment, shouldInterrupt, } from "./algo.js";
|
|
5
5
|
import { gatherIterator, gatherIteratorSync, prefixGenerator, } from "../utils.js";
|
|
6
6
|
import { mapInput, mapOutputUpdates, mapOutputValues, readChannels, } from "./io.js";
|
|
7
|
-
import { EmptyInputError, GraphInterrupt, isGraphInterrupt, } from "../errors.js";
|
|
7
|
+
import { getSubgraphsSeenSet, EmptyInputError, GraphInterrupt, isGraphInterrupt, MultipleSubgraphsError, } from "../errors.js";
|
|
8
8
|
import { getNewChannelVersions, patchConfigurable } from "./utils/index.js";
|
|
9
9
|
import { mapDebugTasks, mapDebugCheckpoint, mapDebugTaskResults, } from "./debug.js";
|
|
10
10
|
const INPUT_DONE = Symbol.for("INPUT_DONE");
|
|
@@ -237,6 +237,7 @@ export class PregelLoop {
|
|
|
237
237
|
}
|
|
238
238
|
static async initialize(params) {
|
|
239
239
|
let { config, stream } = params;
|
|
240
|
+
const { checkSubgraphs = true } = params;
|
|
240
241
|
if (stream !== undefined &&
|
|
241
242
|
config.configurable?.[CONFIG_KEY_STREAM] !== undefined) {
|
|
242
243
|
stream = createDuplexStream(stream, config.configurable[CONFIG_KEY_STREAM]);
|
|
@@ -293,6 +294,19 @@ export class PregelLoop {
|
|
|
293
294
|
// Start the store. This is a batch store, so it will run continuously
|
|
294
295
|
store.start();
|
|
295
296
|
}
|
|
297
|
+
if (checkSubgraphs && isNested && params.checkpointer !== undefined) {
|
|
298
|
+
if (getSubgraphsSeenSet().has(config.configurable?.checkpoint_ns)) {
|
|
299
|
+
throw new MultipleSubgraphsError([
|
|
300
|
+
"Detected the same subgraph called multiple times by the same node.",
|
|
301
|
+
"This is not allowed if checkpointing is enabled.",
|
|
302
|
+
"",
|
|
303
|
+
`You can disable checkpointing for a subgraph by compiling it with ".compile({ checkpointer: false });"`,
|
|
304
|
+
].join("\n"));
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
getSubgraphsSeenSet().add(config.configurable?.checkpoint_ns);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
296
310
|
return new PregelLoop({
|
|
297
311
|
input: params.input,
|
|
298
312
|
config,
|
package/dist/pregel/retry.cjs
CHANGED
|
@@ -131,6 +131,17 @@ pregelTask, retryPolicy) {
|
|
|
131
131
|
error.constructor.unminifiable_name ??
|
|
132
132
|
error.constructor.name;
|
|
133
133
|
console.log(`Retrying task "${pregelTask.name}" after ${interval.toFixed(2)} seconds (attempt ${attempts}) after ${errorName}: ${error}`);
|
|
134
|
+
// Clear checkpoint_ns seen (for subgraph detection)
|
|
135
|
+
const checkpointNs = pregelTask.config?.configurable?.checkpoint_ns;
|
|
136
|
+
if (checkpointNs) {
|
|
137
|
+
(0, errors_js_1.getSubgraphsSeenSet)().delete(checkpointNs);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
const checkpointNs = pregelTask.config?.configurable?.checkpoint_ns;
|
|
142
|
+
if (checkpointNs) {
|
|
143
|
+
(0, errors_js_1.getSubgraphsSeenSet)().delete(checkpointNs);
|
|
144
|
+
}
|
|
134
145
|
}
|
|
135
146
|
}
|
|
136
147
|
return {
|
package/dist/pregel/retry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isGraphInterrupt } from "../errors.js";
|
|
1
|
+
import { getSubgraphsSeenSet, isGraphInterrupt } from "../errors.js";
|
|
2
2
|
export const DEFAULT_INITIAL_INTERVAL = 500;
|
|
3
3
|
export const DEFAULT_BACKOFF_FACTOR = 2;
|
|
4
4
|
export const DEFAULT_MAX_INTERVAL = 128000;
|
|
@@ -127,6 +127,17 @@ pregelTask, retryPolicy) {
|
|
|
127
127
|
error.constructor.unminifiable_name ??
|
|
128
128
|
error.constructor.name;
|
|
129
129
|
console.log(`Retrying task "${pregelTask.name}" after ${interval.toFixed(2)} seconds (attempt ${attempts}) after ${errorName}: ${error}`);
|
|
130
|
+
// Clear checkpoint_ns seen (for subgraph detection)
|
|
131
|
+
const checkpointNs = pregelTask.config?.configurable?.checkpoint_ns;
|
|
132
|
+
if (checkpointNs) {
|
|
133
|
+
getSubgraphsSeenSet().delete(checkpointNs);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
const checkpointNs = pregelTask.config?.configurable?.checkpoint_ns;
|
|
138
|
+
if (checkpointNs) {
|
|
139
|
+
getSubgraphsSeenSet().delete(checkpointNs);
|
|
140
|
+
}
|
|
130
141
|
}
|
|
131
142
|
}
|
|
132
143
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
2
2
|
import { BaseStore } from "@langchain/langgraph-checkpoint";
|
|
3
|
-
export interface LangGraphRunnableConfig extends RunnableConfig {
|
|
3
|
+
export interface LangGraphRunnableConfig<ConfigurableType extends Record<string, any> = Record<string, any>> extends RunnableConfig<ConfigurableType> {
|
|
4
4
|
store?: BaseStore;
|
|
5
5
|
}
|
package/dist/pregel/types.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export interface PregelInterface<Nn extends StrRecord<string, PregelNode>, Cc ex
|
|
|
44
44
|
* @default false
|
|
45
45
|
*/
|
|
46
46
|
debug?: boolean;
|
|
47
|
-
checkpointer?: BaseCheckpointSaver;
|
|
47
|
+
checkpointer?: BaseCheckpointSaver | false;
|
|
48
48
|
retryPolicy?: RetryPolicy;
|
|
49
49
|
config?: LangGraphRunnableConfig;
|
|
50
50
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "LangGraph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"author": "LangChain",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@langchain/langgraph-checkpoint": "~0.0.
|
|
34
|
+
"@langchain/langgraph-checkpoint": "~0.0.10",
|
|
35
35
|
"double-ended-queue": "^2.1.0-0",
|
|
36
36
|
"uuid": "^10.0.0",
|
|
37
37
|
"zod": "^3.23.8"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@langchain/core": ">=0.2.
|
|
40
|
+
"@langchain/core": ">=0.2.36 <0.3.0 || >=0.3.9 < 0.4.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "^29.5.0",
|