Workflow Retry Template
The Workflow Retry template demonstrates how BindAI can retry a failed workflow node before ultimately failing the workflow. Retry behavior is handled by the workflow executor. When a node raises an exception and a retry policy is configured, the executor attempts the node again until it succeeds or the configured maximum number of attempts is reached. This template introduces executor-level failure recovery.Purpose
This template demonstrates how to:- configure a retry policy
- retry failed node execution
- limit retry attempts
- continue after a successful retry
- handle final workflow failure
Workflow Structure
A retry-enabled workflow can be represented as:Retry Policy
A workflow context can contain aRetryPolicy.
Example:
max_attemptsdelay_secondsexponential_backoff
max_attempts to control retries.
Execution Flow
When a node executes successfully:Retry Lifecycle
For a policy with:Retry Counter
The workflow context tracks the current attempt using:Successful Recovery
A retry can recover from a temporary node failure. For example:Retry Without a Policy
If a node fails without a retry policy:Retry Limit
Themax_attempts setting limits the total number of attempts.
Example:
Delay Configuration
The retry policy defines:Exponential Backoff
The retry policy also defines:Exception Handling
The current retry implementation does not restrict retries to specific exception types. Whennode.execute() raises an exception:
retry_on configuration for selecting specific exception classes.
Retry vs Loop
Retry and Loop templates solve different problems.
Use Retry for failure recovery.
Use Loop for intentional iteration.
Retry and Timeout
Retry can be combined with workflow timeout behavior.Final Failure
When all allowed attempts fail, the executor invokes normal workflow failure handling. The workflow:- records the error
- marks execution as completed
- records a
workflow.failedevent - persists the workflow instance
- stores failed execution history
- returns an unsuccessful workflow result
Example Workflow
A conceptual retry workflow looks like:Best Practices
- Set
max_attemptsdeliberately. - Retry operations only when repeating them is safe.
- Do not assume configured delay is currently active.
- Do not assume exponential backoff is currently active.
- Remember that all node exceptions are eligible for retry when a policy exists.
- Avoid retrying non-idempotent operations unless they are designed for safe repetition.
- Combine retry policies with timeout policies when appropriate.
- Monitor repeated failures in production.
Related Templates
The Retry template works naturally with:- Workflow Parallel
- Workflow Timeout
- Workflow Schedule
- Workflow Loop
Summary
The Workflow Retry template demonstrates executor-level recovery from failed node execution. When a node raises an exception and aRetryPolicy is configured, BindAI retries the node until it succeeds or max_attempts is reached.
The current implementation retries immediately. Although delay_seconds and exponential_backoff are part of the policy configuration, they are not yet applied by the executor.
This makes the current retry implementation a simple and predictable attempt-limit mechanism that can be extended later with delay, backoff, and more selective exception handling.