Create agentic workflows with the Invoke Agent block
Learn how to call an agent from a workflow.
Retool Agents Availability | |||
---|---|---|---|
Cloud-hosted | Public beta | ||
Self-hosted (3.280 Edge) | Public beta | ||
Self-hosted (3.196 Stable and later) |
Use the Invoke Agent block to trigger a Retool Agent from a workflow. Invoking an agent from a workflow creates an agentic workflow. Refer to the conceptual guide on agentic workflows for more information.
Some tools require user approval or authentication to execute. These tools are not available in agentic workflows.
This guide provides instructions on how to invoke an agent and retrieve its results. Click the following link to download a sample workflow in JSON form and import it as a new workflow. Configure the workflow to call your own agent.
Sample Workflow
Prerequisites
Before you create an agentic workflow, you must first create an agent. Refer to the Retool Agents tutorial for more information.
Invoke agent
Complete the following steps to add and configure an Invoke Agent block:
- Click and drag to create a new, connected block.
- Select Invoke Agent as the type of block.
- Set Agent to the agent you want to call.
Select the return type
The time period it takes to receive a result from an agent can vary widely based on a variety of factors, including the model used, the number of tools called, and the type of reasoning performed. If you need to use the outcome of your agent call in the workflow, you can get the results either synchronously, or asynchronously, by selecting the Return type.
- The Result (sync) type is the default setting. This returns the direct result of the agent's output.
- The Run state (async) type returns the
agentRunId
,agentId
, andstatus
only. It does not include the output of the agent.
You can then transform the data returned with a Code block, a Filter block, or any other action you may want to take within the workflow.
Handle responses
Finally, set your workflow up to gracefully handle success and failure.
To return a successful response:
- Click and drag to create a new, connected block.
- Chose the Response type.
- Set the Status code to 200.
To handle a failure:
- Right-click on the canvas to create a block that is not connected to the rest of the control flow.
- Chose the Response type.
- Click the ••• menu and select Add global error handler. This setting configures the block as an error handler that applies to the full workflow.
- Set the Status code to
400
. - Paste the following code (or something similar) in the Return body field:
workflowContext.currentRun.error
Test out your workflow by clicking the Run button before you publish it.
Add triggers
Like any other workflow, you can add triggers to run your agentic workflow. Note that if you create a webhook trigger, anyone with access to the webhook will be able to trigger your agent.
Configure block settings
Refer to the Wait block reference for information about the block's settings.