Skip to content

fix(conversational_tool_use_simulation): fall back to reason_for_contact when the opening user message fails - #4641

Merged
cmunley1 merged 6 commits into
mainfrom
yifuw/ctus-first-user-message-fallback
Oct 16, 2026
Merged

cmunley1 merged 6 commits into
mainfrom
yifuw/ctus-first-user-message-fallback

Conversation

@yfw

@yfw yfw commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Upstreams #3111 to main. #3111 was merged only into super-v3.5-posttraining.

When the user simulator fails on the opening user message, the conversational tool-use server now opens the
conversation with the scenario's reason_for_contact. Before, it ended the trajectory before the policy spoke. A
failure here means the simulator raised an error, or its first message already contained ###STOP### or
###TRANSFER###.

Cause

In both failure cases the server marked the trajectory invalid or terminal at turn 0. The agent then returned a
response with an empty output list. NeMo RL main cannot represent a sample with no policy tokens. It raises before
any mask is read, so one such row can fail the rollout batch.

Fix

  • When no user message exists yet, the server uses customer_scenario.reason_for_contact as the first user message.
    If that is empty or contains ###STOP### or ###TRANSFER###, it uses a generic request
    (DEFAULT_FIRST_USER_MESSAGE). A ###STOP###/###TRANSFER### message triggers the fallback only when nothing
    precedes it in the conversation; a generation error triggers it whenever no user message exists yet.
  • Each fallback is appended to result.source_artifacts.first_user_message_fallbacks, so each fallback stays visible
    in the rollout result.
  • Failures on later user turns keep the existing invalid/terminal behavior.
  • The new config flag fallback_first_user_message controls this. It defaults to true, and the canonical YAML
    declares it. test_config.py asserts the canonical value.
  • The README configuration table and docs/rollout.md document the flag.

No issue is linked. The cause and fix are recorded in #3111, which this PR ports.

Validation

Ran on this branch (base main at 974d1a921). #3111 cherry-picked cleanly. Since super-v3.5-posttraining split from main,
main changed these files in 3 commits. The closest is #4568 (judge text.format, top-level mask_sample). None of them
touch the opening-message path.

  • ng_test +entrypoint=resources_servers/conversational_tool_use_simulation +should_validate_data=true: 85 passed,
    and data validation passed.

  • The 3 new fallback tests fail against main's app.py and pass on this branch:

    • test_first_user_stop_falls_back_to_reason_for_contact
    • test_first_user_generation_error_falls_back_to_reason_for_contact
    • test_first_user_fallback_uses_default_when_reason_for_contact_is_unusable

    The 3 guard tests pass on both. They cover the flag turned off, for the stop and error cases, and an error on a
    later turn.

  • 3 more tests check that a fallback row is scored and not masked through verify(), that the flag defaults to
    true, and that a ###STOP### first message is retried before the fallback replaces it. Each fails if the behavior
    it covers is broken.

  • Parity with super-v3.5-posttraining: the fallback code is identical to that branch at every Gym commit the
    training run below used (e978899b7, 34b99364, 14317ecb5). A local run of the real agent and resource server
    through verify() on 23 cases (user simulator, policy and judge stubbed) matches that branch on reward, mask and
    messages with the flag at its default, true or false. With false it also matches main without this PR.

  • pre-commit run --all-files: passed, no changes.

  • DCO: every commit is signed off.

Rollout evidence

The fix ran in a Nemotron 3.5 Super RLVR training run, super35-journey-rlvr-v43-yifuw-001
(W&B). The run used NeMo RL
super-v3.5-posttraining, whose Gym pin has included #3111 since 2026-09-04. The run's data blend includes
conversational_tool_use_simulation.

  • The fallback fired twice. Each time, the user simulator returned only a reasoning item and no message, so the server
    logged first user message fallback: message_generation_error (A response does not contain a message output).
    Without the fix, each of these rows would have produced an empty agent output. That branch's NeMo RL also has
    RL docs(cli): document --environment selector and fix stale CLI samples #4001, which turns such rows into masked placeholders, so this run shows the fallback trains safely rather than
    that it prevented a failure. NeMo RL main doesn't have docs(cli): document --environment selector and fix stale CLI samples #4001.
  • Training kept going after both. The first fallback happened during step 35 of W&B run dvp5tc0d, which went on to
    step 38. The second happened during step 41 of 0g5thn9y, which went on to step 51. The run reached step 78.

