Skip to content

feat(agent): honor skip_verification in six agents that ignored the global flag - #4154

Draft
arendu wants to merge 2 commits into
mainfrom
adithyare/gym-skip-verification-agents
Draft

arendu wants to merge 2 commits into
mainfrom
adithyare/gym-skip-verification-agents

Conversation

@arendu

@arendu arendu commented Oct 7, 2026 •

Copy link
Copy Markdown

Branch: adithyare/gym-skip-verification-agents (based on Gym main bbb0c58e)

Motivation

skip_verification: bool / skip_verification_reward: float are declared on
BaseResponsesAPIAgentConfig (nemo_gym/base_responses_api_agent.py) and
injected into every agent config by nemo_gym/global_config.py. On-policy
distillation (OPD) runs set skip_verification=True globally because the
teacher, not the verifier, produces the training signal: the policy rollout is
collected, /verify is skipped, and the fixed skip_verification_reward is
reported with verification_skipped: True.

simple_agent and tool_simulation_agent already honor the flag on main, but
six agents accept the config fields (inherited from the base config) and then
silently ignore them: they call /verify unconditionally. Under OPD this
either wastes verifier/judge compute or fails outright when the resources
server's verifier is not provisioned for that run.

This PR ports the per-agent skip_verification handling that already shipped
in our training fork (Gym 14317ecb5) onto main. Main and that fork have no
common merge-base, so the hunks were re-applied by hand against main's current
code, following the style of simple_agent/app.py on main.

No issue is linked: the base config already documents the flag and these
agents simply did not implement it.

Per-agent changes

All six configs inherit BaseResponsesAPIAgentConfig, so no config-class
changes are required; the fields were already accepted, just unused.

Agent Change
responses_api_agents/opencode_agent/app.py In run(), when skip_verification is set, build verify_json from the run request + agent response with the fixed reward and verification_skipped: True instead of POSTing /verify. turns_used / finished_naturally / observability fields are still attached.
responses_api_agents/finance_agent/app.py In _run_inner(), return a FinanceAgentVerifyResponse echoing the verify request with the fixed reward before the /verify call. aggregate_metrics() falls back to the base-class implementation (which warns and returns empty metrics) instead of proxying to the resources server when verification is skipped, mirroring simple_agent.
responses_api_agents/scicode_agent/app.py In run(), after assembling solutions, response, token_usage_version and step_usage, return that dict with the fixed reward instead of calling /verify. All sub-steps are still generated.
responses_api_agents/image_tools_agent/app.py In run(), substitute the fixed reward for the verifier's base reward; the image-tool aux reward is still layered on top, so reward = skip_verification_reward + image_tools_aux_reward and base_reward is the fixed value.
responses_api_agents/non_executing_simple_agent/app.py Same shape as finance_agent: short-circuit /verify in run() and fall back to base aggregate_metrics() under skip.
responses_api_agents/conversational_tool_use/simulation/app.py In run(), return the echoed verify request with the fixed reward and mark the session as not needing discard (the resources server session completed normally). ConversationalToolUseAgentVerifyResponse.require_result_for_scored_rollout now also accepts a response with verification_skipped=True and no typed result, since no judge ran. aggregate_metrics() falls back to the base implementation under skip.

The aggregate_metrics fallback for the three agents that proxy aggregation to
the resources server (finance, non-executing, conversational tool-use) is a
small addition beyond the literal fork hunks: it matches what simple_agent
does on main and avoids asking a resources server to aggregate rows it never
scored.

Tests

One unit test per agent, each asserting that under
skip_verification=True, skip_verification_reward=0.25:

  • the run returns reward == 0.25 and verification_skipped is True,
  • the model/agent response is still present in the result,
  • the only outbound calls are /seed_session and /v1/responses (the mocked
    server_client.post raises on any other path, so a stray /verify or
    /discard_session fails the test).

