> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maadify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tool Executions

> Configure execute-tool actions, payloads, loops, and templated inputs

## Add a tool execution

<Steps>
  <Step title="Add the tool action">
    In the parent agent flow, select **Execute tool** and choose a tool.

    <Frame>
      <img src="https://mintcdn.com/maadify/X4aEKWAIWIr8YAhZ/images/tool-executions/add_tool_execution.png?fit=max&auto=format&n=X4aEKWAIWIr8YAhZ&q=85&s=04dbd533aefa7c0a2adafced9aa5381d" alt="Action picker showing the Execute tool option with a tool selected" width="1116" height="632" data-path="images/tool-executions/add_tool_execution.png" />
    </Frame>
  </Step>

  <Step title="Configure inputs">
    Use schema fields or a custom JSON payload to build inputs.

    <Frame>
      <img src="https://mintcdn.com/maadify/X4aEKWAIWIr8YAhZ/images/tool-executions/schema_based_payload.png?fit=max&auto=format&n=X4aEKWAIWIr8YAhZ&q=85&s=5459ed813ee87c8ca25eae5525b7ffaf" alt="Execute tool payload editor showing the schema fields and custom JSON toggle" width="1099" height="833" data-path="images/tool-executions/schema_based_payload.png" />
    </Frame>
  </Step>

  <Step title="Test execution">
    Run a test execution to confirm inputs and outputs. Run this in chat to verify inputs and outputs.
  </Step>
</Steps>

## Execute tool configuration

When you add an **execute tool** action, you can control how inputs are built and how the tool runs.

* **Payload type**: schema-driven fields or a custom JSON payload.
* **Access level**: full access or restricted access based on tool defaults. Use will always default with the default tool configurations set on the tool.
* **Async execution**: run the tool in the background, it will use a fire and forget approach.
* **Context memory**: store outputs into memory for agents to access, later or for context management.
* **Schema validation**: surface errors when filling out the payload.

<Tip>
  Use schema payloads when you want guardrails. Use custom JSON for advanced mappings.
</Tip>

<Frame>
  <img src="https://mintcdn.com/maadify/X4aEKWAIWIr8YAhZ/images/tool-executions/schema_based_payload.png?fit=max&auto=format&n=X4aEKWAIWIr8YAhZ&q=85&s=5459ed813ee87c8ca25eae5525b7ffaf" alt="Variable picker grouped by Tools, Runtime inputs, Structured outputs, and Memory context" width="1099" height="833" data-path="images/tool-executions/schema_based_payload.png" />
</Frame>

**Context variable memory configuration**

<Frame>
  <img src="https://mintcdn.com/maadify/X4aEKWAIWIr8YAhZ/images/tool-executions/context_variable_memory_config.png?fit=max&auto=format&n=X4aEKWAIWIr8YAhZ&q=85&s=6ff61fadf287051cb8c19e08412ba4b1" alt="Execute tool configuration panel showing payload type, access level, async execution, context memory, and schema validation settings" width="1040" height="208" data-path="images/tool-executions/context_variable_memory_config.png" />
</Frame>

## Variable templating for tool inputs

Custom payloads and schema values support Jinja-style templating. This lets you map outputs from earlier steps into tool inputs.

### What context variables are available

You can reference:

* **Tool outputs** by tool name and field path.
* **Sub-agent outputs** surfaced through structured outputs or raw message content.
* **Runtime inputs** captured earlier in the workflow, these can be files, trigger inputs, questions, chat history, or current group chat messages.
* **Context variables** carried across all steps these include all tool outputs for all tool execution instances and sub-agent structured outputs.

If you have multiple instances of the same tool, append `__{instance_id}` to the tool name.

### How variables appear in the UI

Use the variable picker to browse and insert values. Variables are grouped by:

* **Tools**: each configured tool output is listed under the tool name.
* **Runtime inputs**: values captured from triggers or previous steps.
* **Structured outputs**: fields saved from sub-agent responses.

<Tip>
  If a variable is missing, make sure the tool ran, the step completed, and the output was saved to context.
</Tip>

