Skip to main content
Workflows orchestrate the interaction between an agent, an environment, and a rollout engine to execute multi-step tasks.
Workflows are the older of the two agent-authoring paths in rLLM. New agents should be authored as AgentFlows — see the Cookbooks tutorial and cookbooks/. Workflows remain supported for the use cases where you want explicit BaseAgent + BaseEnv separation; the seven cookbooks ship as examples of the AgentFlow alternative.

Workflow

Abstract base class for all workflows.

Constructor

RolloutEngine
The rollout engine for model inference.
ThreadPoolExecutor
Thread pool executor for async operations.
float
default:"1e6"
Timeout for workflow execution in seconds.
float
default:"0.0"
Discount factor for reward computation. When > 0, computes Monte Carlo returns.
float
default:"0.0"
Coefficient for reward shaping based on reward deltas.

Methods

run

Execute the workflow on a single task. Must be implemented by subclasses.
dict
The task to execute.
str
Unique identifier for the task.
Episode | None
The generated episode.

run_with_termination_handling

Wrapper around run() that handles termination events, errors, and timeouts.

commit

Commit a trajectory for training.
str | None
Name for the trajectory.
BaseAgent | None
Agent whose trajectory to commit.
Trajectory | None
Trajectory to commit directly (alternative to agent).
bool
default:"False"
Whether to reset the agent after committing.

collect_trajectories

Collect all trajectories from committed and agent instances.
Episode
Episode containing all trajectories.

reset

Reset the workflow for a new task.
dict | None
The task to reset to.
str | None
Unique identifier for the task.

postprocess_episode

Post-process episode after completion (compute rewards, metrics, etc.).

SimpleWorkflow

Simplified workflow for single-agent, single-turn tasks.

Constructor

RolloutEngine
Engine for model inference.
RewardFunction
Function to compute rewards from task and action.

Methods

run

Execute the workflow:
The workflow automatically:
  1. Extracts messages from task (supports question, prompt, problem, or messages keys)
  2. Gets model response
  3. Computes reward
  4. Creates trajectory with step
  5. Returns episode

MultiTurnWorkflow

Workflow for multi-step agent-environment interactions.

Constructor

type | str
Agent class (a BaseAgent subclass) or string identifier registered in env_agent_mappings.
type | str
Environment class or string identifier.
dict | None
Arguments to pass to agent constructor.
dict | None
Arguments to pass to environment constructor.
int
default:"5"
Maximum number of steps before termination.

Methods

run

Execute the multi-step workflow:
The workflow:
  1. Resets environment with task
  2. Updates agent with initial observation
  3. For each step:
    • Gets model response
    • Updates agent with response
    • Steps environment with action
    • Updates agent with new observation and reward
  4. Terminates on done=True or max steps reached

TerminationReason

Enum for workflow termination reasons.

Example: Custom Workflow