Async Component
Use the Async component to run parts of your workflow in the background. It's essential for long-running tasks like processing large files or looping through thousands of records, preventing timeouts and keeping your main agent responsive.
Why this matters
What You’ll Configure
- Define Inputs
- Understand Outputs
- How to Debug
- When to use Await
- Best Practices
- Troubleshooting Tips
- What to Try Next
Step 1: Define Inputs
Inputs for the Async
component are the data you need to pass to the background workflow. Each input you define here becomes available as a variable within the async branch.
Field | Required? | Description | Notes |
---|---|---|---|
Input Name | Yes | A unique name for your input. | This name becomes an output variable to use in the async flow. |
Type | Yes | Data type (String, Number, Array, etc.). | Ensures data is handled correctly in the background process. |
Default Value | No | A fallback value if no input is provided. | Useful for testing or making inputs optional. |
Optional | No | Marks the input as not required for execution. | The workflow will proceed even if this input is not supplied. |
Parameterizing Your Job
Step 2: Understand Outputs
The Async
component has a primary output in the main workflow and makes your inputs available within the async branch.
Output | Description | Where It's Available |
---|---|---|
JobID | A unique reference ID for the asynchronous job that was just started. | Main workflow (immediately) |
(Your Inputs) | Each input you defined in Step 1 is available as an output variable to be used in subsequent steps. | Inside the async branch only |
A Tale of Two Workflows
Step 3: How to Debug Async Workflows
Debugging is different
- Go to Agent Settings > Logs.
- Find the execution log for your main workflow that triggered the
Async
component. - A separate log entry will exist for the async workflow. You can find it by looking for a new run that started at the same time.
- Review this separate log to see the step-by-step execution and identify any errors in your background task.
Step 4: When to Use the Await Component
Use the Await Component only when your main workflow must pause and wait for a result from the async job before it can continue.
Use Case | Use Async alone? | Use Async + Await ? |
---|---|---|
Fire-and-forget tasks (e.g., sending notifications) | Yes | No |
Solving a timeout in a long loop | Yes | No |
Needing results back in the same user session | No | Yes |
TIP
Best Practices
- Develop Synchronously First: Build and debug the core logic in a standard workflow. Once it works correctly, wrap it in an
Async
component. - Implement Completion Notifications: Since the job runs in the background, have it notify you of its completion. The last step in your async branch could be a Send Email, Slack Message, or API Call to another system.
- Use for Heavy Lifting: Reserve
Async
for truly long-running tasks: processing large datasets, complexFor Each
loops, or calling slow external APIs that would otherwise time out. - Store Results Persistently: It's often safer to have the async job save its output to a database, file storage, or a system of record rather than relying on
Await
.
Troubleshooting Tips
If your async job fails or doesn't run...
What to Try Next
- Combine
Async
with the Await Component to get results back in your main flow. - Use
Async
to wrap a For Each Loop that processes thousands of records from a database without timing out. - Store results from an async job in a permanent location using RAG Remember or by calling an external database.