[BUG] Unable to save the value of a state variable from custom tool
Describe the bug I am trying to save the value of a state variable on conditional agent from the custom js tool. but nothing seems to be working
To Reproduce Steps to reproduce the behavior:
- Go to a conditional agent
- Click on custom js tool
- Scroll down to the js code
- See error by trying to save just a random value for a random variable to the state
Expected behavior Should update the value of state variable
can you share the flow? you can only save the state via Update State:
how you can save state with a custom tool ?
I couldn't so decided to save the data from custom tool to a json and later on used it when ever needed. Hope that answers your question.
yeah pretty work around, would be nice in the future to be able to update state everywhere in the flow
yeah, tried everything but that's the best I could find. You can assign the json name to chat id and then you can use it inside other tool with the chat id.
@vishwajeetio could you provide detailed steps as to how you achieved this please? i am stuck on this for days as well.
facing the same issue here. @vishwajeetio can you share details on your solution?
While @vishwajeetio approach of saving data generated by the custom tool into a JSON file is a practical workaround, it introduces additional complexity and potential challenges in file management and data synchronization. A more efficient solution would be to enable custom tools to directly access and modify the $flow.state, allowing the setting of any necessary attributes from within the custom tool. This functionality would provide a more seamless integration, streamline development within the platform, and eliminate the need for alternative solutions, thereby enhancing the overall efficiency of the workflow.
@HenryHengZJ is this possible?
With agentflow V2, you can now use Tool Node, LLM Node or Agent Node to update the flow state: