Updating a Variable in Workflow: Effective Strategies Explained
Is there an effective way to update variables once set? For example:
- 1.
In the beginning of a flow, set a variable "myvariable" as a whole number - such as 10
- 2.
prompt ai command - perform a basic task, set to search for up to three people at a time, up to a maximum of the "myvariable" count
- 3.
decrease variable "myveriable" by the number of people returned
- 4.
reach condition:
- a.
Condition A: If variable is >0, return to 2
- b.
Condition B: If variable is 0, print message and complete flow/exit
If, for example, the myvariable was initially set to 10, and each search successfully returned up to 3 people, it would cycle 4 times. Cycle 1: Return 3 people, reduce variable to 7 Cycle 2: Return 3 people, reduce variable to 4 Cycle 3: Return 3 people, reduce variable to 1 Cycle 4: Return 1 person, reduce variable to 0, reach condition loop completion criteria I swear I used to be able to do this by setting a variable again with the same name, however it seems to then create a new variable, hence I can't continually refer to a variable that should be updated in-place. I'm thinking of using memory instead, but I'm guessing somehow I'm misusing variable because it's supposed to be able to ... vary. This isn't the only thing I need to update on the fly - other variables would be lists of names, etc. I can commit and read these from a google sheet as an option but as lists grow I believe this may become "expensive" - whether model costs or context management in general.