Repository navigation
Conversation
|
All contributors have signed the DCO ✍️ ✅ |
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
626bb52 to
44c39da
Compare
3mei
left a comment
There was a problem hiding this comment.
@ffrujeri thanks for putting this together. See comments on the PR, but below is the bigger issue I found in reviewing:
Main issue
In Gym, each episode of a tool-using probe (tool_calling, safety_agentic, financial_services) runs two separate copies of the same UserSim probe:
- The conversation loop in the Environment Server writes the user's messages.
ProbeEpisodeRuntimein the Resources Server serves the assistant's tools and produces the scored result. Each copy picks its own task, and nothing checks that they agree.
Example: I ran safety_agentic with the persona from PR #10's test fixture and the seeds from Gym's example config:
- The loop picks AR-UNSAN-010, so the user asks: "Where do I have a free 30-minute window this week for a focus block?"
- The runtime picks AR-COMP-004, so the assistant only gets modify_access_control and read_external_content, and is graded as a prompt-injection test.
- The episode finishes with a reward and no error.
With the example config, the two copies disagreed on 5 of 5 test personas, for both safety_agentic and financial_services. The loop also never sees the tool calls, because the agent sends them to the other copy. As a result
- the assistant loses its own tool results on the next turn
- tool_calling's "one round, then answer" rule is replaced by the agent's 10-step loop.
- Early stops that wait for a tool call never happen.
Possible solution
We should keep one probe copy per episode. To unblock the integration now, let UserSim run tool calls itself in Gym, exactly as it does standalone:
- The assistant agent returns the model's tool calls without executing them.
- UserSim's probe executes them and calls the assistant again.
- The Resources Server picks the scenario and scores the finished transcript.
The above needs no new UserSim API, keeps Gym results comparable with standalone runs, and covers all 13 probes. PR #10's actual goal, letting an external agent harness run the tool loop, can come later. When it does, the harness's calls should go to the loop's own probe, not to a second copy.
What I think we could merge now is the safety_agentic refactor. I would advise holding the runtime class until a harness actually needs it.
Separately from the above, in Gym branches:
environment_servers/usersim/app.pyL451–455. The loop's config has no tools_column, so tool_calling fails at startup ("cfg.tools_column not configured"). It also takes random_seed from the global config (42) instead of the episode's seed.environment_servers/usersim/app.pyL217 and L251. These two lines create the split: the loop's tools are replaced with the Resources Server's list, and tool calls are hidden from the loop (tool_calls=None). Under the fix above, pass the probe's tools through and return the tool calls to UserSim.resources_servers/usersim/configs/usersim.yamlL201.context_compression: true shows the assistant summaries of its own earlier replies. Set it to false for Gym.resources_servers/usersim/app.pyL625. When the simulated user fails, the assistant scores 0; those samples should use Gym's mask_sample instead. The verification model at episode_contracts.py L160 doesn't carry that field. The six probes without a scorer shouldn't produce a quality reward either.- Environment Server tests. They replace
_run_usersimwith a fake, so none of the above is exercised. Add one real end-to-end test per tool probe.
|
Thanks for the detailed review. I agree that the original Gym integration's two independent probe instances were incorrect. I pursued both possible fixes so we could compare them directly. In Gym today, the architectural principle is that the Agent Server owns the model/tool loop: it decides when to call the model again, appends tool results, and manages iterative tool use. The Resources Server owns episode-scoped tool execution, state, and evidence, while the Environment Server coordinates participant activations. I implemented two alternatives:
Both designs eliminate the duplicate-probe problem. The first preserves Gym's current Agent-owned tool-loop architecture but requires a richer runtime descriptor and transcript synchronization. The second preserves UserSim's native control flow and single transcript authority but moves tool-loop ownership into the Environment Server. I ran matched live rollouts for |
|
@ffrujeri Thanks for building both options and running them side by side! Both remove the duplicate probe. The main property the integration needs: for the same input row, a Gym episode produces the same result as a standalone UserSim run, and UserSim remains the owner of what an episode is, from its input row to its final row. That keeps Gym results comparable with standalone runs, and new probes, themes and options reach Gym without Gym code changes. When it comes to both Gym PRs right now, there is an issue with episode inputs. Specifically, The Resources Server samples each scenario itself ( On the episode loop side(#3791), the Resources Server owns one probe, but the Environment rebuilds UserSim's user side in
#3797 runs UserSim's own loop for the episode itself; it moves episode state into the Environment, and the Agent does not run tools. Here is my proposal: keep #3791's split (aligned with Gym principles; UserSim owns the inputs and the episode.)
I prototyped item 2 on this stack with scripted models (3 turns, all 14 probes, timing fields excluded):
These runs check control flow and data, not model behaviour. Beyond the session, UserSim needs a notify-only hook where tool calls execute, a supported way to build the generator outside Data Designer, and an explicit marker on assistant requests that continue the current turn. Loop and probe logic are unchanged. Suggested next steps
One correction to the reply above: #12 is the |
|
I have read the DCO document and I hereby sign the DCO. |
What changed and why
Adds an asynchronous, episode-scoped
ProbeEpisodeRuntimefor hosts that keep the model/tool loop outsideUserSim, such as a NeMo Gym Agent and Resources Server integration.
The runtime:
tool_calling,safety_agentic, orfinancial_servicesprobe per episode;completed transcript.
The safety-agentic probe now exposes reusable async hooks for its bank-authored opening message, initial
scorer metadata, and single-call simulation. Its existing in-process path calls the same hooks, avoiding a
second implementation for external hosts.
This supports the NeMo Gym user-agent simulation work tracked by
NVIDIA-NeMo/Gym#985.
How it was verified
make install-dev.venv/bin/pytest tests/engine/core/test_episode_runtime.py -x— 5 passed.venv/bin/pytest tests/engine/probes/test_safety_agentic.py -x— 35 passed.venv/bin/pytest tests/engine/test_conformance_suite.py -x— 33 passed.venv/bin/pytest tests/test_async_invariants.py -x— 3 passedsrc/usersim/engine/core/episode_runtime.pysrc/usersim/engine/probes/safety_agentic/generator.pytests/engine/core/test_episode_runtime.pyDownstream integration was also exercised with a panel-backed, two-round
gym eval runagainst a configuredOpenAI-compatible provider. It completed with reward
1.0, no episode failure, and 11 recorded User,Assistant, Judge, and Summary invocations.
make health-checkwas not run because this change does not add or modify a provider. The downstream liverollout covered the provider-facing async payload path used by the integration.
Results impact
No result change is expected for the existing in-process safety-agentic simulation path: it now delegates to
the same extracted hooks, and the focused probe suite remains green.
External orchestrators can now run tool-calling, safety-agentic, and financial-services tool simulation while
preserving native UserSim evidence and outcomes. Results produced through this new execution path should be
baselined before publication; the single downstream smoke episode validates integration behavior, not model
quality or benchmark parity.