Repository navigation
fix(verifiers_agent): correlate the prefixed Responses route too - #3361
Merged
cmunley1 merged 1 commit intoSep 14, 2026
Conversation
Addresses the P2 review comment on #3321. `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, and agents get no `RolloutContextMiddleware` -- that is installed on resources servers (`base_resources_server.py`), not on agents, which register explicit prefixed routes -- so the contextvar is unset there. A call on that route therefore built an unprefixed client and lost capture, which is the same silent failure #3321 set out to fix, just on the other entry point. `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` so a run with capture off keeps the shared unprefixed client. Tested at the route level rather than by patching `rollout_id_from_run`: the tests POST through the real FastAPI app so the path parameter is populated by the actual protocol. The prefixed-route test fails without this change with `'http://policy/v1' != 'http://policy/ng-rollout/7-2/v1'`. The unprefixed route and the capture-disabled case are covered as negative controls. Note: `test_policy_client_never_replays_the_session_cookie` and `test_a_default_openai_client_would_replay_the_session_cookie` fail in my sandbox on the unmodified branch head as well -- they appear to need network egress the sandbox denies, and are unrelated to this change. Signed-off-by: Wojciech Prazuch <[email protected]>
cmunley1
merged commit Sep 14, 2026
d338c28
into
wprazuch/verifiers-agent-capture-prefix
10 checks passed
cmunley1
deleted the
wprazuch/verifiers-agent-capture-responses-route
branch
September 14, 2026 18:33
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_runonly covers/run, where rollout collection injects_ng_rollout_idinto the request body. The supported/ng-rollout/<id>/v1/responsesroute carries the id in the path instead.There is no
RolloutContextMiddlewareon 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. Socurrent_rollout_id()isNoneon 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
responsesalready receives theRequest, so resolve the id from the run body first and fall back torequest.path_params. Gated on the same_capture_correlation_enabledas 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 syntheticbody.rollout_idand 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_prefixed_route_correlates_the_model_client/ng-rollout/7-2/v1/responses→http://policy/ng-rollout/7-2/v1test_unprefixed_route_stays_unprefixed/v1/responses→http://policy/v1test_prefixed_route_is_inert_when_capture_is_disabledThe 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_cookieandtest_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.