Other
Add to state list
Adds a new item to a list in the Agent’s state. Useful for tracking multiple values over time.
Overview
This block adds a string value to a list in the agent’s state. It behaves differently depending on the state element’s type:
- If the state element doesn’t already exist, the block creates it and adds the value to it.
- If the state element already exists as a list, the block adds the value to the list.
- If the state element exists but isn’t a list, the block fails.
The Add to state list block only accepts string values. If you pass a value such as a dictionary, it will be converted to a string and added to the list.
Example
The following example shows an Add to state list block as part of a For-each workflow.
The For-each loop block iterates over a list of values and generates text for each value. Then, the Add to state list block adds the result of each iteration to the state list called text_gen_results
.
On the initial run, the Add to state list block creates the state element and adds the first value to it. Every subsequent run, the block adds the next value to the list.
Fields
Name | Type | Control | Default | Description | Options | Validation |
---|---|---|---|---|---|---|
State element | Text | - | - | - | - | - |
Value | Text | Textarea | - | - | - | - |
End states
Below are the possible end states of the block call.
Name | Field | Type | Description |
---|---|---|---|
Success | - | success | If the function doesn’t raise an Exception. |
Error | - | error | If the function raises an Exception. |