Files:

  • responses_api_agents/opencode_agent/tests/test_app.py::TestSkipVerification::test_run_skip_verification_uses_configured_reward
  • responses_api_agents/finance_agent/tests/test_app.py::TestRun::test_run_skip_verification_uses_configured_reward
  • responses_api_agents/scicode_agent/tests/test_app.py::TestApp::test_run_skip_verification_uses_configured_reward
  • responses_api_agents/image_tools_agent/tests/test_app.py::test_image_tools_agent_skip_verification_uses_configured_base_reward
  • responses_api_agents/non_executing_simple_agent/tests/test_app.py::TestApp::test_run_skip_verification_uses_configured_reward
  • responses_api_agents/conversational_tool_use/simulation/tests/test_app.py::test_run_skip_verification_uses_configured_reward_without_verify

Agent-specific assertions: scicode still generates every sub-step and keeps
solutions / token_usage_version; image_tools reports base_reward == 0.25,
image_tools_aux_reward == 0.0, reward == 0.25; conversational tool-use
yields result is None, no transient-failure marker, and
instance_config == {"mask_sample": False}; opencode reports
turns_used == 1 and finished_naturally is True.

Validation performed

  • ruff check on the 12 touched files: passes.
  • ruff format --check on the 12 touched files: already formatted.
  • python3 -m py_compile on all touched files: passes.
  • pytest (Python 3.13.14, uv sync --frozen --extra dev env, each agent's
    test file run in isolation with the agent dir on PYTHONPATH, mirroring
    gym env test; image_tools additionally needs pillow numpy scipy requests
    from its requirements.txt):
    • finance_agent/tests/test_app.py: 68 passed
    • non_executing_simple_agent/tests/test_app.py: 5 passed
    • scicode_agent/tests/test_app.py: 44 passed
    • image_tools_agent/tests/test_app.py: 4 passed
    • opencode_agent/tests/test_app.py: 32 passed
    • conversational_tool_use/simulation/tests/test_app.py: 37 passed
  • pre-commit run --all-files was not run (no pre-commit in the throwaway
    env); ruff check/format cover the Python hooks for the touched files.

Rollout evidence: N/A for this draft. The change is a pure short-circuit ahead
of the /verify call and does not alter the rollout itself; the fork version
of these hunks has been exercised in OPD training runs. A real smoke rollout
with skip_verification=true on at least one of these agents should be
recorded before the PR is marked ready for review.

Review follow-ups

Copilot flagged two session leaks in the first revision (PR #4154 comments
4222309268 and 4222309372). Both premises were verified against the code on
main; both also existed in the fork version of these hunks (14317ecb5), which
had no finance cleanup endpoint either.

  1. conversational_tool_use/simulation: the skip path set
    session_needs_discard = False, but the resources server only drops
    session_id_to_state in /verify or /discard_session
    (resources_servers/conversational_tool_use_simulation/app.py
    discard_session / verify). Fix: the skip path no longer clears the flag,
    so the existing finally posts /discard_session with the session cookies.
    The regression test now expects /seed_session, /v1/responses,
    /discard_session (with session_id=session-1) and still fails on any
    /verify call.

  2. finance_agent: finance_sec_search and finance_agent_v2 allocate
    _data_storage / _session_start_times in seed_session and freed them
    only in verify; neither server had a cleanup-only endpoint. Fix: add a
    discard_session(request) -> DiscardSessionResponse method and
    POST /discard_session route to both servers (registered ahead of their
    /{tool_name} catch-all), releasing exactly the two per-session dicts that
    verify releases and nothing else. FinanceAgent._run_inner calls it with
    the rollout's session cookies before returning the fixed reward. Tests:
    agent test expects /discard_session after /v1/responses with
    {"session": "seeded"} and still rejects /verify; each resources server
    gains test_discard_session_releases_seeded_state_without_judging
    (seed, populate storage, discard -> both dicts empty, server_client.post
    never called, second discard is a no-op).

