Skip to content

fix(verifiers_agent): carry the rollout capture prefix on the model client - #3321

Merged
cmunley1 merged 6 commits into
mainfrom
wprazuch/verifiers-agent-capture-prefix
Sep 14, 2026
Merged

cmunley1 merged 6 commits into
mainfrom
wprazuch/verifiers-agent-capture-prefix

Conversation

@wprazuch

Copy link
Copy Markdown
Contributor

Model-call capture is keyed by the /ng-rollout/<id> URL prefix
(nemo_gym/base_responses_api_model.py, _CaptureMiddleware). But
verifiers_agent/app.py:_get_client built its base URL straight from the model
server's host and port:

model_server_url = f"http://{server_config_dict.host}:{server_config_dict.port}"

so no model call was ever attributed to a rollout. Downstream: capture store
empty → trajectory carries model_call_capture_no_records and
model_calls_unavailable → every rollout-health check degrades to
unobserved
.

The client cache was also keyed by model-server name alone, so even with the
prefix applied the first rollout's client would have been reused for every
later rollout.

Why this is worth fixing rather than tolerating

An unobserved verdict is quiet. The run still prints a score, failure_reason
stays null, and rollouts_failures.jsonl stays empty (0 bytes). A
systematically broken run is then indistinguishable from a healthy low-scoring
one — and the checks that go dark are precisely the ones that would catch it:
agent_turn_hollow, model_call_zero_completion_tokens, model_call_failed,
model_call_runaway_generation.

Fix

Resolve through the base class's resolve_model_base_url(name, rollout_id),
which applies the prefix, and key the cache by (model server, rollout id).
rollout_id_from_run returns None when capture is disabled, which collapses
this back to the previous unprefixed URL and a single cache entry — so the
no-observability path is unchanged.

Verification

Real gym eval run --benchmark automationbench --model-type vllm_model against
a remote OpenAI-compatible endpoint, with observability_enabled=true:

before after
capture files written 0 1 per rollout
trajectory model_calls 0 2
reported tokens (prompt/completion) 0 / 0 3153 / 966
trajectory gaps model_call_capture_no_records, model_calls_unavailable, turns_unavailable, conversation_unavailable turns_unavailable, conversation_unavailable

Two regression tests added; both fail on main and pass with the fix.
pre-commit clean.

Scope — this is half the fix

Turn-level checks (AGENT_TURNS, and BOUND_CALLS via
_canonical_model_call_references) stay unobserved until the agent also emits
ng_agent_observations with an AgentInvocation carrying conversation and
model_calls: list[ModelCallRef]. The conversation is already reconstructed in
_convert_trajectory_to_output, but correlating verifiers' internal completions
back to captured model_call_ids needs design input. Proposed as a follow-up
rather than bolted on here.

Open question for reviewers

observability_enabled defaults to False, and no EFB gym recipe sets it
(grep -rn observability_enabled configs/ reviewed_configs/ → nothing). So
every gym benchmark on the EFB path currently runs health-blind, not just this
one. Should the harness warn when health checking runs with observability off,
instead of reporting 0 healthy, 0 unhealthy, N unobserved as if it were a
pass? Happy to open that separately.

…lient

Model-call capture is keyed by the `/ng-rollout/<id>` URL prefix, but
`_get_client` built its base URL straight from the model server's host and
port, so no call was ever attributed to a rollout. The capture store stayed
empty, the projected trajectory came back with `model_call_capture_no_records`
and `model_calls_unavailable`, and every rollout-health check degraded to
`unobserved`.

That matters because an unobserved verdict is not loud: the run still prints a
score, `failure_reason` stays null and `rollouts_failures.jsonl` stays empty. A
systematically broken run is then indistinguishable from a healthy low-scoring
one, and the checks that would have caught it -- `agent_turn_hollow`,
`model_call_zero_completion_tokens`, `model_call_failed`,
`model_call_runaway_generation` -- are exactly the ones that go dark.

Resolve the base URL through `resolve_model_base_url`, which applies the
prefix, and key the client cache by (model server, rollout id) so one rollout's
prefix is not pinned onto every later rollout. `rollout_id_from_run` returns
None when capture is disabled, which collapses this back to the previous
unprefixed URL and a single cache entry.

Measured on a real `gym eval run` against a remote endpoint: capture files
written per rollout go from 0 to 1, trajectory `model_calls` from 0 to 2, and
reported tokens from 0/0 to 3153 prompt / 966 completion.

