Skip to content

Commit 3c29259

Browse files
authored
feat: support latest langgraph context (#375)
1 parent c886269 commit 3c29259

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

typescript-sdk/integrations/langgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"@langchain/core": "^0.3.66",
27-
"@langchain/langgraph-sdk": "^0.0.105",
27+
"@langchain/langgraph-sdk": "^0.1.2",
2828
"partial-json": "^0.1.7",
2929
"rxjs": "7.8.1"
3030
},

typescript-sdk/integrations/langgraph/src/agent.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ export class LangGraphAgent extends AbstractAgent {
333333
streamMode,
334334
input: payloadInput,
335335
config: payloadConfig,
336+
context: {
337+
...context,
338+
...(payloadConfig?.configurable ?? {}),
339+
}
336340
};
337341

338342
// If there are still outstanding unresolved interrupts, we must force resolution of them before moving forward
@@ -947,11 +951,15 @@ export class LangGraphAgent extends AbstractAgent {
947951
try {
948952
const graphSchema = await this.client.assistants.getSchemas(this.assistant!.assistant_id);
949953
let configSchema = null;
954+
let contextSchema: string[] = []
955+
if ('context_schema' in graphSchema && graphSchema.context_schema?.properties) {
956+
contextSchema = Object.keys(graphSchema.context_schema.properties);
957+
}
950958
if (graphSchema.config_schema?.properties) {
951959
configSchema = Object.keys(graphSchema.config_schema.properties);
952960
}
953961
if (!graphSchema.input_schema?.properties || !graphSchema.output_schema?.properties) {
954-
return { config: [], input: null, output: null };
962+
return { config: [], input: null, output: null, context: contextSchema };
955963
}
956964
const inputSchema = Object.keys(graphSchema.input_schema.properties);
957965
const outputSchema = Object.keys(graphSchema.output_schema.properties);
@@ -963,10 +971,11 @@ export class LangGraphAgent extends AbstractAgent {
963971
outputSchema && outputSchema.length
964972
? [...outputSchema, ...this.constantSchemaKeys]
965973
: null,
974+
context: contextSchema,
966975
config: configSchema,
967976
};
968977
} catch (e) {
969-
return { config: [], input: this.constantSchemaKeys, output: this.constantSchemaKeys };
978+
return { config: [], input: this.constantSchemaKeys, output: this.constantSchemaKeys, context: [] };
970979
}
971980
}
972981

typescript-sdk/integrations/langgraph/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface StateEnrichment {
3939
export type SchemaKeys = {
4040
input: string[] | null;
4141
output: string[] | null;
42+
context: string[] | null;
4243
config: string[] | null;
4344
} | null;
4445

typescript-sdk/pnpm-lock.yaml

Lines changed: 22 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)