for_each

A special system tool that allows for iteration over a list of items.

Fields

NameTypeDescriptionRequired

returns_key

string

If declared, this variable will be returned as an array of items from the loop. Note: We automatically flatten sub-arrays and highly recommend your return value be processed into one primative inside the loop before returning the value.

items

array

The list of items to iterate over.

parallel

boolean

If true, the tools will be run in parallel. If false, the tools will be run in series.

each_item.item_name

string

The name of the variable to use for the current item in the loop.

each_item.tools

array

The list of tools to run for each item in the loop. Each iteration is run in parallel.

Returns

TypeDescription

prompt array

The list of items from the loop.

Example

- name: for_each
  items: <list-of-items>
  returns_key: <optional-return-key-for-block-scope>
  each_item:
    item_name: <name-of-iteration-variable>
    tools: <list-of-tools>
  returns: <return-value-list-from-block-scope-name>

Last updated