Skip to content

feat(agent): bind agent sessions to an agent instance at seed time - #5253

Open
pthombre wants to merge 6 commits into
pranav/agent-instance-04-direct-call-namesfrom
pranav/agent-instance-05-agent-session-binding
Open

pthombre wants to merge 6 commits into
pranav/agent-instance-04-direct-call-namesfrom
pranav/agent-instance-05-agent-session-binding

Conversation

@pthombre

@pthombre pthombre commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Agent instances that run as agent sessions (nemo_user_sim's user simulator and assistant, SWE-Together's candidate and judge) are started by an environment server, which is the component that should name them (G3). This PR binds a session to its agent instance at seed time: the agent server checks the name on every activation, and the session's model calls carry it.

Seed

  • AgentSeedSessionRequest.agent_instance (optional), validated against the name grammar and omitted from the serialized seed when unset, as continuation is.
  • One open session per agent instance of an episode (G2). A seed whose episode and agent instance are already bound to another open session is refused with 409. The binding is session state, released when the session closes, so nothing outlives the episode (G9). require_distinct_agent_instances lets an environment server check its names before seeding.

Activation

  • Activation routes also accept /ng-rollout/{capture_key}/ng-agent-instance/{agent_instance}[/training-token-capture]/v1/responses.
  • Every /v1/responses route checks, through nemo_gym.correlation, that the path names the session's agent instance: a mismatch, a named path on an unnamed session, and an unnamed path on a named session are refused with 409. It is a FastAPI dependency on the base agent's routes, so every session agent gets it without per-agent code.
  • Session routing needs no change: seed and close routes are unprefixed, and activations route by cookie.
  • The restart-only checkpoint middleware reads the path through resolve.

Outbound model calls. While a named session seeds or activates, agent_instance_context is set, and url_path_for_request, base_url_for_run and resolve_model_base_url fall back to it, so the ~75 agents built on these helpers carry the name with no per-agent change. Setting it during the seed covers harnesses that receive their model URL when the session starts. An explicit name wins.

Environments

Component Change
environment_servers/nemo_user_sim Seeds assistant and user; responses_path builds named activation paths through rollout_path_prefix; the training tag follows training_agent_instances (default: the assistant only, as today).
environment_servers/swe_together The candidate agent is seeded and activated as assistant. The judge moves from its own <key>-judge episode onto the episode's capture key as judge (training tag default off), so the episode's checkpoint retire now covers it.

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.&lt;id&gt; and judge calls"| MS
  MS --> CM
  MS --> LG --> DL --> RR
  ENV --> RR
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  class ENV,AG this
Loading
sequenceDiagram
  participant E as Environment server
  participant A as Agent server
  participant M as Model server
  E->>A: POST /v1/agent_sessions {episode k, agent_instance "user"}
  Note over A: refuses 409 if k already has an open "user" session,<br/>seeds with agent_instance_context("user")
  E->>A: POST /ng-rollout/k/ng-agent-instance/user/v1/responses (session cookie)
  Note over A: path name == seeded name, else 409,<br/>runs the activation as "user"
  A->>M: model calls via base_url_for_run / url_path_for_request -> /ng-rollout/k/ng-agent-instance/user/...
  E->>A: POST /v1/agent_sessions/close
  Note over A: binding released, "user" can be seeded again
Loading

Where 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 /run names no agent instance, and its records differ from main only by the new model_ref column.

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.

  1. refactor(capture): name capture keys capture_key on the ledger control surface #5248 (pranav/agent-instance-00-capture-key-rename): refactor(capture): name capture keys capture_key on the ledger control surface
  2. feat(core): add a correlation module that reads and builds the rollout path #5249 (pranav/agent-instance-01-correlation-module): feat(core): add a correlation module that reads and builds the rollout path
  3. feat(model): record agent instance, agent kind and model server on every capture and model-call record #5250 (pranav/agent-instance-02-record-identity): feat(model): record agent instance, agent kind and model server on every capture and model-call record
  4. feat(capture): compute lineage, terminal chains and outcomes per agent instance and model server #5251 (pranav/agent-instance-03-per-agent-capture): feat(capture): compute lineage, terminal chains and outcomes per agent instance and model server
  5. feat(core): let callers name an agent instance on model calls #5252 (pranav/agent-instance-04-direct-call-names): feat(core): let callers name an agent instance on model calls
  6. feat(agent): bind agent sessions to an agent instance at seed time #5253 (pranav/agent-instance-05-agent-session-binding): feat(agent): bind agent sessions to an agent instance at seed time (this PR)
  7. feat(episode): report terminal calls and rewards per agent instance #5254 (pranav/agent-instance-06-per-agent-results): feat(episode): report terminal calls and rewards per agent instance
  8. refactor(core): read and build every rollout path through the correlation module #5255 (pranav/agent-instance-07-migrate-readers): refactor(core): read and build every rollout path through the correlation module

The 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_prefix detects an existing prefix with resolve and takes the name from agent_instance_context.

The NeMo RL follow-up (selecting agent instances to train on, one RolloutReceipt per 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.nightly container), each branch against a baseline worktree of main @ 0b8783981:

  • Baseline core suite (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.
  • Server-local suites ran in one venv per server built from its requirements.txt or pyproject.toml, as gym env test does.
  • pre-commit could not fetch its hook repositories from the build environment, so ruff check --fix, ruff check --select I --fix and ruff format ran 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.
  • Every commit carries a Signed-off-by line.
  • Core suite on this branch: 33 failed, 12,346 passed, 4 errors, the baseline set (one flaky docker-compose test swapped with another).
  • Server suites: SWE-Together 204 passed on this branch (baseline 202 plus the two new tests; a first run caught two stubs written for the old _activation_path signature, now updated); nemo_user_sim 36 passed on PR 7's branch, which contains this commit.
  • test_agent_session_instances.py (new), through the real agent app and session cookies:
    • an unnamed seed serializes as on main; a named one round-trips; an invalid name is refused;
    • a named session's activation runs as its agent instance, and its model URLs, including a URL built during the seed, carry the name; an explicit name wins;
    • a matching name and the training-tagged named path succeed; a mismatched name, a named path on an unnamed session, an unnamed path on a named session and an unprefixed path on a named session are refused with 409;
    • a second open session of the same episode and agent instance is refused with 409, a different agent instance is accepted, and after the first session closes the name can be seeded again;
    • an environment server refuses to seed a name twice.
  • nemo_user_sim: seeds carry user and assistant, and the assistant's activation path names it.
  • SWE-Together: the judge is seeded in the episode itself as judge, activated and closed under the episode's capture key; activation paths name assistant (tagged) and judge (tagged only when selected).

Rollout evidence

Not yet run. Before this leaves draft: nemo_user_sim and SWE-Together smoke rollouts with capture on, checking agent_instance and model_ref in the ledger and model-call records, that with default configuration only the assistant's calls are captured, and that SWE-Together's judge calls sit under the episode's capture key as judge (including a checkpoint restore and retire during the judge's activation).

Compatibility

  • SWE-Together judge records move from the <key>-judge capture key to the episode's key under the agent instance judge. Anything downstream that looks for the -judge suffix must change.
  • Activations of a named session must name it; environment servers in this repo that seed named sessions build those paths. Unnamed sessions behave as before.
  • Depends on refactor(sessions): one name per session lifecycle concept before release #5083 (refactor(sessions): one name per session lifecycle concept), which is still open. This PR is written against the session code on main and refuses conflicts with HTTPException(409); once refactor(sessions): one name per session lifecycle concept before release #5083 merges it is rebased onto AgentSessionConflictError and the code that PR renames. It stays a draft until then.

🤖 Generated with Claude Code

@pthombre pthombre added feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers area:agent Agent harnesses and Responses API agent behavior blocked Work cannot move forward until an external dependency is cleared complexity:medium Single-domain change with interacting parts or a moderate review surface labels Oct 29, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 29, 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.

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

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.

HOLD — 1 BLOCKER, 5 RISKs and 1 NOTE.

The three-topic static review covered all changed files and their directly affected session, capture, checkpoint and environment contracts. The principal failure is that the default SWE-Together Claude Code judge still emits unnamed model calls after moving into the episode's capture key. Additional findings concern instance-specific training tags and uniqueness across lifecycle transitions and workers.

RISK — Provide representative real-model smoke evidence

The PR explicitly says the smoke rollouts have not run. Trusted repository guidance requires representative real-model rollouts for behavior-changing environment or agent work; mocked session/path tests do not establish end-to-end capture and cleanup correctness.

Could you attach commands, configuration, tested revision and inspected artifacts for one representative rollout of each environment? Acceptance should demonstrate:

  • UserSim records identify user and assistant; SWE-Together records identify assistant and judge, with the judge under the episode capture key rather than <key>-judge.
  • Model-call records retain the correct model_ref; default training-token capture includes only the assistant.
  • UserSim still verifies its result and closes both participant sessions. SWE-Together closes the judge before reading its verdict, preserves a valid verdict despite a lost response, and distinguishes an unmeasured judge failure from a measured zero.
  • The planned checkpoint/retire exercise during judge work stops that episode's judge execution and releases its session.

This is a request for representative smoke evidence, not a new full reward baseline. No tests or rollouts were executed during this read-only review. Suggested patches and acceptance checks below are source-reasoned proposals and must be verified before adoption.

Note: formal approval is not available for this request, so this review is posted as a comment only.


Inline comments (escaped v1):

  • responses_api_agents/claude_code_agent/app.py line 191: BLOCKER — Carry the judge identity through Claude Code's model URL.

    The default SWE-Together recipe uses this adapter. This PR now seeds it as judge in the episode itself, but _sandbox_response calls this resolver, which bypasses all three changed base-agent URL helpers. It still builds .../ng-rollout/r, not .../ng-rollout/r/ng-agent-instance/judge. The model middleware derives identity solely from that URL, so successful judge calls are silently recorded with agent_instance=None, not judge. Moving off the separate r-judge key makes this an attribution regression on the supplied recipe.

    Could you update _resolve_call_base_url? Add the current_agent_instance import from nemo_gym.rollout_correlation, then replace its configured-Gym-model branch with:

    if base_url and self.config.model_server:
        agent_instance = current_agent_instance()
        base_url = apply_rollout_prefix(
            base_url,
            rollout_id,
            token_capture=self.training_tag_for(agent_instance),
            agent_instance=agent_instance,
        )

    This restores both identity and the named-instance training-selection contract for this independent resolver.

    Preserve: direct external Anthropic URLs must remain untouched; unnamed legacy calls must retain their current rollout/training prefixes; trace propagation and judge output/cleanup semantics must not change.

    Proposed checks, not run: activate a named judge session against a capture-enabled stub model and assert the staged ANTHROPIC_BASE_URL names judge and the resulting model-call record does too. With capture enabled, assert default judge untagged, explicitly selected judge tagged, and unnamed opted-in calls still tagged. Retain the concrete external-URL and unnamed-prefix assertions in TestRolloutCorrelation.

  • nemo_gym/base_responses_api_agent.py line 1138: RISK — Apply instance selection when these helpers choose the training tag.

    resolve_model_base_url and base_url_for_run now inherit a session's name, but their default token_capture still uses only _token_id_capture_enabled(). For capture enabled with all_agents: true, a directory, and default training_agent_instances: [assistant], calling either helper in agent_instance_context("user") produces a named training-tagged User URL. The expected URL is named but untagged. Real harness callers such as OpenCode's session activation rebuild their model URL this way, so an untagged environment activation does not enforce the selected-instance policy.

    Could you make the following change in both base_url_for_run and resolve_model_base_url? Resolve the effective name before apply_rollout_prefix:

    agent_instance = agent_instance if agent_instance is not None else current_agent_instance()

    and pass:

    token_capture=self.training_tag_for(agent_instance) if token_capture is None else token_capture,
    agent_instance=agent_instance,

    Update their token_capture=None documentation accordingly. The invariant is that implicit URL tags require both agent capture enablement and selection of the effective instance.

    Preserve: an explicit name still overrides context; explicit token_capture=True/False still overrides the default; unnamed agents retain their previous opt-in behavior; no rollout ID still means no rollout/name prefix. Do not replace url_path_for_request's inbound-tag preservation with this default-selection rule.

    Proposed checks, not run: exercise both helpers during named seed and activation with default selection: assistant tagged, user/judge untagged. Select user and assert it becomes tagged; test an indexed kind selection such as debater.1; assert explicit tag overrides and explicit-name precedence. Retain the unnamed model-endpoint assertion and acceptance of an explicitly tagged named activation.

  • nemo_gym/base_responses_api_agent.py line 720: RISK — Keep the instance reserved until close actually completes.

    This exclusion releases the name as soon as _close_session_state sets record.closing=True, before it awaits activation termination and harness cleanup. Reproduce by seeding s1 as (episode r, assistant), blocking its close hook, and seeding s2 with the same episode/name while close waits: s2 succeeds. The original harness can still be running; a failed close also leaves its resources retained while permitting the replacement. That violates the stated release-on-close binding and can interleave calls from two sessions under one identity. See the close transition.

    Could you remove only the closing exemption, leaving the predicate as:

    if (
        session_id != body.agent_session_id
        and record.close_response is None
        and record.episode_id == body.episode_id
        and record.agent_instance == body.agent_instance
    ):
        return session_id

    A closing or partially initialized session must retain its reservation until successful close or confirmed release removes its state; it must remain unavailable for activation as today.

    Proposed checks, not run: while an event blocks s1 cleanup, a fresh-cookie s2 seed of the same episode/name must return 409. Repeat after cleanup raises, then retry close successfully and assert s2 succeeds. Also retain rejection during seed setup, acceptance of different names/episodes and multiple unnamed sessions, identical-seed replay, and the current post-close reuse assertion. Preserve the failed-close state retention exercised by the existing retry test.

  • nemo_gym/base_responses_api_agent.py line 916: RISK — Restore the record's instance binding along with its session state.

    The new conflict check reads record.agent_instance, but this restore constructor leaves it at None even when state.request.agent_instance is named. SimpleAgent's restore preserves the name in the request and installs it here. After restoring s1 as assistant into attempt r-a1, a fresh seed s2 for the same attempt/name therefore succeeds. Both sessions can activate as assistant, although a normally seeded record would reject s2.

    Could you replace the assignment with:

    self._session_records[agent_session_id] = _AgentSessionRecord(
        state=state,
        episode_id=state.request.episode_id,
        agent_instance=state.request.agent_instance,
    )

    The invariant is that restored and normally seeded records expose the same episode/name reservation.

    Proposed regression, not run: export a named SimpleAgent session, install it into a replacement attempt, resume admission, then POST a different session ID with the restored episode/name and expect 409. Activate the restored session with its cookie and matching named replacement path and expect its saved reply or continuation, not a new unrelated session. Close it and verify that a fresh session can then reuse the name.

    Preserve: unnamed restore behavior, acceptance of another instance in the same attempt, and attempt rewriting. In particular, retain the existing restored-session assertions that stale/unprefixed requests execute no model call and that the replacement attempt can replay or continue.

  • nemo_gym/base_responses_api_agent.py line 716: RISK — The uniqueness check is worker-local on a multi-worker agent server.

    _session_records is process-local. With num_workers=2, seed s1 as (r, assistant) on worker A, then seed a different ID s2 with the same episode/name on worker B: both scans see no conflict and both seeds succeed. Existing session routing claims/routes by session ID, so it intentionally does not bring these distinct IDs to the same worker. Multi-worker agents are a supported configuration. The advertised episode/name uniqueness contract therefore disappears when the server scales beyond one worker.

    Could you enforce an atomic server-wide reservation for (episode capture_key, agent_instance) before setup, coordinated through the existing server-runtime/session-claim ownership mechanism? Release it only after confirmed close/release, restore it for restored sessions, and release a rejected seed's unused reservation. If that ownership work is deferred, explicitly reject named sessions with multiple workers rather than claiming to enforce uniqueness there. The exact shared-claim implementation needs an ownership decision, so a process-local lock or speculative patch would not be a complete fix.

    Preserve: routing of identical session-ID retries to their owner, close-retry receipts, independent instances/episodes, unnamed sessions, and cleanup/claim release after failed setup. Do not route every episode to a single worker merely to hide this conflict.

    Proposed acceptance, not run: extend the existing two-worker AgentWorker fixture. Send distinct IDs with one named identity to different workers, sequentially and concurrently: exactly one seed must succeed, or named multi-worker operation must be explicitly refused. Different names and episodes must still succeed; successful close must allow reuse from the other worker. Retain the existing owner-routing checks.

  • resources_servers/nemo_user_sim/README.md line 47: NOTE — Update the User capture eligibility contract.

    This paragraph still says only Assistant calls are eligible for training-token capture. The changed activation-path builder now permits User capture when training_agent_instances selects user. For example, capture enabled with all_agents: true and training_agent_instances: [assistant, user] produces a tagged User activation. The documentation incorrectly describes that supported configuration as ineligible.

    Could you replace the eligibility sentence with:

    Only the Assistant receives sandbox access. Participant training-token capture
    requires capture to be enabled for the target Agent Server and selection by
    `token_id_capture.training_agent_instances`, which defaults to `[assistant]`.
    Selecting `[assistant, user]` enables both participants; conversation support-model
    calls do not carry the training tag.
    

    Preserve: distinguish sandbox access, training capture and ordinary model-call observability. Selecting user must not grant a sandbox; default participant training capture remains assistant-only.

    Acceptance — static check, not executed: compare the revised paragraph with the seed's assistant-only sandbox branch and the path builder's target-capture/instance-selection conjunction. Proposed path cases should assert default User untagged, explicitly selected User tagged and default Assistant tagged when its target captures.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@pthombre
pthombre force-pushed the pranav/agent-instance-05-agent-session-binding branch 2 times, most recently from 4b5883a to 455cf68 Compare November 3, 2026 00:03
@pthombre
pthombre force-pushed the pranav/agent-instance-05-agent-session-binding branch from 455cf68 to dd85689 Compare November 3, 2026 14:13
@pthombre
pthombre force-pushed the pranav/agent-instance-05-agent-session-binding branch from dd85689 to c6e833f Compare November 3, 2026 15:07
@pthombre
pthombre force-pushed the pranav/agent-instance-05-agent-session-binding branch 2 times, most recently from 5cf561c to b25d661 Compare November 4, 2026 00:50
@pthombre
pthombre force-pushed the pranav/agent-instance-05-agent-session-binding branch from b25d661 to 83757ed Compare November 4, 2026 01:33
@ananthsub
ananthsub force-pushed the pranav/agent-instance-05-agent-session-binding branch from 83757ed to 00ad408 Compare November 4, 2026 06:08
@pthombre
pthombre force-pushed the pranav/agent-instance-05-agent-session-binding branch 2 times, most recently from b27ae96 to 8ef484c Compare November 16, 2026 20:45
pthombre and others added 4 commits November 16, 2026 21:27
…t instance and model server

A group is the calls of one agent instance on one model server; a
single-agent episode is one group. Lineage never crosses a group:

- Parent search runs within the request's group: LineageIndex and the
  incremental and file stores keep one RolloutLineage per group inside each
  episode's cache entry, FileLineageStore filters its shared custody rows by
  group, and source-history candidates come from the group's manifest rows.
  resolve() and has_rows() take a keyword-only identity.
- A request whose only match was served by another model server for the
  same agent instance is a root with root_reason "model_server_changed".
- `ambiguous_candidate` now means ambiguous within one agent instance and
  one model server.

