langgraph/how-tos/update-state-from-tools/ #2806
Replies: 15 comments 11 replies
-
Is this supported for langgraph JS? I can't find the page for it |
Beta Was this translation helpful? Give feedback.
-
what if the tool is a pydantic model class for structured output. how to set the update state logic (return Command()) |
Beta Was this translation helpful? Give feedback.
-
i found an issue: when LLM call mutliple tools at once, only the last tool call message stream output, others not output. |
Beta Was this translation helpful? Give feedback.
-
FYI, in order to update the state from a tool by using Command, it seems that the state MUST be a subclass of Hopefully, this saves you some time |
Beta Was this translation helpful? Give feedback.
-
this is good, but how can i person update the graph state but doesn't let the agent know? will it also receive the updated state? as it usually receive the output of what happened in the tool, for the agent can be effective. i want the agent to recive a msg but also update the state. |
Beta Was this translation helpful? Give feedback.
-
Where is Command defined? I don't see how to import it. Never mind, I found it. For anyone else wondering: From: https://langchain-ai.github.io/langgraph/how-tos/update-state-from-tools/#define-tool |
Beta Was this translation helpful? Give feedback.
-
yesssssssssssssss
…On Tue, Jan 14, 2025 at 9:42 PM Corey ***@***.***> wrote:
Is it possible to get state from within a tool using Langgraph JS? In
Python, it looks like there's an InjectedState value but not seeing such a
thing in JS. If not, i'll have to rethink how i'm utilizing the graph.
—
Reply to this email directly, view it on GitHub
<#2806 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUCPIWC2P45NDXCTZQ6U3RL2KU47JAVCNFSM6AAAAABTZVROVSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOBTGM3TOMQ>
.
You are receiving this because you commented.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
I use : '''
''' but get an error 1 validation error for process_qualifications |
Beta Was this translation helpful? Give feedback.
-
I am getting following error on multiple parallel tool calls of the same tool
following is the way I have structured the tool class AgentState(TypedDict):
messages: Annotated[list[AnyMessage], operator.add]
last_tool_call: Annotated[Optional[str], operator.add] = None
@tool
async def meeting_slots_finder(
params: MeetingSlotFindInput,
tool_call_id: Annotated[str, InjectedToolCallId],
config: RunnableConfig
):
return Command(
update={
"last_tool_call": "meeting_slots_finder",
"messages": [
ToolMessage(
tool_call_id=tool_call_id,
content=', '.join(timeslots)
)
]
},
) how can I fix this above error? |
Beta Was this translation helpful? Give feedback.
-
Before we added a router function after the ToolNode to go to the llm or depending on the tool.
|
Beta Was this translation helpful? Give feedback.
-
I create the following function that returns Command with some state updates. When I use the async streaming like agent.astream(...) (with debug mode on and stream mode set to "messages"), I can clearly see that the ToolMessage is printed in the terminal. However, the same ToolMessage does not seem to be streamed, since I am not receiving a chunk for it. And when the retrieve the message history after this call, I also do see the ToolMessage there. This is rather a weird behavior, since I'd expect to not see the ToolMessage in the state history if it was not working correctly. Can someone explain if I am doing something wrong? Tool implementation
Graph compilation
Streaming (adjusted for AI SDK on FE)
|
Beta Was this translation helpful? Give feedback.
-
How would you go about writing tests for a tool based on this? |
Beta Was this translation helpful? Give feedback.
-
Could you show an example of updating state through a tool without using create_react_agent and ToolNode? Also, is it possible without Command? |
Beta Was this translation helpful? Give feedback.
-
@hinthornw If I have a tool which a child class of BaseTool, how can I do the update? Any help is really appreciated! |
Beta Was this translation helpful? Give feedback.
-
is there any way to update the state inside the tool without returning
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
langgraph/how-tos/update-state-from-tools/
Build language agents as graphs
https://langchain-ai.github.io/langgraph/how-tos/update-state-from-tools/
Beta Was this translation helpful? Give feedback.
All reactions