Skip to content

feat(usersim): use canonical probe runtime - #3791

Merged
ffrujeri merged 0 commit into
ffrujeri/usersim-rollout-quickstartfrom
ffrujeri/usersim-canonical-runtime
Oct 1, 2026
Merged

ffrujeri merged 0 commit into
ffrujeri/usersim-rollout-quickstartfrom
ffrujeri/usersim-canonical-runtime

Conversation

@ffrujeri

@ffrujeri ffrujeri commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • carry the complete UserSim-resolved row unchanged and construct episodes only with ProbeEpisodeRuntime.from_resolved_row(row, models=...)
  • preserve UserSim trajectory identity/provenance and role model identities; Gym no longer reconstructs generator preamble fields
  • remove host X-NeMo-Gym-Turn-Index / X-NeMo-Gym-Call-Index headers and let UserSim assign semantic indices
  • add narrowly typed DirectHTTP ordered-batch support while keeping the model → tool → model loop in SimpleAgent
  • return single simulated tool payloads as exact opaque text bytes without JSON parsing or {result: ...} wrapping
  • compare a UserSim-materialized task through real Resources, Environment, and SimpleAgent execution against the standalone generator
  • pin runtime, provenance, allowlists, tests, and docs to 4fd4c800bbef8883329543df632f328860fc6429

Why

This consumes the canonical external execution API from UserSim PR #15 and addresses the four reviewer concerns without changing Gym PR #3797.

Validation

  • Resources tests — 12 passed
  • Environment lifecycle tests — 8 passed
  • SimpleAgent + tool-access tests — 26 passed
  • preparation + standalone generator parity — 4 passed
  • Ruff check and format-check on requested stack layers — passed
  • scoped pre-commit — passed
  • Fern — 0 errors, 1 hidden warning
  • all authored commits include DCO sign-off

Live rollout evidence

All runs used /home/ffrujeri/nemo-gym/env.yaml without exposing credentials, one prepared row, one repeat, and concurrency 1. An initial policy reasoning-parser mismatch was corrected with +policy_uses_reasoning_parser=true; bounded upstream HTTP 503 retries occurred, then all final runs completed.

  • tool_calling: 1/1 completed; trajectory 9be739c21d9596e2; revision 4fd4c800...; conversation status true; 5 turns; 2 tool calls; reward 0.0; mask_sample=false; no failure kind; native scenario incomplete due model behavior
  • safety_agentic: 1/1 completed; trajectory 26f4b7560537cd59; revision 4fd4c800...; conversation status true; 1 turn; 1 tool call; native index (0, 0); reward 0.8666666666666667; scenario complete; mask_sample=false
  • financial_services: 1/1 completed; trajectory ea8d7d13ca6b4da7; revision 4fd4c800...; conversation status true; 4 turns; 2 native tool calls; reward 0.5333333333333333; scenario complete; mask_sample=false
  • all tool transcript payloads remained strings; no non-json, JSONDecodeError, or evidence-mismatch retry markers occurred

Compatibility

This intentionally replaces the old scenario/context seed shape and host index headers with the pinned resolved-row and UserSim-owned-index contracts. Standard DirectHTTP behavior is unchanged unless an optional typed batch_path is configured.

@copy-pr-bot

copy-pr-bot Bot commented Sep 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.

@yaoyu-33 yaoyu-33 added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Sep 29, 2026
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from 93f7dc1 to c745dda Compare September 30, 2026 02:27
@ffrujeri
ffrujeri added this pull request to stack #3804 September 30, 2026 02:34
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from c745dda to a1d407b Compare September 30, 2026 02:41
@3mei

3mei commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@ffrujeri Summary of my comment on UserSim#10, from the Gym side. This PR removes the duplicate probe. For Gym episodes to reproduce standalone NeMo UserSim runs of the same input row, UserSim needs to own the episode inputs and the episode loop, with the Gym code staying generic. New probes, themes and options then reach Gym without Gym code changes.

Episode inputs

  • _select_probe and _resolve_seed sample each scenario in Gym: the probe from probe_mix (L105), the persona by a stable hash into the panel (L379), the theme from probe_themes (L111, L381-L387), and the tools from dataset rows. Gym also keeps its own probe lists (L57, L72).
  • The example has one tool_calling theme and one hand-written tool, and two themes per general probe, all in English. UserSim ships 143 toolsets in 79 categories, which drive tool_calling's tools and theme, and per-locale topic seeds (for example 48 en_US, 15 ja_JP and 20 pt_BR topics for general_open_ended).
  • Change: the prepare step runs UserSim's sampling-only option (a flag on usersim simulate, proposed in UserSim#10), and each dataset row carries the resulting UserSim input row, which the Resources Server passes to UserSim unchanged. probe_mix, probe_themes, SUPPORTED_PROBES, THEME_DRIVEN_PROBES and the stable-hash sampling go away; UserSim's own sampling options (probe mix, locales, panel) are passed through to UserSim.

Episode loop

  1. environment_servers/usersim/app.py L515-L588: _run_external_probe replaces UserSim's loop. There are no user-turn checks and retries, in-conversation judge, early stop, frustration, or wrap-up, and the follow-up prompt is new text (L568-L571).
  2. resources_servers/usersim/app.py L475-L496: the probe is built without UserSim's per-episode user settings (40 test personas: disclosure instructions 0/40 vs 25/40 standalone, interaction style 0/40 vs 23/40), and the profile ignores the locale (L496).
  3. L628-L630: non-JSON tool results are wrapped, then rejected by the runtime; 7 of 89 safety_agentic mocks are not JSON. SimpleAgent already uses the raw response body as the tool output (simple_agent/app.py L341), so returning the payload as plain text is enough.
  4. environment_servers/usersim/app.py L548-L553: the Agent receives the raw transcript, so financial_services loses UserSim's trimmed document view.
  5. L287: the bridge drops the model's reasoning, which UserSim stores by default.
  6. resources_servers/usersim/app.py L486: finance_retrieval_mode="golden" is UserSim's gold-document ablation; the default hybrid falls back to lexical search when no embedding model is configured.

Proposed rework (keeps this PR's split: Resources owns the episode, the Assistant Agent owns the model/tool loop, the Environment coordinates)

  • Resources hosts one UserSim session per episode, starting from the prepared input row, for every registered probe (all 14 built-ins today). It exposes next request, respond, record agent output, and tool routes that return UserSim's payload by call id; closing the session cancels the episode, and /verify receives the session's final row. The tool simulator stays in Resources, because the Environment is waiting on the Agent while tools run. Load UserSim's data at startup: in a load test, loading it during the first episodes stalled the event loop for up to 630 ms.
  • Environment becomes a generic driver: it routes each request by UserSim role name, per config, to the User, Judge or Summary participant or to the Assistant Agent, and keeps the invocation log. It passes each role's model id and token budget when seeding the session, and returns reasoning and usage with every response. It no longer imports UserSim, so _run_external_probe and the generator subclass go away.
  • SimpleAgent: replace the loop-policy changes here with one step. The agent records each model response before issuing its tool calls, as conversational_tool_use does with /record_agent_outputs, then follows the reply (continue or stop, tools on or off, the next input). The turn and call index headers go away; the call id stays. Agents that cannot record use execute_tools: false from feat(usersim): evaluate environment-owned native tool loop #3797, and UserSim runs the tools.
  • Example config: the simulated user (L72), the judge and summary model (L105-L110) and the tool simulator (L40-L42) default to the model under test (L5-L7); point them at a separate model.
  • Tests: end to end with the real session for all 14 probes in both modes, compared with feat(usersim): evaluate environment-owned native tool loop #3797 on the same rows.

A prototype of the session on the same stack matched standalone runs on 14/14 probes in both modes, and 42/42 concurrent episodes (details in UserSim#10).

@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from a1d407b to 854f584 Compare September 30, 2026 15:44
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch 4 times, most recently from 8b97ff2 to 2b128e7 Compare September 30, 2026 17:21
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from 2b128e7 to d213a11 Compare September 30, 2026 19:33
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch 2 times, most recently from 958338e to e52359f Compare September 30, 2026 21:10
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Sep 30, 2026
@3mei

3mei commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@ffrujeri

Still open

  1. The pin includes a UserSim regression. At 4fd4c800, standalone UserSim cannot build its Data Designer pipeline (UserSim#15); this needs a re-pin once that's fixed.
  2. Role model ids and token budgets don't reach the runtime. identity_disclosure runs without an expected identity, and each row's trajectory_id names UserSim's default models from preparation (feat(nemo-user-sim): add generated validation tasks #3802) rather than the models this environment runs.
  3. SimpleAgent still carries UserSim's loop policy. With the record step from my earlier comment, the agent follows UserSim's reply for each step, AgentToolLoopPolicy leaves Gym's general-purpose agent, and the multi-turn differences described on UserSim#15 go away.
  4. Contract errors count against the policy. If a tool result reaches the runtime changed, UserSim retries the turn and fails it as assistant_model; the fix is on the UserSim side.

Also:

  • the MCP transport has no batch path, so parallel calls there count as separate rounds;
  • the simulated user still defaults to the policy model;
  • UserSim's data isn't loaded at startup;
  • the tests cover safety_agentic with one tool round, rather than all 14 probes in both modes compared with feat(usersim): evaluate environment-owned native tool loop #3797.

The UserSim-side changes are listed on UserSim#15. Happy to make those changes on usersim!

ffrujeri added a commit that referenced this pull request Oct 1, 2026
Addresses the review on #3791 and adopts the reworked UserSim contract
from NVIDIA-NeMo/UserSim#15.

The Assistant Agent no longer runs the probe's tools. It makes one model
call per activation and returns the model's tool calls unexecuted; UserSim
executes them inside its own conversation loop when the Environment records
that response, so the turn and call indices, the tool simulator's context,
and the loop's own decisions stay UserSim's.

- Re-pins UserSim to a4665b3, where standalone `usersim simulate` builds its
  Data Designer pipeline again.
- Declares the models this environment runs per role, with their token
  budgets, when seeding. Without them `identity_disclosure` ran with no
  expected identity and trajectory ids named preparation's defaults rather
  than the models under test.
- Returns reasoning and usage with every recorded response; UserSim stores
  both.
- `AgentToolLoopPolicy` leaves Gym's general-purpose agent contract, along
  with the tool-access batch path. In their place `AgentSeedSessionRequest`
  carries one generic `execute_tools` flag for callers that run tools
  themselves. SimpleAgent loses the synthesis, activation-cap and
  per-turn-cap logic that only existed to mirror UserSim's loop.
- Contract errors from the runtime return HTTP 422 to their author instead
  of being retried against, or attributed to, the model under test.
- Drops the tool and batch routes, the tool-call-id header and the MCP/HTTP
  tool transports for probe tools: nothing executes them host-side now, so
  parallel calls can no longer be split across rounds by transport.
- Loads UserSim's probe registry and assets at Resources startup rather than
  during the first episodes, where it stalled the event loop.
- Points the simulated user at the support model; it was the policy model,
  so the model under test was interviewing itself.
- Closes the runtime through its own `close()` and finalizes through the
  public lifecycle state rather than private attributes.

Tests: end-to-end parity against a standalone generator run for all 14
registered probes through the real Resources/Environment/SimpleAgent stack,
declared role models, a rejected contract error, and `execute_tools: false`
returning tool calls after exactly one model call.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
ffrujeri added a commit that referenced this pull request Oct 1, 2026
Addresses the review on #3791 and adopts the reworked UserSim contract from
NVIDIA-NeMo/UserSim#15. Keeps this PR's split: Resources owns the episode, the
Assistant Agent owns the model/tool loop, the Environment coordinates.

The Agent still drives model -> tool -> model, but it no longer decides the
loop's shape. Per step it calls its model, records that response with
Resources *before* issuing the response's tool calls, and follows the reply:
whether the turn continues, which tools are offered next, and the exact input
UserSim would send. Recording is what makes UserSim execute the calls, inside
its own conversation loop, so the turn and call indices and the tool
simulator's context are UserSim's. The reply's input replaces the Agent's own
accumulated transcript, which matters for probes that trim their context.

That removes `AgentToolLoopPolicy` from Gym's general-purpose agent contract
along with the tool-access batch path, and with them SimpleAgent's synthesis,
activation-cap and per-turn-cap logic, which only existed to mirror rules
UserSim already enforces. In their place the agent session carries
`record_outputs_path` and a generic `execute_tools` for agents that cannot
record.

- Re-pins UserSim to a4665b3, where standalone `usersim simulate` builds its
  Data Designer pipeline again.
- Declares the models this environment runs per role, with their token
  budgets, when seeding. Without them `identity_disclosure` ran with no
  expected identity and trajectory ids named preparation's defaults.
- Returns reasoning and usage with every recorded response; UserSim stores
  both.
- Contract errors return HTTP 422 to their author rather than being retried
  against, or attributed to, the model under test.
- Drops the tool batch route and its transport flag: parallel calls now
  arrive together in one recorded response, so they can no longer be split
  across rounds by transport.
- Loads UserSim's probe registry and assets at Resources startup rather than
  during the first episodes, where it stalled the event loop.
- Points the simulated user at the support model; it was the policy model, so
  the model under test was interviewing itself.
- Closes the runtime through its own `close()` and finalizes through the
  public lifecycle state rather than private attributes.

Tests: end-to-end parity against a standalone generator run for all 14
registered probes through the real Resources/Environment/SimpleAgent stack,
the record reply driving the Agent's loop, declared role models, a rejected
contract error, and the tool route returning UserSim's payload verbatim.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from 4b45886 to 20b4e5f Compare October 1, 2026 04:57
ffrujeri added a commit that referenced this pull request Oct 1, 2026
Addresses the review on #3791 and adopts the reworked UserSim contract from
NVIDIA-NeMo/UserSim#15. Keeps this PR's split: Resources owns the episode, the
Assistant Agent owns the model/tool loop, the Environment coordinates.

The Agent still drives model -> tool -> model, but it no longer decides the
loop's shape. Per step it calls its model, records that response with
Resources *before* issuing the response's tool calls, and follows the reply:
whether the turn continues, which tools are offered next, and the exact input
UserSim would send. Recording is what makes UserSim execute the calls, inside
its own conversation loop, so the turn and call indices and the tool
simulator's context are UserSim's. The reply's input replaces the Agent's own
accumulated transcript, which matters for probes that trim their context.

That removes `AgentToolLoopPolicy` from Gym's general-purpose agent contract
along with the tool-access batch path, and with them SimpleAgent's synthesis,
activation-cap and per-turn-cap logic, which only existed to mirror rules
UserSim already enforces. In their place the agent session carries
`record_outputs_path` and a generic `execute_tools` for agents that cannot
record.

- Re-pins UserSim to a4665b3, where standalone `usersim simulate` builds its
  Data Designer pipeline again.
- Declares the models this environment runs per role, with their token
  budgets, when seeding. Without them `identity_disclosure` ran with no
  expected identity and trajectory ids named preparation's defaults.
- Returns reasoning and usage with every recorded response; UserSim stores
  both.
- Contract errors return HTTP 422 to their author rather than being retried
  against, or attributed to, the model under test.
- Drops the tool batch route and its transport flag: parallel calls now
  arrive together in one recorded response, so they can no longer be split
  across rounds by transport.
- Loads UserSim's probe registry and assets at Resources startup rather than
  during the first episodes, where it stalled the event loop.
- Points the simulated user at the support model; it was the policy model, so
  the model under test was interviewing itself.
- Closes the runtime through its own `close()` and finalizes through the
  public lifecycle state rather than private attributes.

Tests: end-to-end parity against a standalone generator run for all 14
registered probes through the real Resources/Environment/SimpleAgent stack,
the record reply driving the Agent's loop, declared role models, a rejected
contract error, and the tool route returning UserSim's payload verbatim.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from 20b4e5f to bd99602 Compare October 1, 2026 04:58
ffrujeri added a commit that referenced this pull request Oct 1, 2026
Addresses the review on #3791 and adopts the reworked UserSim contract from
NVIDIA-NeMo/UserSim#15. Keeps this PR's split: Resources owns the episode, the
Assistant Agent owns the model/tool loop, the Environment coordinates.

The Agent still drives model -> tool -> model, but it no longer decides the
loop's shape. Per step it calls its model, records that response with
Resources *before* issuing the response's tool calls, and follows the reply:
whether the turn continues, which tools are offered next, and the exact input
UserSim would send. Recording is what makes UserSim execute the calls, inside
its own conversation loop, so the turn and call indices and the tool
simulator's context are UserSim's. The reply's input replaces the Agent's own
accumulated transcript, which matters for probes that trim their context.

That removes `AgentToolLoopPolicy` from Gym's general-purpose agent contract
along with the tool-access batch path, and with them SimpleAgent's synthesis,
activation-cap and per-turn-cap logic, which only existed to mirror rules
UserSim already enforces. The agent contract gains one field in their place:
`record_outputs_path`.

- Re-pins UserSim to a4665b3, where standalone `usersim simulate` builds its
  Data Designer pipeline again.
- Declares the models this environment runs per role, with their token
  budgets, when seeding. Without them `identity_disclosure` ran with no
  expected identity and trajectory ids named preparation's defaults.
- Returns reasoning and usage with every recorded response; UserSim stores
  both.
- Contract errors return HTTP 422 to their author rather than being retried
  against, or attributed to, the model under test.
- Drops the tool batch route and its transport flag: parallel calls now
  arrive together in one recorded response, so they can no longer be split
  across rounds by transport.
- Loads UserSim's probe registry and assets at Resources startup rather than
  during the first episodes, where it stalled the event loop.
- Points the simulated user at the support model; it was the policy model, so
  the model under test was interviewing itself.
- Closes the runtime through its own `close()` and finalizes through the
  public lifecycle state rather than private attributes.

Tests: end-to-end parity against a standalone generator run for all 14
registered probes through the real Resources/Environment/SimpleAgent stack,
the record reply driving the Agent's loop, declared role models, a rejected
contract error, and the tool route returning UserSim's payload verbatim.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from bd99602 to d25962f Compare October 1, 2026 05:55
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch 2 times, most recently from 0a21016 to e52359f Compare October 1, 2026 14:24
@ffrujeri
ffrujeri marked this pull request as draft October 1, 2026 19:06
@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 1, 2026
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from 52b9a34 to c7c0684 Compare October 1, 2026 20:28
@ffrujeri ffrujeri closed this Oct 1, 2026
@ffrujeri
ffrujeri force-pushed the ffrujeri/usersim-canonical-runtime branch from e3bf84f to ad73e0b Compare October 1, 2026 22:28
@ffrujeri
ffrujeri merged commit ad73e0b into main Oct 1, 2026
@ffrujeri
ffrujeri deleted the ffrujeri/usersim-canonical-runtime branch October 1, 2026 22:28
@copy-pr-bot

copy-pr-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ffrujeri
ffrujeri restored the ffrujeri/usersim-canonical-runtime branch October 1, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants