AgentWorkflowEngine manages workflow execution with built-in retry logic, episode logging, and parallel task processing.
The Workflow path is the older of the two agent-authoring paths. For new
code, see the AgentFlow & Evaluator
protocol — it doesn’t need a custom engine wrapper. The
cookbooks/ directory
has seven worked examples.AgentWorkflowEngine
Constructor
Workflow class to instantiate for each task.
Arguments to pass to workflow instances.
Engine for model inference and rollout.
Optional configuration object for training.
Number of parallel workflow instances to maintain.
Maximum number of retry attempts for failed tasks.
Whether to raise exceptions on permanent failures.
Optional logger for saving episode data to files.
Methods
initialize_pool
Initialize the workflow pool with parallel workflow instances.set_training_step
Set current training step for episode logging.Current training step number.
Mode identifier: “train” or “val”.
Current epoch number.
process_task_with_retry
Process a single task rollout with retry logic based on termination reasons.Task dictionary containing the task specification.
Unique identifier for the task.
Index of this rollout attempt for the task.
The task ID.
The rollout index.
Completed episode.
execute_batch
Execute a batch of tasks with automatic retry and error handling.List of task dictionaries.
Number of rollouts to generate per task.
List of completed episodes.
Retry Logic
The engine automatically retries tasks based on termination reason:- Retryable:
TIMEOUT,ERROR,MAX_PROMPT_LENGTH_EXCEEDED,MAX_RESPONSE_LENGTH_EXCEEDED - Non-retryable:
ENV_DONE,MAX_TURNS_EXCEEDED,UNKNOWN
retry_limit times before failing permanently.

