# tinker_cookbook.rl.RolloutStrategy

## _class_ [**tinker_cookbook.rl.RolloutStrategy**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/rollout_strategy.py#L49)( _ABC_)

Controls how trajectories are collected from a group of environments.

Subclasses implement `execute` which receives the [`EnvGroupBuilder`](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/envgroupbuilder/) and a policy, creates envs, runs rollouts, and returns the surviving trajectories plus any error info.

Implementations must be pickleable — use `@dataclass(frozen=True)` with only primitive fields.

### _property_ [**catches_group_errors**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/rollout_strategy.py#L61)

If True, group-level errors (`make_envs`, `compute_group_rewards`) are caught and the group is skipped. If False, they propagate.

**Returns:** _bool_

### [**execute**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/rollout_strategy.py#L67)( _env_group_builder_, _policy_)

Create envs, run rollouts, and return results.

May raise on unrecoverable errors (e.g. retry budget exhausted). The caller (`do_group_rollout`) handles group-level error recovery based on `catches_group_errors`.

**Parameters:**

- [**env_group_builder**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/rollout_strategy.py#L69) ( _[EnvGroupBuilder](https://tinker-docs.thinking-machines.ai/cookbook/api-reference/rl/envgroupbuilder/)_) – Builder used to create the environments for this rollout group.
- [**policy**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/rollout_strategy.py#L70) ( _[TokenCompleter](https://tinker-docs.thinking-machines.ai/cookbook/api-reference/completers/tokencompleter/)_) – The policy (language model) used to generate actions during rollouts.

**Returns:** _RolloutResult_ – The collected trajectories, surviving environments, and any errors encountered.

_Abstract method._

## Referenced by

- [tinker_cookbook.rl.FailFast](https://tinker-docs.thinking-machines-ai/cookbook/api-reference/rl/failfast/)
- [tinker_cookbook.rl.RetryOnFailure](https://tinker-docs.thinking-machines-ai/cookbook/api-reference/rl/retryonfailure/)
