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<
9393> = Omit < RunAgentInput , "forwardedProps" > & {
9494 forwardedProps ?: Omit < RunsStreamPayload < TStreamMode , TSubgraphs > , "input" > & {
9595 nodeName ?: string ;
96+ threadMetadata ?: Record < string , any > ;
9697 } ;
9798} ;
9899
@@ -166,7 +167,7 @@ export class LangGraphAgent extends AbstractAgent {
166167 this . assistant = await this . getAssistant ( ) ;
167168 }
168169
169- const thread = await this . getOrCreateThread ( threadId ) ;
170+ const thread = await this . getOrCreateThread ( threadId , forwardedProps ?. threadMetadata ) ;
170171 this . activeRun ! . threadId = thread . thread_id ;
171172 const agentState = await this . client . threads . getState ( thread . thread_id ) ?? { values : { } } as ThreadState
172173
@@ -673,13 +674,16 @@ export class LangGraphAgent extends AbstractAgent {
673674 return state ;
674675 }
675676
676- async getOrCreateThread ( threadId : string ) : Promise < Thread > {
677+ async getOrCreateThread ( threadId : string , threadMetadata ?: Record < string , any > ) : Promise < Thread > {
677678 let thread : Thread ;
678679 try {
679680 try {
680681 thread = await this . getThread ( threadId ) ;
681682 } catch ( error ) {
682- thread = await this . createThread ( { threadId } ) ;
683+ thread = await this . createThread ( {
684+ threadId,
685+ metadata : threadMetadata
686+ } ) ;
683687 }
684688 } catch ( error : unknown ) {
685689 throw new Error ( `Failed to create thread: ${ ( error as Error ) . message } ` ) ;
You can’t perform that action at this time.
0 commit comments