File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
typescript-sdk/integrations/langgraph/src Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ type RunAgentExtendedInput<
93
93
> = Omit < RunAgentInput , "forwardedProps" > & {
94
94
forwardedProps ?: Omit < RunsStreamPayload < TStreamMode , TSubgraphs > , "input" > & {
95
95
nodeName ?: string ;
96
+ threadMetadata ?: Record < string , any > ;
96
97
} ;
97
98
} ;
98
99
@@ -166,7 +167,7 @@ export class LangGraphAgent extends AbstractAgent {
166
167
this . assistant = await this . getAssistant ( ) ;
167
168
}
168
169
169
- const thread = await this . getOrCreateThread ( threadId ) ;
170
+ const thread = await this . getOrCreateThread ( threadId , forwardedProps ?. threadMetadata ) ;
170
171
this . activeRun ! . threadId = thread . thread_id ;
171
172
const agentState = await this . client . threads . getState ( thread . thread_id ) ?? { values : { } } as ThreadState
172
173
@@ -673,13 +674,16 @@ export class LangGraphAgent extends AbstractAgent {
673
674
return state ;
674
675
}
675
676
676
- async getOrCreateThread ( threadId : string ) : Promise < Thread > {
677
+ async getOrCreateThread ( threadId : string , threadMetadata ?: Record < string , any > ) : Promise < Thread > {
677
678
let thread : Thread ;
678
679
try {
679
680
try {
680
681
thread = await this . getThread ( threadId ) ;
681
682
} catch ( error ) {
682
- thread = await this . createThread ( { threadId } ) ;
683
+ thread = await this . createThread ( {
684
+ threadId,
685
+ metadata : threadMetadata
686
+ } ) ;
683
687
}
684
688
} catch ( error : unknown ) {
685
689
throw new Error ( `Failed to create thread: ${ ( error as Error ) . message } ` ) ;
You can’t perform that action at this time.
0 commit comments