This is the first half. Turn-level checks stay unobserved until the agent also
emits `ng_agent_observations`; that needs a conversation/model-call projection
out of the verifiers trajectory and is left to a follow-up.

Signed-off-by: Wojciech Prazuch <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@yaoyu-33 yaoyu-33 added area:agent Agent harnesses and Responses API agent behavior bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer labels Sep 11, 2026
… capture path

The matrix row was all `X`, which is correct for the broken path but stale once
model calls are correlated again. With the capture prefix applied, the
environment's own calls route through the Gym Model Server and are captured, so
C1 (per-call token statistics and response metadata), C2 (token counts) and C4
(model-visible history reconstructable from the rollout JSONL) hold on that
path.

Measured on a real `gym eval run` against a remote endpoint: 4 captured calls
with per-call request and response payloads, 3153 prompt / 966 completion
tokens, and 4 model calls projected into `ng_trajectory`.

C3, C5 and C6 stay `X`: the agent emits no `ng_agent_observations`, so there
are no turns and no tool attempt status or timing, and the rollout-health
checks that read agent turns or bound calls remain unobserved. C7 is left
unchanged because this PR does not affect it.

Signed-off-by: Wojciech Prazuch <[email protected]>
@wprazuch

wprazuch commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Added the capability-matrix row for verifiers_agent (dbcd6be51), since it goes stale the moment this merges.

X | X | X | X | X | X | X → V | V | X | V | X | X | X

C1/C2/C4 are the capture-derived criteria this PR restores — measured on a real gym eval run: 4 captured calls with per-call request/response payloads, 3153 prompt / 966 completion tokens, 4 model calls projected into ng_trajectory. C3/C5/C6 stay X because the agent emits no ng_agent_observations. C7 left unchanged as this PR does not affect it.

Two things I would value a review on from whoever owns the matrix:

  1. Is that grading right? I am self-assessing against criteria I did not define, which is exactly the situation where I would rather be corrected than assumed correct.
  2. Reaching parity with the opencode_agent row needs C5/C6, which for OpenCode come from parsing its session DB in _parse_opencode_session. verifiers has no equivalent store, but the agent does already reconstruct the conversation in _convert_trajectory_to_output. Is emitting an AgentInvocation plus ToolCallObservation records from that the shape you would want, and is there an intended route for an agent to reference captured calls when it cannot enumerate model_call_ids?

That second one is what currently keeps all eight turn- and call-level health checks unobserved for this benchmark, so it is worth getting right rather than fast.

@github-actions

Copy link
Copy Markdown
Contributor

@wprazuch

Copy link
Copy Markdown
Contributor Author

Correcting something I wrote above: I said reaching opencode_agent parity needs C5/C6 and that this benchmark would stay behind until then. That was wrong, and the correction matters, so recording it here rather than quietly editing.

turns in ng_trajectory come only from a producer-supplied trajectory on the rollout result (rollout_collection.py:_build_trajectory_record). ng_agent_observations contributes invocations, tool calls and model calls — but never turns. And if not turns: gaps.append(ObservationGap(code="turns_unavailable")) is unconditional.

Two consequences:

  • turns_observed is False, so both AGENT_TURNS checks are unobserved.
  • _canonical_model_call_references reads trajectory["turns"][*]["model_calls"], so with no turns there are no references, bindings.matched_calls is empty, and all six BOUND_CALLS checks are unobserved too.

