Skip to content

feat(environment): honor skip_verification in single_agent_turn - #4949

Merged
yaoyu-33 merged 5 commits into
NVIDIA-NeMo:mainfrom
yaoyu-33:yuya/gymint-235-env-server-skip-verification
Oct 27, 2026
Merged

yaoyu-33 merged 5 commits into
NVIDIA-NeMo:mainfrom
yaoyu-33:yuya/gymint-235-env-server-skip-verification

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Stack — environment server migration, phase 1 (bottom → top): this PR → #4952 (generator) → #4953 (configs) → #4954 (retire agents). The stack builds on a mirror of this PR's head in this repository.

What and why

simple_agent already serves agent sessions and is the only agent that resumes inside its turn, but about 307 configs still reach it through the legacy_agent relay. Moving them to single_agent_turn_legacy (#4953) is the largest single cut in restart cost. One thing blocks it: single_agent_turn always calls /verify, and the global skip_verification flag is copied only into agent configs (nemo_gym/global_config.py, validate_and_populate_defaults). Switching a config today drops the setting without a warning.

This PR makes single_agent_turn, and the single_agent_turn_legacy adapter built on it, honor the setting:

  • New config fields skip_verification and skip_verification_reward. When either is unset, it falls back to the bound agent's value. That value already carries the global flag and any explicit agent-level setting (for example critpt_custom_grader), so a pairing moved off the relay keeps behaving as its agent's /run did. An explicit environment-server value wins over the agent's.
  • When skipping, the episode does not call /verify. It returns this server's verified result shape: the verify body, plus the fixed reward and verification_skipped: true that simple_agent's /run also sets. The flag lets anything reading the result tell it apart from a measured reward; nothing in Gym filters on it yet.
  • The agent outcome policy still applies, so a retryable agent failure stays a retryable failure and does not become a fixed reward. Both sessions are still closed.
  • /aggregate_metrics warns and returns empty metrics, as an agent's does under skip_verification.

Out of scope, to keep this PR focused:

Completes skip-verification support for single_agent_turn; the other Environment Servers remain separate follow-up work.

Design

Markers: green NEW, orange CHANGED, red dashed BROKEN; the label text says the same, so the diagrams read without color.

Before and after

The global +skip_verification=true flag is copied only into agent configs. Under the relay, the agent's /run ran the whole episode and read it. Under single_agent_turn_legacy, the environment server runs the episode, and before this PR it never looked at the flag.

Before

flowchart LR
    G["global +skip_verification=true"] -->|copied into| AC["simple_agent config<br/>skip_verification: true"]

    subgraph relay["legacy_agent relay (today, ~307 configs)"]
        R1["agent /run"] -->|reads flag| R2["skip /verify<br/>reward = fixed, verification_skipped"]
    end

    subgraph sat["single_agent_turn_legacy (before this PR)"]
        S1["seed → agent turn → close agent"] --> S2["always POST /verify"]
        S2 --> S3["reward from resources server"]
    end

    AC --> R1
    AC -. "never read: setting silently dropped" .-> S1
Loading

After

flowchart LR
    G["global +skip_verification=true"] -->|copied into| AC["simple_agent config"]
    EC["environment server config<br/>skip_verification / skip_verification_reward<br/>(optional)"]

    subgraph sat["single_agent_turn_legacy (this PR)"]
        D{"skip?<br/>env setting if set,<br/>else the agent's"}
        S1["seed → agent turn → close agent<br/>outcome policy still applies"] --> D
        D -->|no| V["POST /verify<br/>reward from resources server"]
        D -->|yes| K["no /verify<br/>reward = fixed<br/>verification_skipped: true"]
        V --> C["close resources session"]
        K --> C
    end

    EC --> D
    AC --> D
Loading

Episode control flow (single_agent_turn and single_agent_turn_legacy). The skip replaces only the /verify step. The outcome policy runs before it, and the resources session is closed on both paths.

sequenceDiagram
    autonumber
    participant RC as Rollout collection
    participant ES as single_agent_turn(_legacy)
    participant AG as simple_agent session
    participant RS as Resources server
    RC->>ES: /run (flat row)
    ES->>RS: /seed_session (typed)
    ES->>AG: /v1/agent_sessions
    ES->>AG: /v1/responses (one turn)
    ES->>AG: /v1/agent_sessions/close
    Note over ES: agent outcome policy still applies:<br/>a retryable failure stays a failure, never a fixed reward
    alt NEW: skip_verification (server setting, else the agent's)
        Note over ES: NEW: no /verify<br/>reward = skip_verification_reward<br/>verification_skipped: true
    else not skipped (unchanged)
        ES->>RS: /verify (session cookie)
        RS-->>ES: reward
    end
    ES->>RS: /close_session (both paths)
    ES-->>RC: flat result row
Loading

Validation

  • environment_servers/single_agent_turn/tests/test_app.py: 109 passed. Thirteen new cases cover:
    • reward from the environment server's own setting, the agent's setting, and a mix of the two
    • default reward 0.0
    • environment server false overriding an agent's true
    • the environment server's reward with the agent's skip
    • an agent that does not skip, set as false or as the string "false" (a quoted override or ${oc.env:...} value), keeps verifying
    • string agent values parsed as the agent parses them
    • the outcome policy still producing a retryable failure
    • empty aggregate metrics with no resources call, from the environment server's setting or the agent's
    • an episode restored at its verify boundary closing the resources session without verifying
  • environment_servers/single_agent_turn_legacy/tests/test_app.py: 19 passed. The new case runs a flat row with the agent's setting, which is the migration case covered by chore(configs): move simple_agent configs off the legacy_agent relay #4953.
  • The 8 original new cases fail on unmodified main (checked by reverting app.py). The string "false" case fails on the first commit of this PR, which used bool(...).
  • pre-commit run --all-files: all hooks pass, no files modified.
  • Run each test file on its own: collecting both in one pytest call clashes on the shared test_app module name, as it does on main.

Rollout evidence

This runs the real Gym servers against a stub model, not a real one. No model endpoint was available in this environment. A real-model rollout is N/A for this change: whether /verify is called depends only on configuration, not on model output, and the stub run exercises the real servers end to end and counts every call.

Config resources_servers/example_single_tool_call/configs/example_single_tool_call_single_agent_turn.yaml (simple_agent through single_agent_turn_legacy, stateful resources sessions) with openai_model pointed at a local stub Responses endpoint. Two rows; gym env start with +uvicorn_logging_show_200_ok=true, then gym eval run --no-serve.

Run Rewards verification_skipped /verify calls /seed_session / /close_session agent session create / close
+skip_verification=true +skip_verification_reward=0.75 (global flag only) 0.75, 0.75 true, true 0 2 / 2 2 / 2
control, no flag 0.0, 0.0 (from /verify) absent 2 2 / 2 2 / 2

The global flag reached the environment server through the agent config, with no environment-server setting. The skip run's aggregate metrics file is empty.

Compatibility

Existing configs behave the same unless the agent or the run sets skip_verification:

  • With the fields unset and no agent flag, behavior is identical.
  • Configs that set skip_verification on a simple_agent bound to single_agent_turn now skip, where before they silently verified. That is the intended fix.
  • The global +skip_verification=true also reaches existing single_agent_turn pairings whose agent is not simple_agent, because Gym copies the flag into every agent config. Examples are benchmarks/gdpval/config.yaml (stirrup), benchmarks/swebench/pro/hermes.yaml, and responses_api_agents/nooa_agent/configs/nooa_agent.yaml. Those pairings verified before and now skip under the flag, as asked.

🤖 Generated with Claude Code

CI refresh (2026-10-23)

Rebased onto main at 8041d1910 and preserved the existing stack bases. This includes #4973's atomic resubmit-lock fix and #4966's Terminus PROMPT_COMMAND fix, which address the failures in the previous CI runs. No additional runtime behavior changes were introduced by this refresh.

Resolved the import conflict with #4945 while retaining both the shared dependency-error helper and the skip-verification tests. pytest --import-mode=importlib environment_servers/single_agent_turn/tests/test_app.py environment_servers/single_agent_turn_legacy/tests/test_app.py tests/unit_tests/test_eval_resubmit.py: 176 passed.

pre-commit run --all-files, git diff --check, and DCO trailer checks passed. Fresh Linux CI is still required on the new head. Rollout evidence for this refresh: N/A; this only rebases the existing changes onto the upstream CI fixes.

@yaoyu-33 yaoyu-33 added feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation labels Oct 22, 2026
@copy-pr-bot

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

Copy link
Copy Markdown
Contributor Author

/ok to test 97f8001

@yaoyu-33 yaoyu-33 left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. It closes a real gap for the config migration in #4953: without it, moving the simple_agent relay configs onto single_agent_turn_legacy would silently drop the global skip_verification. The precedence rule (this server's own setting, else the bound agent's) is easy to follow, the outcome policy still runs before the skip, and both sessions are still closed. The new tests assert real behavior. Both suites pass at this head (103 and 19), and the new cases fail on main.

Two inline comments:

  • Risk: the agent fallback coerces with bool(...), so a string "false" turns into a skip.
  • Note: the Compatibility section misses one behavior change for pairings with agents other than simple_agent.

Smaller points, not posted inline:

  • The aggregate_metrics docstring still says it always forwards to the resources server.
  • The rollout evidence uses a stub model. Because this path does not depend on model output, that seems fine here. It would still help to say so as the explicit N/A that AGENTS.md asks for, or to add one real-model smoke run.
  • Validation lists scoped pre-commit run --files, not --all-files.

Verdict: ship with care once the boolean coercion is fixed.

@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 92a3e6a

@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test e9d96f3

@yaoyu-33
yaoyu-33 marked this pull request as ready for review October 23, 2026 17:09
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Oct 23, 2026

@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 — LGTM — no reliability concerns.

Reviewed all four changed files and traced configuration fallback, outcome-policy ordering, session cleanup, checkpoint restore, and legacy result projection. The fallback now parses string values with Pydantic, resolving the earlier "false" issue. The README also documents the effect on all bound agents. No actionable BLOCKER, RISK, or NOTE findings remain.

Validation was static source and test inspection only; I did not execute tests or reproduce the PR-reported rollout evidence.

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

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

yaoyu-33 and others added 3 commits October 23, 2026 13:44
single_agent_turn always called the resources server's /verify, and the
global skip_verification flag is copied only into agent configs. Moving a
simple_agent pairing off the legacy_agent relay therefore dropped the
setting silently (GYMINT-235, blocking GYMINT-549).

The environment server now takes skip_verification and
skip_verification_reward. Unset, each falls back to the bound agent's
value, which carries the global flag. When skipping, the episode returns
the flat verify body with the fixed reward and verification_skipped=true,
still applies the agent outcome policy, and still closes both sessions.
/aggregate_metrics returns empty metrics, as an agent's does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
The fallback to the bound agent's skip_verification used bool(), so a string "false" from a quoted
override or an ${oc.env:...} interpolation skipped /verify while the agent itself verified. Parse
both fallbacks with pydantic, as the agent's config does, and test the string and explicit-false
cases. The README now says the global flag also reaches agents whose own /run never read it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Restoring an episode at its verify boundary with skip_verification on closes the resources session
without calling /verify, and aggregate metrics are empty when the skip comes from the bound agent.
The README and the code comment no longer say that reward profiling and training read
verification_skipped; nothing does yet, but the flag lets a reader tell the fixed reward apart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
weijiac0619
weijiac0619 previously approved these changes Oct 26, 2026
Merge main at 5a31c28, preserving skip-verification behavior and using resources_verify_step_type in the verification branch.

Validation: 284 tests passed across both affected server suites and checkpoint environment, contract, and declaration suites. pre-commit run --all-files and git diff --check passed. Tests used NEMO_GYM_EXTRA_ROOTS and PYTHONPATH pointing at this worktree to avoid the shared editable install.

Rollout evidence: N/A for this conflict-only update; the resolution follows the upstream field rename and introduces no additional runtime behavior.

Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 496ae53

weijiac0619
weijiac0619 previously approved these changes Oct 26, 2026
@yaoyu-33
yaoyu-33 added this pull request to the merge queue Oct 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 26, 2026
@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 6b9fe7f

@yaoyu-33
yaoyu-33 added this pull request to the merge queue Oct 27, 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/40551705110

Merged via the queue into NVIDIA-NeMo:main with commit 20be8ee Oct 27, 2026
46 of 49 checks passed
@yaoyu-33
yaoyu-33 deleted the yuya/gymint-235-env-server-skip-verification branch October 27, 2026 18:13
yuhezhang-ai added a commit that referenced this pull request Oct 27, 2026
Conflicts:
- rollout_collection.py: #5029 tells the exporters to start a new tracking run when a resume finds nothing to
  resume. #3302 makes that decision in RolloutStore.start_or_resume, so the store now reports started_fresh and
  the collector calls start_over() after it when a resume was requested.
- single_agent_turn_legacy tests: kept both new tests (#4949's skip_verification test and #3302's).

Tests from main adapted to #3302's rules:
- A run with history whose output or materialized inputs are missing refuses to resume rather than start over,
  so it keeps its tracking run. The start-over case is a resume with nothing saved.
- The string-flag collection test supplies the running servers' configuration, which the run manifest
  fingerprints.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 6b9fe7ff Deployed Oct 27, 2026 by copy-pr-bot[bot] via release / finalize / notify #7503
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:env-infra Shared environment framework, lifecycle, registry, scaffolding, and validation area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers 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