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
type[Workflow]
Workflow class to instantiate for each task.
dict
Arguments to pass to workflow instances.
RolloutEngine
Engine for model inference and rollout.
dict | None
Optional configuration object for training.
int
default:"128"
Number of parallel workflow instances to maintain.
int
default:"3"
Maximum number of retry attempts for failed tasks.
bool
default:"True"
Whether to raise exceptions on permanent failures.
EpisodeLogger | None
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.int
Current training step number.
str
default:"train"
Mode identifier: “train” or “val”.
int
default:"0"
Current epoch number.
process_task_with_retry
Process a single task rollout with retry logic based on termination reasons.dict
Task dictionary containing the task specification.
str
Unique identifier for the task.
int
Index of this rollout attempt for the task.
str
The task ID.
int
The rollout index.
Episode
Completed episode.
execute_batch
Execute a batch of tasks with automatic retry and error handling.list[dict]
List of task dictionaries.
int
default:"1"
Number of rollouts to generate per task.
list[Episode]
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.

