JSON TransformArray
push
Append elements to the end of an array
push
Adds one or more items to the end of an array. If items is itself an array, its elements are appended individually (spread); otherwise the value is appended as a single element.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
items | any | Yes | — | Item or array of items to append. Selectors inside are resolved first. |
Example
Input
[1, 2, 3]Operation
{ "type": "push", "options": { "items": [4, 5] } }Output
[1, 2, 3, 4, 5]In a Circuit Step
{
"name": "append_followup",
"description": "Append a follow-up message to the conversation",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ messages }}",
"operations": [
{
"type": "push",
"options": {
"items": [
{ "role": "user", "content": "${{ input.followup }}" }
]
}
}
]
},
"outputs": [
{
"name": "extended_messages",
"description": "Messages with follow-up appended",
"value": "${{ append_followup.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
push: expected arrayif the input is not an array. - Pushing a non-array value appends it as a single element:
push({ "items": "hello" })on["a"]yields["a", "hello"]. itemsis fully selector-evaluated before append —"items": "${{ input.tail }}"works, including selectors nested inside anitemsarray.- To wrap a single array as one element rather than spreading it, use
insertAtat the end index, or wrap it manually:"items": [["nested", "array"]].