File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @langchain/langgraph " : patch
3+ ---
4+
5+ Fix ` stateKey ` property in ` pushMessage ` being ignored when RunnableConfig is automatically inherited
Original file line number Diff line number Diff line change 44 coerceMessageLikeToMessage ,
55} from "@langchain/core/messages" ;
66import type { RunnableConfig } from "@langchain/core/runnables" ;
7- import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons" ;
87import { v4 } from "uuid" ;
98import { StateGraph } from "./state.js" ;
9+ import { ensureLangGraphConfig } from "../pregel/utils/config.js" ;
1010import type { StreamMessagesHandler } from "../pregel/messages.js" ;
1111
1212export const REMOVE_ALL_MESSAGES = "__remove_all__" ;
@@ -123,16 +123,9 @@ export function pushMessage(
123123 stateKey ?: string | null ;
124124 }
125125) {
126- const rawOptions :
127- | ( RunnableConfig & { stateKey ?: string | null } )
128- | undefined =
129- options ?? AsyncLocalStorageProviderSingleton . getRunnableConfig ( ) ;
126+ const { stateKey : userStateKey , ...userConfig } = options ?? { } ;
127+ const config = ensureLangGraphConfig ( userConfig ) ;
130128
131- if ( rawOptions == null ) {
132- throw new Error ( "Calling pushMessage outside the context of a graph." ) ;
133- }
134-
135- const { stateKey : userStateKey , ...config } = rawOptions ;
136129 let stateKey : string | undefined = userStateKey ?? "messages" ;
137130 if ( userStateKey === null ) stateKey = undefined ;
138131
You can’t perform that action at this time.
0 commit comments