<Frame>
  <img src="https://mintcdn.com/maadify/X4aEKWAIWIr8YAhZ/images/tool-executions/select_variable.png?fit=max&auto=format&n=X4aEKWAIWIr8YAhZ&q=85&s=bad1decd46a8f93b0ab1a186ccc6e592" alt="Variable picker grouped by Tools, Runtime inputs, Structured outputs, and Memory context" width="727" height="283" data-path="images/tool-executions/select_variable.png" />
</Frame>

### Common variable paths

Use these patterns when inserting variables:

* **Tool output**: `{{ tool_key.data.field }}` where tool\_key is the `{tool_name}_{tool_id}`
* **Tool output with instance**: `{{ tool_key__instance_id.data.field }}` where tool\_key is the `{tool_name}_{tool_id}` and instance\_id is the instance id of the tool execution.
* **Nested objects**: `{{ tool_key.data.object.child }}`
* **Arrays**: `{{ tool_key.data.items.0.sku }}` gets the first item in the array.
* **Structured output**: `{{ sub_agent_name_id.key }}` where sub\_agent\_name\_id is the `{sub_agent_name}_{sub_agent_id}`
* **Runtime input**: `{{ input.question }}` gets the question from the runtime input.
* **Inside Loops**: `{{ _loop.property }}` gets the property from each item when the tool is executed in a loop.

<Note>
  Exact variable labels match what you see in the picker. Use the picker to avoid typos.
</Note>

### Variable syntax

<Frame>
  <img src="https://mintcdn.com/maadify/X4aEKWAIWIr8YAhZ/images/tool-executions/custom_payload.png?fit=max&auto=format&n=X4aEKWAIWIr8YAhZ&q=85&s=bc46e938d938ab1521736df1b8af3c62" alt="Custom JSON payload editor showing Jinja-style variables, filters, and conditionals inline with the payload" width="1063" height="443" data-path="images/tool-executions/custom_payload.png" />
</Frame>

```json theme={null}
{
  "order_id": "{{ get_order_99__1.data.id }}",
  "customer": "{{ get_order_99__1.data.customer_name }}"
}
```

```json theme={null}
{
  "order_id": "{{ get_order__1.data.id }}",
  "backup_id": "{{ get_order__2.data.id }}"
}
```

### Nested properties

```json theme={null}
{
  "email": "{{ get_customer_99.data.customer.email }}",
  "city": "{{ get_customer_99.data.customer.address.city }}"
}
```

### Filters

Use filters to transform values:

* `default` for fallbacks
* `tojson` to serialize objects or lists
* `upper`, `lower`, `trim`
* `length` for counts
* `join` for list formatting

```json theme={null}
{
  "note": "{{ order.data.note | default('No notes') }}",
  "tags": {{ order.data.tags | default([]) | tojson }},
  "email": "{{ user.data.email | lower | trim }}"
}
```

### Conditionals

```json theme={null}
{
  "priority": "{% if order.data.total > 100 %}high{% else %}normal{% endif %}"
}
```

### Loops

```json theme={null}
{
  "items": [
    {% for item in products.data.items %}
    { "sku": "{{ item.sku }}", "qty": {{ item.quantity }} }{% if not loop.last %},{% endif %}
    {% endfor %}
  ]
}
```

<Tip>
  Use `tojson` for arrays or objects to keep valid JSON in custom payloads.
</Tip>

## Loops and skip conditions

Execute-tool actions can iterate over arrays and conditionally skip items.

* **Loop on**: select an array path in the tool input.
* **Max iterations**: prevent runaway loops.
* **Fail on error**: stop immediately or continue on errors.
* **Skip conditions**: use all/any groups with nested condition sets. These can be used to skip items in a loop or to skip the tool execution if a condition is met.

<Frame>
  <img src="https://mintcdn.com/maadify/X4aEKWAIWIr8YAhZ/images/tool-executions/loop_configuration.png?fit=max&auto=format&n=X4aEKWAIWIr8YAhZ&q=85&s=bfeeb47f1b17b3d3f961a27cde7d8110" alt="Execute tool loop configuration with skip conditions" width="756" height="736" data-path="images/tool-executions/loop_configuration.png" />
</Frame>
