Dive

Control steps

reduce

Folds a list into one value by running the same steps for each item in order.

How it works

  • over must produce a list. The body (do) runs once per item, in order.
  • {{accumulator}} holds the running value, starting at initial. Each run's result becomes the next {{accumulator}}.
  • {{item}} and {{index}} are available too.

Limits

  • Always runs one item at a time. For independent per-item work, map first and reduce its results.
  • The body can't contain another map or reduce.

Input

doobject | object[]required

Starting accumulator value (any JSON; may use templates). Defaults to null.

overanyrequired

The list to fold — usually a template like {{E1.results}} that resolves to an array.

Result

Later steps read these as {{<step id>.<field>}}.

countinteger

How many items ran.

resultobject

The final value of the accumulator.

- id: E1
  tool_name: reduce
  input:
    over: "{{input.over}}"
    do: "{{input.do}}"
{
  "count": 3,
  "result": {
    "…": "…"
  }
}