The other four agents were checked for the same class of leak. Their in-repo
resources servers keep no per-session state across seed/verify: scicode,
image_tools, structured_outputs (non-executing agent) and
terminal_multi_harness use the base seed_session; vibench (opencode)
returns the PRD text from seed_session and stores nothing. opencode_agent
and non_executing_simple_agent are generic harnesses, so a stateful
resources server paired with them in the future would need the same
/discard_session treatment; that caveat already applies to simple_agent's
skip path on main and is out of scope here.

Follow-up validation (same throwaway env, per-dir PYTHONPATH; finance
resources servers additionally need their requirements.txt):
ruff check / ruff format --check on the 8 touched files pass;
finance_agent/tests/test_app.py 68 passed;
conversational_tool_use/simulation/tests/test_app.py 37 passed;
resources_servers/finance_sec_search/tests/test_app.py 79 passed;
resources_servers/finance_agent_v2/tests/test_app.py 114 passed;
resources_servers/conversational_tool_use_simulation/tests/test_app.py
35 passed (unchanged, sanity).

Compatibility

  • Default behavior (skip_verification=False) is unchanged for all six agents.
  • No config schema changes; the fields were already present on the base config.
  • NeMo-RL needs no code change; it only needs a later Gym submodule bump to
    pick this up.

🤖 Generated with Claude Code

@copy-pr-bot

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

@arendu
arendu requested review from bxyu-nvidia and yfw October 7, 2026 05:49
@arendu
arendu marked this pull request as ready for review October 8, 2026 16:55
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 8, 2026 16:56
@arendu
arendu force-pushed the adithyare/gym-skip-verification-agents branch from ae4cc9b to 3295f6a Compare October 8, 2026 17:21
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 8, 2026 17:22
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Oct 8, 2026
@arendu
arendu requested a balanced review from Copilot October 8, 2026 17:41

Copilot AI 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.

🟡 Changes recommended

The finance and conversational skip paths bypass required session cleanup, causing unbounded resource-state retention.

2 open findings
What changed in this PR

Adds global skip_verification support to six agents so training runs can collect rollouts without invoking verifiers.

Changes:

  • Return configured skip rewards while preserving rollout outputs and metadata.
  • Bypass resource-server metric aggregation in three agents.
  • Add skip-verification regression tests for all six agents.
File Description
responses_api_agents/​scicode_agent/​tests/​test_app.py Tests skipped verification and preserved sub-step outputs.
responses_api_agents/​scicode_agent/​app.py Returns skip reward after generating solutions.
responses_api_agents/​opencode_agent/​tests/​test_app.py Tests skip reward and rollout metadata.
responses_api_agents/​opencode_agent/​app.py Conditionally bypasses verification.
responses_api_agents/​non_executing_simple_agent/​tests/​test_app.py Tests skip reward and retained response.
responses_api_agents/​non_executing_simple_agent/​app.py Bypasses verification and metric proxying.
responses_api_agents/​image_tools_agent/​tests/​test_app.py Tests configured base reward under skip.
responses_api_agents/​image_tools_agent/​app.py Substitutes base reward while retaining auxiliary rewards.
responses_api_agents/​finance_agent/​tests/​test_app.py Tests skip reward and outbound calls.
responses_api_agents/​finance_agent/​app.py Bypasses verification and metric proxying.
responses_api_agents/​conversational_tool_use/​simulation/​tests/​test_app.py Tests skipped responses without judge results.
responses_api_agents/​conversational_tool_use/​simulation/​app.py Adds skip handling and relaxes result validation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +364 to +365
if self.config.skip_verification:
session_needs_discard = False

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Confirmed: only /verify or /discard_session drops session_id_to_state, so clearing the flag leaked each skipped session (the super-v3.5 fork had the same bug). Fixed in b7d8a62: the skip path leaves session_needs_discard set so the existing finally posts /discard_session with the rollout cookies. The regression test now expects /seed_session -> /v1/responses -> /discard_session (asserting the seeded cookie) and still fails on any /verify.

