Flowise icon indicating copy to clipboard operation
Flowise copied to clipboard

[BUG] Unable to save the value of a state variable from custom tool

Open vishwajeetio opened this issue 1 year ago • 5 comments

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:

  1. Go to a conditional agent
  2. Click on custom js tool
  3. Scroll down to the js code
  4. 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

vishwajeetio avatar Aug 30 '24 16:08 vishwajeetio

can you share the flow? you can only save the state via Update State: image

HenryHengZJ avatar Aug 31 '24 13:08 HenryHengZJ

how you can save state with a custom tool ?

takefy-dev avatar Sep 24 '24 15:09 takefy-dev

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.

vishwajeetio avatar Sep 24 '24 15:09 vishwajeetio

yeah pretty work around, would be nice in the future to be able to update state everywhere in the flow

takefy-dev avatar Sep 24 '24 15:09 takefy-dev

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 avatar Sep 24 '24 15:09 vishwajeetio

@vishwajeetio could you provide detailed steps as to how you achieved this please? i am stuck on this for days as well.

veris-christopher avatar Dec 02 '24 06:12 veris-christopher

facing the same issue here. @vishwajeetio can you share details on your solution?

yuralves avatar Jan 11 '25 19:01 yuralves

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?

thiagolealassis avatar Feb 26 '25 13:02 thiagolealassis

With agentflow V2, you can now use Tool Node, LLM Node or Agent Node to update the flow state:

Image

HenryHengZJ avatar Jun 12 '25 23:06 HenryHengZJ