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

rollout_engine
RolloutEngine
The rollout engine for model inference.
executor
ThreadPoolExecutor
Thread pool executor for async operations.
timeout
float
default:"1e6"
Timeout for workflow execution in seconds.
gamma
float
default:"0.0"
Discount factor for reward computation. When > 0, computes Monte Carlo returns.
reward_bonus_coeff
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.
task
dict
The task to execute.
uid
str
Unique identifier for the task.
episode
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.
name
str | None
Name for the trajectory.
agent
BaseAgent | None
Agent whose trajectory to commit.
trajectory
Trajectory | None
Trajectory to commit directly (alternative to agent).
reset
bool
default:"False"
Whether to reset the agent after committing.

collect_trajectories

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

reset

Reset the workflow for a new task.
task
dict | None
The task to reset to.
uid
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

rollout_engine
RolloutEngine
Engine for model inference.
reward_function
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

agent_cls
type | str
Agent class (a BaseAgent subclass) or string identifier registered in env_agent_mappings.
env_cls
type | str
Environment class or string identifier.
agent_args
dict | None
Arguments to pass to agent constructor.
env_args
dict | None
Arguments to pass to environment constructor.
max_steps
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