Comment on lines +532 to +533
if self.config.skip_verification:
return FinanceAgentVerifyResponse.model_validate(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Confirmed: both finance servers freed _data_storage / _session_start_times only in verify and had no cleanup route. Fixed in b7d8a62: added POST /discard_session to finance_sec_search and finance_agent_v2 (registered ahead of the /{tool_name} catch-all) releasing exactly what verify releases, and FinanceAgent calls it with the session cookies before returning the fixed reward. The agent test now expects /discard_session and rejects /verify; each server gains a test that discard frees the seeded state without a judge call and is idempotent. Checked the other four agents in this PR: their resources servers keep no seed-to-verify state, so no further leaks of this class.

@yaoyu-33 yaoyu-33 added area:agent Agent harnesses and Responses API agent behavior bug Something isn't working complexity:high Cross-component or shared-contract change with a large review surface needs-review PR is ready for code review and waiting on a reviewer labels Oct 8, 2026
arendu and others added 2 commits October 8, 2026 14:20
skip_verification / skip_verification_reward are declared on
BaseResponsesAPIAgentConfig and injected globally, and simple_agent and
tool_simulation_agent already honor them. Six agents accepted the fields
(inherited from the base config) but still called /verify unconditionally:
opencode_agent, finance_agent, scicode_agent, image_tools_agent,
non_executing_simple_agent and conversational_tool_use/simulation.

On-policy distillation runs set skip_verification=True globally because the
teacher, not the verifier, supplies the training signal, so these agents
either burned verifier/judge compute or failed when no verifier was
provisioned.

Port the per-agent skip handling from the training fork (Gym 14317ec)
onto main. The fork and main share no merge-base, so the hunks are
re-applied by hand against main's current code in the style of
simple_agent: when the flag is set, skip the /verify POST and return the
verify request echoed back with the fixed reward and
verification_skipped=True. image_tools_agent still layers its aux reward on
top of the fixed base reward. conversational_tool_use's verify-response
validator accepts a skipped response with no typed judge result, and the
three agents that proxy aggregate_metrics to the resources server fall back
to the base implementation under skip, as simple_agent does.

Add one unit test per agent asserting the fixed reward, the
verification_skipped marker, and that only /seed_session and /v1/responses
are called.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: adithyare <[email protected]>
…n path

Review of #4154 found that two of the ported skip paths leaked per-session
state on the resources server, because only /verify (or an explicit discard)
releases it.

conversational_tool_use/simulation: the skip path cleared
session_needs_discard, so session_id_to_state was never dropped. Leave the
flag set so the existing finally block posts /discard_session with the
rollout's cookies.

finance_agent: finance_sec_search and finance_agent_v2 allocate
_data_storage and _session_start_times in seed_session and freed them only
in verify, and had no cleanup-only route. Add a discard_session method and
POST /discard_session to both servers, registered ahead of their
/{tool_name} catch-all, releasing exactly the two dicts verify releases.
The agent calls it with the session cookies before returning the fixed
reward.

Tests: the agent regression tests now expect /discard_session after
/v1/responses (with the seeded cookies) and still fail on any /verify call;
each finance resources server gains a test that discard frees the seeded
state without touching the judge and is idempotent.

The other four agents in the PR pair with resources servers that keep no
seed-to-verify state (base seed_session, or vibench's stateless seed).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: adithyare <[email protected]>
@yaoyu-33

Copy link
Copy Markdown
Contributor

We’re doing some cleanup of the open PR list. This PR has had no activity for over a month, so I’ve moved it back to draft.

If this change is still needed, please resolve any merge conflicts and mark the PR ready for review again when it’s ready to merge. Thanks!

@github-actions github-actions Bot removed the sla:review-overdue Review response is over the one-business-day SLA label Nov 18, 2026

This branch was previously deployed

1 inactive deployment
public — b7d8a624 Deployed Oct 8, 2026 by copy-pr-bot[bot] via release / finalize / notify #4789
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 bug Something isn't working complexity:high Cross-component or shared-contract change with a large 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.

3 participants