Skip to main content

Goals

  • Understand what rollouts are and why you would record them.
  • Record rollouts from an agent interacting with an OpenReward environment.
  • Use provider-specific logging methods for OpenAI, Anthropic, Google Gemini, and OpenRouter.
  • View recorded rollouts in the OpenReward dashboard.

Prerequisites

  • An OpenReward account
  • An OpenReward API key
  • An API key and SDK for your model provider of choice (e.g. OpenAI, Anthropic, Google, OpenRouter)
  • Familiarity with the Your First Environment tutorial

Setup

Install the OpenReward Python library:

What are Rollouts?

A rollout is a recorded trace of an agent interacting with an environment. It captures every message exchange — user prompts, assistant responses, reasoning steps, tool calls, and tool results — along with associated rewards and metadata. Recording rollouts is useful for:
  • Debugging: Inspect exactly what your agent did step-by-step.
  • Analysis: Compare performance across models, prompts, or environment configurations.
  • Training data: Collect trajectories for supervised finetuning or midtraining.
  • Collaboration: Your team can view runs on your organisation’s OpenReward page.
The OpenReward Python SDK provides provider-specific logging methods that automatically serialize messages from OpenAI, Anthropic, and Google Gemini into a normalized format. For OpenRouter (which uses the OpenAI SDK), you use the OpenAI completions logger.

Key Concepts

Runs and Rollouts

A run groups related rollouts together under a single name (e.g. "gpt-5.4-ctf-eval"). Each rollout within a run represents one episode or conversation with the environment.

Creating a Rollout

Logging Methods

The SDK provides these logging methods on a Rollout object: Each method also accepts these parameters:
  • reward (Optional[float]): Reward signal for this step
  • is_finished (Optional[bool]): Whether this step ends the episode
  • metadata (Optional[dict]): Arbitrary metadata for this step

Flushing Events

When you are done logging, call or_client.rollout.close() to ensure all pending events are flushed and uploaded:

Recording Rollouts by Provider

In this example we will sample the GeneralReasoning/CTF environment and record the full rollout trace to OpenReward.
1

Set your API keys

Make sure you have API keys for OpenReward and OpenAI, and set these as environment variables:
2

Create your code

Save this as record_rollout.py:
3

Run your code

Viewing Rollouts

After running your code, head to OpenReward and your profile page. Go to the Runs tab to see your recorded runs: Runs in the OpenReward UI Click on a run to see its rollouts: Example run Click on a specific rollout to inspect the full message timeline, including reasoning steps, tool calls, and rewards: Example rollout

Next Steps

Train with OpenReward

Use recorded rollouts as part of a reinforcement learning training pipeline.

Evaluate with OpenReward

Run systematic evaluations across environments and models.

Build your own environment

Create custom environments for your use case.

Using the AsyncClient

Record rollouts asynchronously for better performance.