You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The createReactAgent function does not accept a stateSchema different from MessagesAnnotation.
Current Behavior
When trying to use a custom stateSchema, the linter throws an error as shown below:
import{ChatOpenAI}from"@langchain/openai";import{Annotation}from"@langchain/langgraph";import{MessagesAnnotation}from"@langchain/langgraph";import{createReactAgent}from'@langchain/langgraph/prebuilt';constStateAnnotation=Annotation.Root({
...MessagesAnnotation.spec,// user providedlastName: Annotation<string>,// updated by the tooluserInfo: Annotation<Record<string,any>>,});conststateModifier=(state: typeofStateAnnotation.State)=>{constuserInfo=state.userInfo;if(userInfo==null){returnstate.messages;}constsystemMessage=`User name is ${userInfo.name}. User lives in ${userInfo.location}`;return[{role: "system",content: systemMessage,}, ...state.messages];};constmodel=newChatOpenAI({model: "gpt-4o",});constagent=createReactAgent({llm: model,stateSchema: StateAnnotation,stateModifier: stateModifier,})
jacoblee93
changed the title
createReactAgent does not support custom stateSchema typescreateReactAgent does not support stateModifier with custom stateSchema types
Jan 29, 2025
Issue Description
The
createReactAgent
function does not accept astateSchema
different fromMessagesAnnotation
.Current Behavior
When trying to use a custom
stateSchema
, the linter throws an error as shown below:Additional Information
Repository Version: "@langchain/langgraph": "^0.2.38",
The text was updated successfully, but these errors were encountered: