Skip to content

Commit

Permalink
fix(langgraph): Prevent non RunnableConfig keys from being passed (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored Dec 5, 2024
1 parent 1247085 commit 5f324c1
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"devDependencies": {
"@langchain/anthropic": "^0.3.5",
"@langchain/community": "^0.3.9",
"@langchain/core": "^0.3.16",
"@langchain/core": "^0.3.22",
"@langchain/groq": "^0.1.2",
"@langchain/langgraph": "workspace:*",
"@langchain/mistralai": "^0.1.1",
Expand Down
2 changes: 1 addition & 1 deletion libs/langgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@jest/globals": "^29.5.0",
"@langchain/anthropic": "^0.3.5",
"@langchain/community": "^0.3.9",
"@langchain/core": "^0.3.16",
"@langchain/core": "^0.3.22",
"@langchain/langgraph-checkpoint-postgres": "workspace:*",
"@langchain/langgraph-checkpoint-sqlite": "workspace:*",
"@langchain/openai": "^0.3.11",
Expand Down
49 changes: 49 additions & 0 deletions libs/langgraph/src/tests/pregel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8910,6 +8910,55 @@ export function runPregelTests(
expect(result.messages).toBeDefined();
expect(result.messages).toHaveLength(2);
});

it("Can have three graphs with different keys", async () => {
const annotationOne = Annotation.Root({
inputOne: Annotation<string>,
});
const annotationTwo = Annotation.Root({
inputOne: Annotation<string>,
inputTwo: Annotation<string>,
});
const annotationThree = Annotation.Root({
inputTwo: Annotation<string>,
inputThree: Annotation<string>,
});

const graphThree = new StateGraph(annotationThree)
.addNode("returns", () => ({ inputThree: "one" }))
.addEdge(START, "returns")
.compile();

const graphTwo = new StateGraph(annotationTwo)
.addNode("one", () => ({ inputTwo: "one" }))
.addNode("callGraphThree", graphThree, { input: annotationThree })
.addEdge(START, "one")
.addEdge("one", "callGraphThree")
.addEdge("callGraphThree", END)
.compile();

const graphOne = new StateGraph(annotationOne)
.addNode("one", () => ({ inputOne: "one" }))
.addNode("callGraphTwo", graphTwo, { input: annotationTwo })
.addEdge(START, "one")
.addEdge("one", "callGraphTwo")
.addEdge("callGraphTwo", END)
.compile();

await expect(graphOne.invoke({ inputOne: "one" })).resolves.toBeDefined();
});

it("Can access store inside a node", async () => {
const graph = new StateGraph(MessagesAnnotation)
.addNode("one", async (_, configTop) => {
expect(configTop.store).toBeDefined();
return {};
})
.addEdge(START, "one")
.compile({ store: new InMemoryStore() });

await graph.invoke({ messages: [] });
});
}

runPregelTests(() => new MemorySaverAssertImmutable());
33 changes: 26 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1592,22 +1592,22 @@ __metadata:
languageName: node
linkType: hard

"@langchain/core@npm:^0.3.16":
version: 0.3.16
resolution: "@langchain/core@npm:0.3.16"
"@langchain/core@npm:^0.3.22":
version: 0.3.22
resolution: "@langchain/core@npm:0.3.22"
dependencies:
ansi-styles: ^5.0.0
camelcase: 6
decamelize: 1.2.0
js-tiktoken: ^1.0.12
langsmith: ^0.2.0
langsmith: ^0.2.8
mustache: ^4.2.0
p-queue: ^6.6.2
p-retry: 4
uuid: ^10.0.0
zod: ^3.22.4
zod-to-json-schema: ^3.22.3
checksum: 2ecfb2cd7375e8d152043c35732b55a99d9ee091007dfd1a2677516f26de531695eb08ec3e6864c3240bb790c913aca4870b42850da9a4ec927f7dbc5efdf110
checksum: e629a7b5b794e378ce29366b7aa6989fd16e2e97ea18a2f4dcc26cb52e71f8b572ec7397922d10626602a72b9530ac02624b5a15fe962161810d1a7cf7db62b9
languageName: node
linkType: hard

Expand Down Expand Up @@ -1843,7 +1843,7 @@ __metadata:
"@jest/globals": ^29.5.0
"@langchain/anthropic": ^0.3.5
"@langchain/community": ^0.3.9
"@langchain/core": ^0.3.16
"@langchain/core": ^0.3.22
"@langchain/langgraph-checkpoint": ~0.0.12
"@langchain/langgraph-checkpoint-postgres": "workspace:*"
"@langchain/langgraph-checkpoint-sqlite": "workspace:*"
Expand Down Expand Up @@ -6641,7 +6641,7 @@ __metadata:
dependencies:
"@langchain/anthropic": ^0.3.5
"@langchain/community": ^0.3.9
"@langchain/core": ^0.3.16
"@langchain/core": ^0.3.22
"@langchain/groq": ^0.1.2
"@langchain/langgraph": "workspace:*"
"@langchain/mistralai": ^0.1.1
Expand Down Expand Up @@ -8912,6 +8912,25 @@ __metadata:
languageName: node
linkType: hard

"langsmith@npm:^0.2.8":
version: 0.2.9
resolution: "langsmith@npm:0.2.9"
dependencies:
"@types/uuid": ^10.0.0
commander: ^10.0.1
p-queue: ^6.6.2
p-retry: 4
semver: ^7.6.3
uuid: ^10.0.0
peerDependencies:
openai: "*"
peerDependenciesMeta:
openai:
optional: true
checksum: 16f42b7d36509bc0754110cb93b2b6f466d339fb4684d6d1b49fea749ee595329d433c35a8f83b55f2fdf53f9d038444773e4b61815aec340bff28e57b8428b4
languageName: node
linkType: hard

"latest-version@npm:^9.0.0":
version: 9.0.0
resolution: "latest-version@npm:9.0.0"
Expand Down

0 comments on commit 5f324c1

Please sign in to comment.