Grepping for TrajectoryRecord( across responses_api_agents/: 2 of 47 agents emit one — simple_agent and simple_agent_with_compaction. Those two are also the only ones populating model_calls= on their turns. opencode_agent and opencode_sandboxed_agent emit an AgentObservationBundle (invocations + tool observations) but no TrajectoryRecord.

So OpenCode rollouts should also return unobserved for all eight turn- and call-level checks, and the same holds for tau2, stirrup, claude_code, hermes and the rest of the agentic fleet. tests/unit_tests/test_rollout_health.py agrees: its healthy fixtures all construct turns carrying model_calls refs.

Which means this PR alone brings verifiers_agent to the same health posture as the SWE-bench agent path — the gap I described is not specific to this benchmark. An AgentInvocation + ToolCallObservation follow-up would put it ahead of OpenCode on C5/C6, but it is not needed for parity.

Stated as falsifiable: this is a code-path argument plus the test fixtures, not an observed OpenCode run. If anyone has an OpenCode quality_summary.json showing non-unobserved verdicts, I have this wrong and would like to see it.

The open question is therefore broader than I first framed it: is unobserved the intended steady state for 45 of 47 agents, or should turn emission move into the harness so agent observations alone are enough to certify a rollout?

client_cache: dict[str, NeMoRLChatCompletionsClient] = Field(default_factory=dict)
# Keyed by (model-server name, rollout id): the rollout id selects the
# capture prefix baked into the client's base_url.
client_cache: dict[tuple[str, Optional[str]], NeMoRLChatCompletionsClient] = Field(default_factory=dict)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Avoid retaining one HTTP client per rollout

This cache is now keyed by a rollout ID that is effectively unique for every attempt, so a persistent agent process accumulates one NeMoRLChatCompletionsClient and one underlying AsyncOpenAI transport/connection pool per rollout. Nothing evicts or closes these clients. Large or repeated evaluations can therefore grow memory, sockets, and connection pools without bound; this also amplifies the httpx high-concurrency issue called out in the repository guidance. Please keep one shared transport and create only a lightweight per-run client/view with the prefixed base_url, or scope each per-run client to run_group() and close it in finally, rather than caching clients indefinitely by rollout ID.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct, thanks for fixing that!

them. ``rollout_id_from_run`` returns ``None`` when capture is disabled,
which collapses this back to the unprefixed URL and a single cache entry.
"""
rollout_id = self.rollout_id_from_run(body) if body is not None else None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Recover correlation from the prefixed Responses route too

rollout_id_from_run(body) covers /run because rollout collection injects _ng_rollout_id into that request body. It does not cover a direct /ng-rollout/{rollout_id}/v1/responses call, where the correlation ID lives in request.path_params and is not normally present in the body. That supported prefixed route will still construct an unprefixed model client and lose capture. Please resolve the ID from the request path/current rollout context as well as the run body (and pass the resolved ID into _get_client). A route-level regression test would catch this; the new unit test currently patches rollout_id_from_run to read a synthetic body.rollout_id, so it does not exercise the real protocol.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an implementation here: #3361, let me know if this implements what you described.

@d-molinari

Copy link
Copy Markdown
Contributor

Beside the unbounded growth of the cache, there's also a functional issue. I previously attempted to use one client per rollout and ran into the following issue:

  • one AsyncOpenAI → one httpx.AsyncClient → one connection pool per rollout
  • that pool's connection sits idle for the whole tool phase between turns
  • the router's uvicorn closes idle connections at timeout_keep_alive=30 (nemo_gym/server_utils.py:1066)
  • the next turn races the close → APIConnectionError -> ReadError(BrokenResourceError)

The proposed solution is similar to @yaoyu-33 suggestion:

Something along the lines of:

def _get_client(self, body=None) -> NeMoRLChatCompletionsClient:
    shared = self._shared_openai_client()          # built once, DefaultAsyncHttpxClient(cookies=_NoStoreCookieJar())
    rollout_id = self.rollout_id_from_run(body) if body is not None else None
    if rollout_id is None:
        return NeMoRLChatCompletionsClient(shared)
    prefixed = shared.with_options(base_url=self.resolve_model_base_url(self.config.model_server.name, rollout_id))
    return NeMoRLChatCompletionsClient(prefixed)   # no cache needed; no pool, no jar, no sockets of its own

with caveat that the NeMoRLChatCompletionsClient should never call .close() because that stops the http client

@d-molinari
d-molinari self-requested a review September 11, 2026 20:08
@yaoyu-33 yaoyu-33 added waiting-on-customer Waiting on the original author to respond and removed needs-review PR is ready for code review and waiting on a reviewer labels Sep 11, 2026
The per-run copy shares the cached client's httpx transport, so closing it
closes the pool every later rollout is still using. `Client.close()` does
`await self.client.close()`, and the wrapper looks disposable, which is exactly
the shape of mistake that lands in a `finally`.

Nothing on the current path closes it -- not this agent, not
`run_group`/`generate` on the verifiers legacy API, and every `.close()` call
site in verifiers sits under `verifiers/v1/`, which this agent does not use.
The rule is written into the docstring rather than enforced by a test on
purpose: I could not build one I can prove catches the regression. With the
copy deliberately replaced by a fresh `AsyncOpenAI`, the per-run client still
reports the shared `_client` and the `_NoStoreCookieJar`, while the same two
discriminators do separate borrowed from fresh on bare openai objects. Until
that is understood, a green test here would assert nothing -- and note the same
doubt applies to the existing `second.client._client is first.client._client`
assertion.

Signed-off-by: Wojciech Prazuch <[email protected]>
@wprazuch

Copy link
Copy Markdown
Contributor Author

@d-molinari I have not seen such a scenario in my runs, so probably your case is something else, which this PR does not cover.

On your .close() caveat - I went looking: OpenAIChatCompletionsClient.close() does await self.client.close(), and since .copy() shares _client, a single close() on any per-run wrapper would take the shared pool down for every rollout after it.

wprazuch and others added 2 commits September 14, 2026 11:33
Addresses the **P2** review comment on #3321. Targets that branch rather
than `main`, so the diff here is only the route fix and it lands
together with the prefix work.

## The gap

`rollout_id_from_run` only covers `/run`, where rollout collection
injects `_ng_rollout_id` into the request body. The supported
`/ng-rollout/<id>/v1/responses` route carries the id in the **path**
instead.

There is no `RolloutContextMiddleware` on agents to recover it either —
that is installed on resources servers (`base_resources_server.py:152`);
agents register explicit prefixed routes
(`base_responses_api_agent.py:81`) and nothing sets the contextvar on
them. So `current_rollout_id()` is `None` on that route.

A call on the prefixed Responses route therefore built an **unprefixed**
client and lost capture — the same silent failure #3321 set out to fix,
on the other entry point.

## The fix

`responses` already receives the `Request`, so resolve the id from the
run body first and fall back to `request.path_params`. Gated on the same
`_capture_correlation_enabled` as the body path, so a run with capture
off keeps the shared unprefixed client and nothing changes for it.

## Tests

Driven through the **real FastAPI routes**, not by patching
`rollout_id_from_run` — the earlier unit test read a synthetic
`body.rollout_id` and so never exercised the protocol, which was the
second half of the P2 comment. These POST through the app so the path
parameter is populated the way the server populates it.

| test | asserts |
|---|---|
| `test_prefixed_route_correlates_the_model_client` |
`/ng-rollout/7-2/v1/responses` → `http://policy/ng-rollout/7-2/v1` |
| `test_unprefixed_route_stays_unprefixed` | `/v1/responses` →
`http://policy/v1` |
| `test_prefixed_route_is_inert_when_capture_is_disabled` | capture off
→ shared unprefixed client |

The first fails without this change with `'http://policy/v1' !=
'http://policy/ng-rollout/7-2/v1'`. The other two are negative controls
and pass either way by design.

## One thing to be aware of

`test_policy_client_never_replays_the_session_cookie` and
`test_a_default_openai_client_would_replay_the_session_cookie` (from
#3316) fail in my sandbox — but they fail on the **unmodified branch
head** too, so they are not caused by this change. They look like they
need network egress my sandbox denies. Worth a second pair of eyes in a
normal environment.

Signed-off-by: Wojciech Prazuch <[email protected]>
@cmunley1

Copy link
Copy Markdown
Contributor

/ok to test 52a3dff

@cmunley1
cmunley1 merged commit d0f1295 into main Sep 14, 2026
32 checks passed
@cmunley1
cmunley1 deleted the wprazuch/verifiers-agent-capture-prefix branch September 14, 2026 18:43
pull Bot pushed a commit to Stars1233/Gym that referenced this pull request Sep 15, 2026
…l URL (NVIDIA-NeMo#3397)

<!-- Thanks for contributing to NeMo Gym! Please fill out the sections
below. -->

## What does this PR do?

<!-- Briefly describe the change and the motivation. Link any related
issue, e.g. "Closes #123". -->

Passes `token_capture=self._token_id_capture_enabled()` where
`anyterminal_agent` builds the model URL for the task container, so
training-token capture records the rollout. Same class of silent failure
as `verifiers_agent` in NVIDIA-NeMo#3321.

Training-token capture is keyed by the
`/ng-rollout/<id>/training-token-capture` URL prefix that an agent hands
its model client, see `rollout_path_prefix` in
`nemo_gym/server_utils.py` and its callers in
`nemo_gym/base_responses_api_agent.py`.
`anyterminal_agent/app.py:_setup_params` builds the model URL for the
task container without it:

```python
server_config["model_server_url"] = apply_rollout_prefix(server_config["model_server_url"], rollout_id)
```

`apply_rollout_prefix` in `nemo_gym/server_utils.py` takes a
keyword-only `token_capture` that defaults to `False`, so the container
gets the evaluation prefix `/ng-rollout/<id>` and the model server
records no training tokens for the rollout.

With `token_id_capture.enabled: true` and `token_id_capture: true` on
the agent, the configuration validates and the run completes normally.
Every rollout comes back with `_ng_token_capture.n_calls == 0` and
`mask_sample: true`. No error, no warning. A run that captured nothing
looks like a healthy one until the trainer masks every sample.

The base class passes the keyword in `url_path_for_run`,
`base_url_for_run`, and `resolve_model_base_url`, and
`claude_code_agent` and `swe_agents` pass it since NVIDIA-NeMo#2124. The
anyterminal wrapper builds its URL on its own path, and that path did
not get the keyword.

With capture off, `_token_id_capture_enabled()` is `False` and the URL
is unchanged, so evaluation runs do not move.

## Tests

Two tests in `TestSetupParams`. They call `_setup_params` with a real
global config dict instead of patching the capture protocol.

| test | asserts |
|---|---|
| `test_model_server_url_carries_the_training_capture_prefix` | capture
on gives `http://policy:8000/ng-rollout/7-2/training-token-capture` |
| `test_model_server_url_keeps_the_plain_rollout_prefix_without_capture`
| capture off gives `http://policy:8000/ng-rollout/7-2` |

The first fails on `main` with `'http://policy:8000/ng-rollout/7-2' !=
'.../training-token-capture'`. The second is a negative control.

```
pytest responses_api_agents/anyterminal_agent/tests/test_app.py
```

81 passed. `pre-commit run --all-files` clean.

### On real rollouts

`gym eval run` on three Terminal-Bench 2 tasks, Codex CLI 0.144.4
running inside the task container through `anyterminal_agent`, Qwen3-8B
served by vLLM on one GPU, `token_id_capture.enabled: true` with the
agent opted in. Both arms use the same overlay, the same task list, and
the same vLLM process. The only difference is this keyword. Gym is
`main` @ `5b34fcdac` in both arms.

| | without the keyword (`main`) | with the keyword |
|---|---|---|
| task containers handed a `/training-token-capture` prefix, per
`params.json` | 0 of 3 | 3 of 3 |
| rollouts with `_ng_token_capture.n_calls > 0` | 0 | 3 |
| rollouts with `mask_sample: true` | 3 of 3 | 0 of 3 |
| captured model calls | 0 | 147 |
| generation tokens delivered | 0 | 14,449 |
| `function_call` items Codex produced | 136 | 145 |

The last row shows Codex ran normally in both arms. The difference is
only in what the model server recorded. On the unfixed arm `gym eval
run` also prints `Rollout health: 3 checked, 0 healthy, 0 unhealthy, 3
unobserved`.

Both arms also carry local workarounds for NVIDIA-NeMo#3312 and NVIDIA-NeMo#3313, which Codex
needs to complete a turn against a chat-backed model server. They touch
the Responses converter and the streaming event, not the URL path.

## Checklist

- [x] I have read the [contributing
guidelines](https://docs.nvidia.com/nemo/gym/latest/contribute/development-setup).
- [x] The change is focused; unrelated "drive-by" edits are tracked as
separate issues/PRs.
- [x] Tests added or updated and pass locally, or N/A for docs-only /
non-code changes (so CI unit/server checks pass when applicable).
- [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so
CI lint/format/copyright pass).
- [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check
passes).

Signed-off-by: jiwasawa <[email protected]>
kajalj22 pushed a commit to kajalj22/Gym that referenced this pull request Oct 1, 2026
…VIDIA-NeMo#3403)

## What

A run of any `verifiers_agent` benchmark reports `0 healthy, 0
unhealthy, N unobserved`. 10 of the 13 rollout health checks have
nothing to read, so an infra outage and a model genuinely scoring zero
look identical in the run summary. This makes the agent emit the
evidence those checks need.

Measured on a 2-task `automationbench` run against a remote endpoint:

| | before | after |
|---|---|---|
| `Rollout health:` | `2 checked, 0 healthy, 0 unhealthy, 2 unobserved`
| `2 checked, 2 healthy, 0 unhealthy, 0 unobserved` |
| checks with no input | 10 | 0 |

Newly evaluated: `model_call_failed`,
`model_call_zero_completion_tokens`, `model_call_missing_token_counts`,
`model_call_runaway_generation`, `agent_turn_hollow`,
`rollout_missing_agent_turns`, `trajectory_capture_mismatch`,
`task_no_successful_model_calls`, `rollout_token_count_mismatch`,
`task_consistently_unhealthy`.

## Why it needed a different approach than `simple_agent`

Turns reach the checks only through a producer-supplied `ng_trajectory`
(`rollout_collection.py:_build_trajectory_record`) —
`ng_agent_observations` never supplies them. With no turns,
`_canonical_model_call_references` finds no references and the
bound-call checks go unobserved too. So the agent has to produce a
`TrajectoryRecord`, and only 2 of 47 agents currently do.

`simple_agent` builds its `ModelCallRef`s from `model_response.id`
because it issues the calls itself. Here `verifiers` owns the call loop
and hands back only a rollout summary, so the agent never sees a
response. The client is the one seam it does own: every call passes
through `get_native_response`, so `_ResponseIdRecordingClient` records
ids and accumulates usage there. No change is needed in `verifiers`.

The evidence rides on the response object rather than on `self`, because
rollouts run concurrently.

## Details worth a look

- **One turn per recorded response, each claiming only its own call.**
The checks read `turns[*].model_calls`; an invocation-level list binds
but leaves every per-call finding unattributable.
- **Turn answers are sliced per turn.** Handing every turn the whole
rollout's items makes each turn look non-hollow as long as any one turn
spoke, so `agent_turn_hollow` could never fire.
- **The `msg_empty` placeholder is not counted as a turn.**
`_convert_trajectory_to_output` appends it whenever no token ids came
back, which is every rollout served by a remote endpoint
(`vllm_model.yaml` sets `return_token_id_information: false`). Counting
it would dress the one case worth catching — a call that produced
nothing — as a turn that spoke.
- **A rollout whose calls all failed** records no ids and reports a
`model_call_reference_unavailable` gap rather than an empty trajectory.
- **`response.usage` was null for every verifiers rollout**; it now
carries the summed token totals.

## Testing

`gym eval run --benchmark automationbench --limit 2` against a remote
endpoint, observability on, before and after — the table above. Per-turn
output from the "after" run:

```
turn 1 answer: ['message', 'function_call'] step_count: 1 calls: ['chatcmpl-80ee9f79edc7954a']
turn 2 answer: ['message', 'function_call'] step_count: 1 calls: ['chatcmpl-bfa942bd8fe3aa2e']
verdict: healthy  unobserved: []  findings: []
```

6 unit tests in `tests/test_app.py`. Each was mutation-checked: the
corresponding invariant was broken in `app.py` and the test confirmed to
fail. One of them was vacuous on the first pass (it passed with the
invariant removed) and was rewritten against the case that actually
distinguishes.

`pre-commit run --all-files` clean;
`tests/unit_tests/test_rollout_{observability,health,collection}.py` 284
passed.

## Known gap this does not close

A negative control — same run with an invalid API key, so all 6 model
calls return `403 auth` — still reports `2 checked, 0 healthy, 0
unhealthy, 2 unobserved` and reward 0.0. The capture holds the evidence
(`status_code: 403`, `error_category: auth`), and the agent correctly
reports the `model_call_reference_unavailable` gap, but the gate cannot
use either:

- `model_call_failed` reads `OWNED_MODEL_CALLS`, and a failed call has
no `response_id`, so it can never bind. Catching it needs a check that
reads the capture rows directly rather than through bindings.
- `rollout_missing_agent_turns` reads `AGENT_TURNS`, and
`rollout_health.py:159` marks any `AGENT_TURNS` check unobserved when no
turns were observed — so the check meant to catch "this rollout has no
turns" is skipped exactly when there are none.

Both are in the health gate, not in this agent, so they are out of scope
here. Flagging for whoever owns `rollout_health` — happy to open a
separate PR if that is wanted. This matters in practice: a 600-task run
had 75 failed calls across 61 rollouts, 25 of which ended on error, and
every one was reported as an ordinary zero.

## Related

- NVIDIA-NeMo#3321 restored the `/ng-rollout/<id>` capture prefix in this agent
(capture files 0 → 1 per rollout).
- NVIDIA-NeMo#3361 extends that to the prefixed Responses route.

This PR is the next layer: capture now happens, and the trajectory that
binds to it exists.

---------

Signed-off-by: Wojciech Prazuch <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 52a3dff2 Deployed Sep 14, 2026 by copy-pr-bot[bot] via release / finalize / notify #2888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working waiting-on-customer Waiting on the original author to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants