I’m defining a LangGraph graph. I wanted a tool to change the conversation state, not only to return a ToolMessage.
I followed this example so I got:
class EndConversationSchema(BaseModel):
"""Call this tool when the user says goodbye"""
reason: str= Field(description="Why does the user want to end the conversation?")
@tool("end_conversation", args_schema=EndConversationSchema)
def end_conversation(
reason: str,
tool_call_id: Annotated[str, InjectedToolCallId]
) -> Command:
""""""
return Command(update={
"active_chat": False,
"messages": [ToolMessage(f"Conversation finished. Reason: {reason}", tool_call_id=tool_call_id)]
})
Now the problem is that when I use this with langgraph.prebuilt.ToolNode
I get: Error: TypeError("``end_conversation()`` missing 1 required positional argument: 'tool_call_id'") Please fix your mistakes.
Any idea on how I am supposed to implement the tool + Command pattern in Langgraph/Langchain?