> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.rollout_correlation

## Module Contents

### Classes

| Name                                                                                 | Description                                                                    |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
| [`RolloutContextMiddleware`](#nemo_gym-rollout_correlation-RolloutContextMiddleware) | Strip a rollout prefix and expose it to downstream Gym calls for this request. |

### Functions

| Name                                                                                             | Description                                          |
| ------------------------------------------------------------------------------------------------ | ---------------------------------------------------- |
| [`current_rollout_id`](#nemo_gym-rollout_correlation-current_rollout_id)                         | -                                                    |
| [`maybe_rollout_id_from_run_body`](#nemo_gym-rollout_correlation-maybe_rollout_id_from_run_body) | Build the capture key stamped by rollout collection. |
| [`rollout_context`](#nemo_gym-rollout_correlation-rollout_context)                               | -                                                    |

### Data

[`_ROLLOUT_ID`](#nemo_gym-rollout_correlation-_ROLLOUT_ID)

### API

```python
class nemo_gym.rollout_correlation.RolloutContextMiddleware(
    app: typing.Any
)
```

Strip a rollout prefix and expose it to downstream Gym calls for this request.

**`_PREFIX`**

---

```python
nemo_gym.rollout_correlation.RolloutContextMiddleware.__call__(
    scope: dict[str, typing.Any],
    receive: typing.Any,
    send: typing.Any
) -> None
```

async

```python
nemo_gym.rollout_correlation.current_rollout_id() -> typing.Optional[str]
```

```python
nemo_gym.rollout_correlation.maybe_rollout_id_from_run_body(
    body: pydantic.BaseModel | collections.abc.Mapping[str, typing.Any] | None
) -> typing.Optional[str]
```

Build the capture key stamped by rollout collection.

```python
nemo_gym.rollout_correlation.rollout_context(
    rollout_id: typing.Optional[str]
) -> collections.abc.Iterator[None]
```

```python
nemo_gym.rollout_correlation._ROLLOUT_ID: ContextVar[Optional[str]] = ContextVar('nemo_gym_rollout_id', default=None)
```