Compatibility

  • This changes default behavior. On main, a first-turn simulator failure produces a row with an empty agent output,
    labeled user_failure and masked. With this PR, that row becomes a normal conversation that starts from the
    scenario's own request, and it is scored and trained on. If the judge rejects that first message itself, the row is
    masked as a user failure, as before. Set fallback_first_user_message: false to restore the old
    behavior.
  • Rows whose prefilled history already contains a user message never fall back.

🤖 Generated with Claude Code

yfw and others added 2 commits October 15, 2026 10:46
…act when the opening user message fails

When the user simulator raised while generating the first user message,
or produced a first message that already carried
###STOP###/###TRANSFER###, the server ended the trajectory before the
agent ever spoke. The agent then returned a response with an empty
output list, which NeMo RL cannot represent (no trainable tokens) and
turned into a whole-batch rollout failure.

Fall back to the scenario's reason_for_contact (or a generic request
when that is empty or itself carries a stop indicator) so the
conversation always reaches the agent. Record each fallback under
source_artifacts.first_user_message_fallbacks so the simulator failure
rate stays observable. Later-turn failures keep the existing
invalid/terminal behavior. Controlled by the new
fallback_first_user_message config flag (default true).

Signed-off-by: Yi-Fu Wu <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…r_message

Add the flag introduced by the previous commit to the README's
configuration table: what triggers the fallback, which text replaces the
opening user message, where each fallback is recorded, and what
disabling it does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@copy-pr-bot

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

@yfw yfw added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer labels Oct 15, 2026
@yfw

yfw commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test b594a36

@yfw

yfw commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

/review

@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.

SHIP — one nonblocking configuration NOTE.

No BLOCKER or RISK findings. The opening-message fallback, opt-out behavior, later-turn failure handling, and artifact serialization are consistent with the inspected agent and verifier paths.

Static review only; tests were not executed.

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

Review generated by codex

@yaoyu-33 yaoyu-33 added the complexity:low Localized change in one scope with a small, straightforward review surface label Oct 15, 2026
yfw and others added 4 commits October 15, 2026 13:37
…ault, retries and TRANSFER reason

The existing fallback tests stopped at next_user_message, so masking
fallback rows, labeling them user_failure, or flipping the code default
to False all passed the suite. Add tests that:

- verify a fallback row end to end: scored, not masked, no failure
  labels, and the fallback recorded in result.source_artifacts;
- pin the fallback_first_user_message default by building the config
  directly (make_server always passes the flag);
- check that a ###STOP### first message is retried before the fallback
  replaces it;
- cover a reason_for_contact containing ###TRANSFER###, which would
  otherwise end the conversation before the policy speaks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
…ssage fallback applies

A ###STOP###/###TRANSFER### message only triggers the fallback when
nothing precedes it in the conversation, the generic request also
replaces a reason_for_contact containing ###TRANSFER###, and with the
flag off the trajectory does not always end before the policy responds
(the policy can speak first). Correct the README row accordingly,
describe the fallback in docs/rollout.md (the session contract the
README links), and reword the helper docstring: the fallback is
recorded per row in the rollout result, not as an aggregate rate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
…r_message in the canonical config

The canonical YAML lists every other setting this server's config
defines, and the README's "Canonical value" column follows it. Declare
the new flag there too so resolved configs show it. The value matches
the Python default, so behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
… enables fallback_first_user_message

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw

yfw commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c9152cd

@cmunley1
cmunley1 added this pull request to the merge queue Oct 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38840110333

Merged via the queue into main with commit c2000f7 Oct 16, 2026
48 of 53 checks passed
@cmunley1
cmunley1 deleted the yifuw/ctus-first-user-message-fallback branch October 16, 2026 02:39

This branch was previously deployed

1 inactive deployment
public — c9152cd1 Deployed Oct 15, 2026 by copy-pr-bot[bot] via release / finalize / notify #5579
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 bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface 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.

4 participants