Repository navigation
Conversation
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — auxiliary-only capture can silently substitute judge tokens for policy output; verifier ownership also regresses in the conversational simulator.
RISK — Required real-model smoke evidence is missing. The PR explicitly says rollout evidence has not run. These changes alter model URLs and capture membership in tau2, pinchbench, and the simulator integrations. Trusted AGENTS.md requires representative real model rollouts for behavior-changing environment/agent work; mocked URL assertions do not establish that actual clients retain the path or that finalization delivers the correct tokens.
Could you attach representative rollout commands/configurations and inspected artifacts before merge? Check both adapters with default selection and an auxiliary instance opted in: assistant calls should be tagged by default, auxiliary calls named but untagged by default, and opt-in capture separated without substituting auxiliary tokens into the scored policy response. Include an auxiliary-only selection regression for the BLOCKER below. Representative simulator/verifier evidence should show support-role names, no unintended training tags, and every observed verifier attempt/retry joined to its returned invocation ID. Retain valid agent/verifier completion and existing grading semantics; record reward, masking, ledger membership, and final token ownership rather than only HTTP success. This is a missing-evidence finding, not a claim that a rollout failed.
Completed source review of all 23 changed files and their directly affected routing, ownership, and capture-finalization contracts. Tests and model rollouts were not executed in this read-only review.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Inline comments (escaped v1):
-
nemo_gym/token_id_capture/groups.pyline 103: BLOCKER — Auxiliary-only capture can replace policy output with judge tokens. This PR introducestraining_agent_instances: [judge]. With capture enabled for pinchbench, its URL construction then leaves the assistant untagged and tags only the judge. This fallback promotes the sole captured instance,judge, to primary even though the episode's scored response still belongs to the assistant.For one clean captured judge ROOT, snapshot assembly passes the policy response into the judge build. When its IDs/content match no judge witness, the single-chain fallback nevertheless accepts that root unmasked. Finalization replaces
response.outputwith judge text/tokens while retaining the assistant's reward. Pinchbench's transcript converter produces no inline token IDs, so the redundant-capture guard does not prevent this. The blast radius is auxiliary-only capture configurations that use response rebuilding, not the default assistant selection.Correction: carry the actual episode-primary identity (
assistantfor these adapters) into the finalizer/consumer selection contract, throughtrajectories_from_sourceand_build_snapshot. If that primary was not captured, return no reconstructed primary response and a missing-primary/masked result, while keeping auxiliary builds available. Never infer the scored actor solely from capture membership. The precise representation of explicit primary identity needs choosing; there is no safe one-line deletion here. In particular, do not globally remove the sole-instance fallback, because a genuinely single named non-assistant primary may use it.Proposed acceptance checks, not executed: freeze one complete ROOT entry named
judge, with prompt[1], generation[2], log probability[-0.1], response IDresp_j1, and output textgrade. Finalize a token-free policy response with IDresp_policy, textpolicy answer, and a reward. It must not become an unmasked response containing judge generation[2]; the policy output/reward association must remain intact. Exercise pinchbench with[judge]selection to cover the adapter-to-finalizer path. Preserve the existing per-agent regressions: assistant+judge capture delivers only assistant tokens at top level, and a lost judge call does not mask the assistant. Also retain unnamed single-agent behavior and add a genuinely single named-primary case. -
resources_servers/conversational_tool_use_simulation/app.pyline 2143: RISK — Preserve the enclosing verifier identity when naming judge calls. With observability enabled, seed a conversation without the optionalrollout_id, then verify a completed trajectory through/ng-rollout/r/verify. The verifier boundary setsverify.<id>, but_call_judge_modelsuppliesjudgeand this block overwrites that context. ServerClient consequently sends/ng-rollout/r/ng-agent-instance/judge/v1/responses. The model middleware derives no verifier invocation ID, so the run loses its judge attempts and they cannot be excluded as verifier-owned calls. For this no-seeded-ID case, the base client previously carried the verifier header.Could
_call_modelpreserve an enclosing verify-kind identity and use that effective identity for both context and its explicit prefix? Insert before thewithblock:owner = current_agent_instance() if owner is not None and verifier_invocation_id_of(owner) is not None: agent_instance = owner
Add imports for
current_agent_instancefrom rollout correlation andverifier_invocation_id_offrom correlation. Keep both existing context/prefix uses of the resultingagent_instance. This is a source-traced suggestion, not executed code; verify it before adoption.Preserve: outside verification, explicit
user,tool_simulation, andjudgeroles must still win over an unrelated outerassistantcontext. Calls must remain untagged, and the outer context must be restored on success/failure. Inside verification, both seeded-ID prefixes and client-added prefixes must carry the same verifier owner across retries.Proposed acceptance: use an observed completed verification with
state.rollout_id=None, a realServerClient, and a stubbed transport returning valid judge evaluations. Assert every judge URL containsverify.<returned invocation_id>and captured attempts join that invocation. Repeat with a seeded rollout ID and a retryable failure followed by success. Retain the outside-verifier assertions for the explicittool_simulationprefix anduser/judgecontexts; add an unrelated outerassistantcontext to ensure those roles are not replaced. -
nemo_gym/rollout_correlation.pyline 136: NOTE — Suggestion: document the explicit-name limitation accurately. This docstring promises that agent URL helpers inherit context when no name is passed. However, base_url_for_run and resolve_model_base_url forward their defaultagent_instance=None, and apply_rollout_prefix does not read the context. Thus a helper called insideagent_instance_context("user")still builds an unnamed URL unless given the name explicitly. The PR describes this as an intentional current limitation, so clarify the documentation rather than changing precedence here.Replace the final docstring paragraph with:
``ServerClient`` puts the name in the model-server path when it adds the rollout prefix itself. Callers building their own prefix or model URL must pass ``agent_instance`` explicitly. ``None`` clears an enclosing name.
Preservation/acceptance: statically confirm the docstring no longer promises helper fallback. Retain the existing routing assertions: automatic model prefixes inherit context; resources calls and already-prefixed paths remain unchanged; explicitly named helpers encode the name. No runtime change is needed for this suggestion.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
There was a problem hiding this comment.
Hi Pranav, thanks for the work! Could you please include the remaining verifier identity cleanup in this stack, across this PR and #5255's reader migration. I would prefer that happens now rather than being postponed.
Replacing our x-ng-verifier-invocation-id header with agent_instance = "verify.<id>" is the direction we want. The current implementation still derives and persists verifier_invocation_id so our existing readers can remain unchanged. Let's migrate those readers here and use the general identity throughout, rather than retain two representations of the same ownership key.
Requested scope:
- Use
agent_instanceconsistently on model-call evidence and verifier invocation records, with ownership joins scoped bycapture_key. - Migrate verifier ownership joins,
exclude_verifier_model_calls, and our harness conformance checks to that identity; remove the redundantverifier_invocation_idfield and its dedicated plumbing from new writes. - Keep the verifier invocation records and their outcome/failure evidence, including verification runs that make zero model calls. This request replaces their identity representation, not their semantics.
- Check whether existing persisted results require compatibility on read. If needed, normalize legacy IDs at that boundary while keeping new writes on the single representation.
Acceptance coverage should preserve attribution of parallel calls and retries to the correct verifier run, separation between different verifier runs and policy calls, and outcome/failure evidence for zero-call runs.
This is a request to complete the consolidation within this stack; it does not require keeping our verifier-specific identity mechanism as a parallel implementation.
giuliolovisotto
left a comment
There was a problem hiding this comment.
Why is assigning verify.<id> gated on observability_enabled? Could /verify assign its identity whenever execution identity is propagated, including token capture with observability off, and gate only evidence collection on observability? That would keep verifier ownership independent of the recording setting.
a72850f to
efb0a0f
Compare
0054050 to
cbbbb5a
Compare
cbbbb5a to
4e827e2
Compare
4e827e2 to
2ea11d8
Compare
2ea11d8 to
144fa2e
Compare
144fa2e to
070bf0a
Compare
070bf0a to
dd2d821
Compare
| body: Any, | ||
| *, | ||
| agent_instance: Optional[str] = None, | ||
| token_capture: Optional[bool] = None, |
There was a problem hiding this comment.
This PR adds agent_instance and token_capture here and to resolve_model_base_url, but not to the third URL helper, url_path_for_run. A call built with it can't name its role or drop the training tag, so training_agent_instances never applies to it.
For example, conversational_tool_use_policy_tool_generation sends both its policy calls and its judge calls through url_path_for_run, so with capture on, its judge calls are always tagged.
|
Heads-up from #5562 (sampling values in multi-agent environments): Whichever of the two PRs lands second should make both read one selection; #5562 marks both spots with |
dd2d821 to
689be93
Compare
689be93 to
6cb78a1
Compare
6cb78a1 to
be05b83
Compare
Agent instances that call a model server directly now name themselves in the path (`/ng-agent-instance/<name>`): - rollout_path_prefix and apply_rollout_prefix take keyword-only `agent_instance`. agent_instance_context(name) (nemo_gym.core) names the calls inside a block; ServerClient puts that name in the path whenever it adds the rollout prefix itself. Resources-server calls are unchanged. - base_url_for_run and resolve_model_base_url take keyword-only `agent_instance` and `token_capture` (None keeps the agent's flag). - The training tag is chosen per agent instance by `token_id_capture.training_agent_instances` (default ["assistant"]), matched by name or agent kind; the unnamed agent keeps today's behavior. - call_judge takes `agent_instance`; precedence is the argument, then the context name, then `judge`. Verifier runs are the agent instance `verify.<invocation id>`: observe_verifier mints a uuid hex id and names every model call of the run, and the model server derives `verifier_invocation_id` from that name, so ng_verifier_invocations and exclude_verifier_model_calls are unchanged. The `x-ng-verifier-invocation-id` header is no longer sent (the constant stays importable); the path is the only carrier. Environments: tau2 names `assistant` and `user`; pinchbench `assistant` and `judge`; nemo_user_sim's support calls `judge`, `summary`, `tool_simulation`; conversational_tool_use_simulation `user`, `tool_simulation`, `judge`; proof_jury_judge's jurors `judge.<i>` outside a verifier run (inside one, the run's name stands so it owns every juror call). Only the assistant carries the training tag by default. Docs: external-agent-harnesses documents the URL grammar. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
…and update the tests the verifier name change left stale - capture: a lone captured agent instance other than assistant is no longer the primary, so a training selection without the assistant cannot deliver another agent instance's tokens as the scored response - tests: false_statement_judge, swebench_pro and miniswe_sandboxed_agent assert the verifier run's name and bare-hex id instead of the removed header and the verify- prefix - tests: cover URL helper naming, the training selection, verify-kind ids, moved judge names, and the simulator and pinchbench call sites Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: Pranav Thombre <[email protected]>
be05b83 to
8cad353
Compare
What changed and why
The URL grammar (PR 1), the recorded identity (PR 2) and per-group capture (PR 3) only help once callers name their agent instances. This PR covers agent instances that call a model server directly: judges, simulated users, tool simulators, and verifier runs. Agent instances that run as agent sessions are bound in PR 5.
Helpers
rollout_path_prefixandapply_rollout_prefixtake keyword-onlyagent_instance.agent_instance_context(name)inrollout_correlationnames the model calls inside a block.ServerClient.requestputs that name in the path whenever it adds the rollout prefix itself; resources-server calls are unchanged. A caller that builds its own prefix passesagent_instanceexplicitly (PR 7 lifts this rule).base_url_for_runandresolve_model_base_urltake keyword-onlyagent_instanceandtoken_capture(Nonekeeps the agent's own flag).training_tag_for(name)tells an agent whether a URL for that agent instance carries the training tag.call_judgetakesagent_instance. Precedence: the argument, then a name already set in context, thenjudge. This names all ~80call_judgecall sites without touching them.Per-agent-instance training tag (the design's decision 3).
token_id_capture.training_agent_instances, default["assistant"], lists the agent instances whose URLs carry/training-token-capture, by name (debater.1) or agent kind (debater). It combines with the agent's existingtoken_id_capture/all_agentsflags; the unnamed agent of a single-agent episode keeps today's behavior.Verifier runs are the agent instance
verify.<id>(replaces #4630's header).observe_verifiermints a uuid hex invocation id and names every model call of the runverify.<id>, throughcall_judge,ServerClientor the URL helpers. The model server derivesverifier_invocation_idfrom an agent instance of kindverify, so #4630's records,ng_verifier_invocationsandexclude_verifier_model_callskeep working unchanged.call_judgeandServerClientno longer sendx-ng-verifier-invocation-id, the model server no longer reads it, andVERIFIER_INVOCATION_HEADERis removed: the path is the only carrier of the run's identity (G1).Environments
responses_api_agents/tau2assistant(tagged as today) anduser(tag fromtraining_agent_instances, default off)responses_api_agents/pinchbenchassistantandjudge(judge default off)environment_servers/nemo_user_simjudge,summary,tool_simulation; never tagged. The user simulator and the assistant are agent sessions, named in PR 5.resources_servers/conversational_tool_use_simulationuser,tool_simulation,judge, in the prefix_call_modelbuilds and in context for calls without a rollout idresources_servers/proof_jury_judgejudge.<i>, outside a verifier run; inside one, the run'sverify.<id>stands, so the run still owns every juror callDocs:
external-agent-harnesses.mdxdocuments the URL grammar, the naming rule,training_agent_instancesand the helpers.How it works
Where this PR sits in the overall flow; the highlighted part is what this PR changes.
flowchart LR ENV["Environment server<br/>seeds and activates agent sessions"] AG["Agent server<br/>session bound to its agent instance"] RS["Resources server<br/>verify(), judges"] MS["Model server<br/>capture middleware"] CM["nemo_gym.correlation<br/>resolve / encode"] LG[("Capture ledger and token store<br/>rows carry agent_instance, model_ref")] DL["Delivery and manifest<br/>chains and outcomes per agent instance"] RR["Episode result<br/>agent_instances map"] ENV -->|"/ng-rollout/k/ng-agent-instance/user/v1/responses"| AG AG -->|"model calls named user"| MS RS -->|"verify.<id> and judge calls"| MS MS --> CM MS --> LG --> DL --> RR ENV --> RR classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937 class RS,CM thissequenceDiagram participant V as Resources server verify() participant J as call_judge / ServerClient participant M as Model server Note over V: observe_verifier mints id 3f2a..., enters agent_instance_context("verify.3f2a...") V->>J: two judge calls in parallel J->>M: POST /ng-rollout/k/ng-agent-instance/verify.3f2a.../v1/responses (x2, retries included) Note over M: records agent_instance verify.3f2a..., agent_kind verify,<br/>verifier_invocation_id 3f2a... (derived, no header) M-->>J: replies Note over V: ng_verifier_invocations joins the calls by id, as with #4630Where this sits in the stack
This is one PR in a stack of draft PRs that implements agent instance identity from the Gym capture identity design (draft 2): several agent instances (assistant, judge, simulated user, debaters) can call model servers in one episode, every record says which one made each call, capture computes lineage and outcomes per agent instance, and the trainer chooses which agent instances it trains on. Gym records; trainers select. Single-agent episodes do not change: an agent's own
/runnames no agent instance, and its records differ frommainonly by the newmodel_refcolumn.Each PR is one commit, and its base is the branch of the PR before it, so each diff shows only that PR's change.
pranav/agent-instance-00-capture-key-rename): refactor(capture): name capture keys capture_key on the ledger control surfacepranav/agent-instance-01-correlation-module): feat(core): add a correlation module that reads and builds the rollout pathpranav/agent-instance-02-record-identity): feat(model): record agent instance, agent kind and model server on every capture and model-call recordpranav/agent-instance-03-per-agent-capture): feat(capture): compute lineage, terminal chains and outcomes per agent instance and model serverpranav/agent-instance-04-direct-call-names): feat(core): let callers name an agent instance on model calls (this PR)pranav/agent-instance-05-agent-session-binding): feat(agent): bind agent sessions to an agent instance at seed timepranav/agent-instance-06-per-agent-results): feat(episode): report terminal calls and rewards per agent instancepranav/agent-instance-07-migrate-readers): refactor(core): read and build every rollout path through the correlation moduleThe first PR's base is
main@0b8783981. External dependencies: #5083 (session lifecycle names, open) for PR 5. #4969 (rollout prefix hooks for fixed-base-URL clients, open) needs one small change in whichever of #4969 and PRs 1 and 4 lands second:with_rollout_prefixdetects an existing prefix withresolveand takes the name fromagent_instance_context.The NeMo RL follow-up (selecting agent instances to train on, one
RolloutReceiptper selected agent instance, per-agent rewards) is separate; until NeMo RL bumps its Gym pin, none of these PRs affect NeMo RL training runs.Issue
No tracking issue exists; the work follows the Gym capture identity design (draft 2) and its implementation plan.
Validation
Tests ran on Slurm (one node,
rl-gym.nightlycontainer), each branch against a baseline worktree ofmain@0b8783981:python -m pytest -n 32 tests/unit_tests): 33 failed, 12,191 passed, 4 errors. Every one is environmental in this container (docker-compose, OpenSandbox compose, Harbor compose overlay, eval resubmit, reward profile, dataset orchestrator and sandbox supervisor tests, and four exporter modules that fail to import), and the same set fails on every branch of the stack. The docker-compose tests are flaky: one or two of them pass or fail from run to run.requirements.txtorpyproject.toml, asgym env testdoes.pre-commitcould not fetch its hook repositories from the build environment, soruff check --fix,ruff check --select I --fixandruff formatran with ruff 0.9.9 (the hook's pinned version) on every changed file. The guardwords and end-of-file hooks did not run here; CI runs them.Signed-off-byline.test_health_probe_timeout_retries_then_starts_dependent), which passes on the other branches of the stack.pyproject.tomldependencies).test_rollout_correlation.py:ServerClientwithagent_instance_contextnames a plain model path, leaves resources-server paths and already-prefixed paths unchanged, and adds neither a prefix nor a name with observability and checkpointing off; URL helpers with and without a name;agent_instance_contextrefuses an invalid name and restores the outer one.test_judge.py:call_judgenames its callsjudgeby default and the context name inside a block, on success and failure; an explicit name wins.test_verifier_observability.py,test_base_responses_api_model.py(fix(observability): retain explicit verifier invocations #4630's tests, moved to the path): one verify run owns its parallel judge calls and retries with no header; a directServerClientcall inside verify carriesverify.<id>in its URL and no header, and a policy call outside carries none; the model server recordsverifier_invocation_idfrom averify.<id>path.proof_jury_judge: jurors arejudge.0..judge.2outside a verifier run and unnamed (so the run's name stands) inside one.training_agent_instancestags them.Rollout evidence
Not yet run. Before this leaves draft: tau2 and pinchbench smoke rollouts with capture on and default configuration, checking that the capture ledger holds only the assistant's calls and that model-call records name
user/judge; and one with the user simulator opted in, checking that the ledger holds both under their own names. A judge-based resources server run with observability on, checkingng_verifier_invocations.Compatibility
x-ng-verifier-invocation-idis removed. Verifier runs are identified byverify.<id>in the path;verifier_invocation_idon model-call records andng_verifier_invocationsare unchanged. Verifier invocation ids are now a bare uuid hex instead ofverify-<hex>.usertotoken_id_capture.training_agent_instancesto keep capturing it./ng-agent-instance/<name>; a harness that parses model URLs itself must accept it./verifyassign<n>; hereobserve_verifier, a Gym component, mints it.🤖 Generated with Claude Code