> This page is for version 0.4.0.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

> 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.verifiers

Helpers for a Harbor task's Python verifier (`tests/verifier.py`, or `verifier.py` at the dataset root).

A Python verifier is a module with a `verify` function. It runs inside the task's verifier sandbox, never
on the host: the `harbor` environment server (and `gym dataset publish --harbor`) wraps it in a
`tests/test.sh` shim that carries this package along, so `from nemo_gym.verifiers import ...` works in
the sandbox with nothing installed. Everything here is therefore standard library only, and this package
imports nothing else from `nemo_gym`.

`verify` declares the arguments it wants and the runner passes those alone (by name, or by position for a
positional-only parameter such as `def verify(workspace, /)`):

* `workspace` (`pathlib.Path`): the task's working directory, where the agent worked;
* `task_data` (`dict`): the task's own fields (`task_data.json`, a parameterized row);
* `response` (`dict` or `None`): the agent's final Responses API response (not available to a
  published Harbor task, whose `test.sh` sees only the container);
* `state` (`dict`): `{"workspace": Path}`, the RFC's spelling of the workspace.

It returns a number (the reward) or a dict with a `reward` key and other numeric keys as metrics; an
`async def verify` is awaited. A `verify` that requires `response` without a default is a contract error (no
reward) wherever no response exists, which is every published Harbor task.

## Submodules

* **[`nemo_gym.verifiers.files`](/nemo/gym/nemo-gym/nemo_gym/verifiers/files)**
* **[`nemo_gym.verifiers.runner`](/nemo/gym/nemo-gym/nemo_gym/verifiers/runner)**

## Package Contents

### Functions

| Name                                                 | Description                                                                                            |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| [`_parse_number`](#nemo_gym-verifiers-_parse_number) | -                                                                                                      |
| [`exact_match`](#nemo_gym-verifiers-exact_match)     | `1.0` when the two strings agree, after stripping surrounding whitespace by default.                   |
| [`final_text`](#nemo_gym-verifiers-final_text)       | The text of the agent's final assistant message in a Responses API response (`""` when there is none). |
| [`numeric_match`](#nemo_gym-verifiers-numeric_match) | `1.0` when the last number in `actual` equals `expected` within the tolerances.                        |

### Data

[`_NUMBER`](#nemo_gym-verifiers-_NUMBER)

### API

```python
nemo_gym.verifiers._parse_number(
    text: str
) -> float | None
```

```python
nemo_gym.verifiers.exact_match(
    actual: str,
    expected: str,
    strip: bool = True,
    case_sensitive: bool = True
) -> float
```

`1.0` when the two strings agree, after stripping surrounding whitespace by default.

```python
nemo_gym.verifiers.final_text(
    response: typing.Mapping[str, typing.Any] | None
) -> str
```

The text of the agent's final assistant message in a Responses API response (`""` when there is none).

Walks `response["output"]` from the end and returns the concatenated `output_text` parts of the last
`message` item; a response that is `None` or carries no message yields `""`.

```python
nemo_gym.verifiers.numeric_match(
    actual: str | float,
    expected: str | float,
    rel_tol: float = 1e-06,
    abs_tol: float = 0.0
) -> float
```

`1.0` when the last number in `actual` equals `expected` within the tolerances.

Strings are searched for their last number (`"The answer is 72."` reads as `72`; thousands separators
are dropped); a string without one scores `0.0`.

```python
nemo_gym.verifiers._NUMBER = re.compile('[-+]?(?:\\d+(?:[.,]\\d+)*(?:\\.\\d+)?|\\.\\d+)(?:[eE][-+]?\\d+)?')
```