Chains and terminal calls: delivery builds each group with the existing
builder and terminal attribution, so retries are grouped and terminals chosen
within a group, and a declared terminal naming another agent instance's call
is masked (declared_terminal_not_captured). The top-level build is the
primary agent instance's (the unnamed agent, else `assistant`, else the only
one); a named episode also returns every agent instance's build under
`agent_instances`. select_terminal_calls selects per group from a manifest.

Outcomes: TokenCaptureSnapshot reports incomplete_agent_instances and
incomplete_episode beside the aggregate `incomplete`. An agent instance is
masked by its own lost calls or by an episode-wide mark, never by another
agent instance's, under both values of mask_incomplete_when_attributed.

Manifest: manifest() and GET /rollouts/{capture_key}/manifest filter by
agent_instance, agent_kind and model_ref; episode-wide failures are returned
under every filter. Delivery and the manifest share nemo_gym.models.token_capture.groups.

Retire and delete clear every group's cached lineage. Model servers refuse a
run whose capturing servers would write to different capture directories;
a custom sink is exempt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Prashant Thombre <[email protected]>
…wide marks and conflicts, and scope the conformance resolver probes

- consumer: an agent instance that lost every call takes part in choosing the primary and gets a failed build, so another agent instance's chain is never delivered in its place
- local store: a mark that names no call stays episode-wide beside a named mark, and a conflicting write stays episode-wide
- conformance kit: resolve probes pass the call's identity and check that another agent instance's request does not resolve
- tests: per-group parent search, admission, terminal attribution, outcomes, manifest filters, and the fixes above

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>
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]>
pthombre and others added 2 commits November 17, 2026 01:08
The component that starts an agent session names it in the episode seed,
the agent server checks the name on every activation, and the session's
model calls carry it.

- AgentSeedSessionRequest gains `agent_instance`, validated against the
  name grammar and omitted from the serialized seed when unset.
- One open session per agent instance of an episode: a second seed of the
  same episode and agent instance is refused with 409 until the first
  session closes. The binding is session state, so nothing outlives the
  episode. Environment servers check that the names they seed are distinct
  (require_distinct_agent_instances).
- Activation routes also accept /ng-rollout/{key}/ng-agent-instance/{name}
  [/training-token-capture]/v1/responses. Every /v1/responses route checks,
  through nemo_gym.core.correlation, that the path names the session's agent
  instance (an unnamed path must reach an unnamed session) and answers a
  mismatch with 409.
- While a named session seeds or activates, agent_instance_context is set,
  and url_path_for_request, base_url_for_run and resolve_model_base_url fall
  back to it, so agents built on these helpers carry the name without
  per-agent changes. An explicit name wins.
- The restart-only checkpoint middleware reads the path through resolve.

Environments: nemo_user_sim seeds and activates `assistant` and `user`;
SWE-Together seeds and activates its agent as `assistant`, and its judge
moves from its own `<key>-judge-<session>` episode onto the episode's capture
key as `judge`, so the episode's retire covers it. Judge evidence
(judge_evidence.collect_judge_evidence) reads only the `judge` agent
instance's rows of that capture; the verification record names it in
`judge_agent_instance`. Only the assistant carries the
training tag by default (token_id_capture.training_agent_instances).

Compatibility: SWE-Together judge records move from `<key>-judge-<session>`
to the episode's key under `judge`; anything looking for the `-judge` suffix
must change. Written against the session code on main; #5083
(AgentSessionConflictError) needs a rebase of this change when it merges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Pranav Prashant Thombre <[email protected]>
… agent instance

- claude_code: the CLI model URL carries the agent instance a session was seeded as (else the name the request runs under) and takes its training tag from training_tag_for, so the SWE-Together judge's calls are recorded as judge and its evidence is kept
- tests: the Claude Code URL for named and unnamed sessions, the episode scope of the one-session-per-name refusal, resolve_model_base_url carrying the session's name, and the SWE-Together candidate and judge activation paths

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Pranav Thombre <[email protected]>

This branch has not been deployed

No deployments
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 area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers blocked Work cannot move forward until an external dependency is cleared complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants