> This page is for version Main (default).
> 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.

# nemo_gym.models.token_capture.harness_notes

Recognize a message that a harness adds to a request in the model's name.

Some harnesses add an assistant message to a request that the model never wrote, and drop it from the next request,
such as OpenCode's note at its step limit. Capture links calls by their model-authored turns, so such a message would
break every link after it and poison the rollout.

Under capture, the model server forwards such a note as a user message and leaves it out of the items that link calls.
The request then ends with a user turn, and an exact-token worker keeps the parent's tokens up to the parent's own
output and renders the tool results and the note after them. The next request, which no longer carries the note,
still extends those tokens, because the worker keeps them from the parent.

This keeps calls chained where the parent's exact tokens carry over: external staging, or prefix supply on the model
server. With `parent_resolution: source_history`, the replayed history leaves the note out while the forwarded
messages end with it, so each call past the step limit starts a new chain, as it did before. In-process capture
without prefix supply still fails closed: the trajectory build finds `parent_digest_mismatch` and does not link
the call to its parent.

Each harness keeps its notes in a module of its own (`opencode.py`), as `HarnessNote` records with the
releases checked to send that exact text. To support another harness, add its module and its `NOTES` to
`HARNESS_NOTES`; the shared tests then cover its notes, and the harness's own tests check its default release.

## Submodules

* **[`nemo_gym.models.token_capture.harness_notes.base`](/nemo/gym/nemo-gym/nemo_gym/models/token_capture/harness_notes/base)**
* **[`nemo_gym.models.token_capture.harness_notes.opencode`](/nemo/gym/nemo-gym/nemo_gym/models/token_capture/harness_notes/opencode)**

## Package Contents

### Functions

| Name                                                                                          | Description                                                                           |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| [`_text_of`](#nemo_gym-models-token_capture-harness_notes-_text_of)                           | -                                                                                     |
| [`trailing_harness_note`](#nemo_gym-models-token_capture-harness_notes-trailing_harness_note) | Return the text of a final assistant message that is a known harness note, else None. |

### Data

[`HARNESS_NOTES`](#nemo_gym-models-token_capture-harness_notes-HARNESS_NOTES)

[`_NOTE_TEXTS`](#nemo_gym-models-token_capture-harness_notes-_NOTE_TEXTS)

### API

```python
nemo_gym.models.token_capture.harness_notes._text_of(
    content: typing.Any
) -> str | None
```

```python
nemo_gym.models.token_capture.harness_notes.trailing_harness_note(
    messages: list[typing.Any]
) -> str | None
```

Return the text of a final assistant message that is a known harness note, else None.

The message must carry only the note: no tool calls, no reasoning and no other content.

```python
nemo_gym.models.token_capture.harness_notes.HARNESS_NOTES: tuple[HarnessNote, ...] = (*(opencode.NOTES),)
```

```python
nemo_gym.models.token_capture.harness_notes._NOTE_TEXTS = frozenset((note.text) for note in HARNESS_NOTES)
```