Skip to content

feat(agent_arena): run AgentArena through agent sessions and keep the relay as *_legacy_agent - #5971

Draft
weijiac0619 wants to merge 8 commits into
mainfrom
weijiac/n4p1-agentarena
Draft

weijiac0619 wants to merge 8 commits into
mainfrom
weijiac/n4p1-agentarena

Conversation

@weijiac0619

@weijiac0619 weijiac0619 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #5987 (core: the typed resources seed carries the task's responses_create_params). This branch has the same changes as their own commits, feat(sessions) and fix(sessions); they drop out of the diff once that PR merges.

What and why

AgentArena (benchmarks/agent_arena/config.yaml) ran agentic_turn_simulation_agent behind the deprecated
legacy_agent relay. The agent refused agent sessions, and the resources server only accepted the seed of the
agent's own /run. This PR moves both onto the Environment Server path (single_agent_turn_legacy), as BrowseComp
(#5484, #5489) and the finance stack (#4948, #5491, #5492) did. The relay recipes are kept as *_legacy_agent.yaml
with a deprecation note.

No issue is linked: the work is tracked internally.

Each episode now runs like this:

  1. The Environment Server seeds agentic_turn_simulation with a typed seed. The server builds the session there: it
    picks the row's harness, replays the history into its model of the agent's files, and prepares the simulator's
    prompt.
  2. It opens an agentic_turn_simulation_agent session with a direct HTTP grant to that server. The agent plays the
    turn, calling /harness and /simulate_tool_call through the grant: the grant's URL with the attempt's rollout
    prefix, its headers, and the session's cookies.
  3. The Environment Server closes the agent, calls /verify, then closes the resources session.

The typed seed's task_data is the row without its responses_create_params, but this server needs the history,
tools and instructions at seed. BrowseComp and finance never hit this: their servers need only fields that are
already in task_data. The first commit therefore adds a small core change, below, so the typed seed carries
responses_create_params beside task_data. Nothing benchmark-specific travels between the agent and the server.

Changes:

  • Core (feat(sessions) commit):
    • ResourcesSeedSessionRequest gains an optional responses_create_params.
    • single_agent_turn fills it on the Resources server's seed, dumped the way _verify_body dumps it. Tool
      servers' seeds do not get it, and a seed without the params leaves the key out of its JSON.
    • The base passes it into seed_request_model only when that model declares a responses_create_params field.
      No other server declares one today, so every other server's task_data validates as before. A seed without the
      field, from an older caller, still validates.
  • resources_servers/agentic_turn_simulation/app.py: sessions use the base session hooks from feat(sessions): centralize resources lifecycle and verification ownership #5709
    (has_session_state, initialize_session_state, release_session_state, verifying).
    • A typed seed binds the session to its episode and task and builds it from task_data plus
      responses_create_params. A typed seed without responses_create_params is refused (422).
    • /harness, /simulate_tool_call, /verify and close take the session lock.
    • Close is idempotent. A /harness or /simulate_tool_call after close or verify answers 404 (session_lost).
      A /verify after close is masked.
    • /verify keeps its whole result, bound to a hash of the request. The same request sent again, after a lost
      reply, returns the first result without calling the judge again. A masked result (no usable judge verdict, say)
      is not kept, so the same request sent again is scored again. Another request for the session is scored with
      the call counts the session left.
    • The /run seed (flat row, cookie) still builds the session at seed, and its /verify releases it.
  • responses_api_agents/agentic_turn_simulation_agent/app.py: serves agent sessions.
    • A seed without a direct HTTP grant is refused (422).
    • The episode loop, the Cline XML protocol, the stop tools and the output-budget handling are unchanged.
    • /run still calls the configured resources server.
    • _close_agent_session_state only calls super(). It is declared because test_session_contract_repo requires
      the close of an agent that defines _seed_agent_session_state.
  • nemo_gym/config/global_config.py: agentic_turn_simulation_agent is added to AGENT_SESSION_AGENT_TYPES.
  • Configs:
    • benchmarks/agent_arena/config.yaml and the environment's own configs/agentic_turn_simulation.yaml use
      single_agent_turn_legacy with resources_tool_transports: [direct_http].
    • benchmarks/agent_arena/config_legacy_agent.yaml and configs/agentic_turn_simulation_legacy_agent.yaml keep
      the relay, unchanged apart from the deprecation note.
    • The README environment table picks up the new config (generated by the pre-commit hook).
  • READMEs for the server and the agent describe the session path.

Compatibility

  • --benchmark agent_arena and gym env start --resources-server agentic_turn_simulation now run the session path.
    --benchmark agent_arena/config_legacy_agent and configs/agentic_turn_simulation_legacy_agent.yaml run the
    relay as before.
  • Instance names, the dataset path, num_repeats: 4, prompts and scoring are unchanged.
  • The environment's own config moved to sessions too, as BrowseComp and finance moved both of their pairings.
    Does anyone train with configs/agentic_turn_simulation.yaml today? If so, that setup should either switch to
    configs/agentic_turn_simulation_legacy_agent.yaml or be checked on the session path first. Training was not run
    here; see Known limits.
  • Failure accounting follows the Environment Server. A turn that ends on a model or agent error becomes a failure row
    (retried within the attempt budget) instead of whatever the relay returned. A time-capped turn is still masked by
    /verify (agentic_turn_simulation:time_cap).
  • Core: the typed resources seed now carries the task's responses_create_params, the same payload /verify
    already receives. A Resources server from an older Gym refuses that seed (its seed request forbids unknown
    fields), so the Environment Server and its Resources server must run from the same Gym version. Details in feat(sessions): carry the task's responses_create_params on the typed resources seed #5987.

Validation

Unit tests

New and changed tests:

  • tests/unit_tests/server_runtime/test_typed_seed_responses_create_params.py, 4 tests:
    • a seed model that declares responses_create_params gets them;
    • without them the field stays unset;
    • a model that forbids unknown fields validates task_data exactly as before;
    • a seed without them leaves the key out of its JSON.
  • environment_servers/single_agent_turn/tests/test_app.py: the Resources seed carries responses_create_params,
    and the tool-server seed's JSON has no such key.
  • resources_servers/agentic_turn_simulation/tests/test_sessions.py, 8 tests:
    • check_resources_session_contract on the typed seed;
    • the session built at seed and driven with a body-less /harness;
    • a typed seed without the params refused;
    • a resent verify returning the first result with one judge call;
    • a resent verify whose judge failed being judged again;
    • close and late calls;
    • restart-only checkpointing: the seed reply carries x-ng-checkpoint-restart: 1, and the restarted attempt
      seeds a fresh session;
    • the /run seed.
  • responses_api_agents/agentic_turn_simulation_agent/tests/test_app.py, 6 session tests:
    • calls go to the grant URL with its headers and cookies;
    • a restored attempt uses its own rollout prefix;
    • a Cline row's protocol comes from the grant's /harness;
    • a session without a grant is refused;
    • a seed without a grant gets 422;
    • an episode through /v1/agent_sessions, /v1/responses and close.
  • benchmarks/agent_arena/tests/test_configs.py: both configs resolve, and each binds the expected Environment
    Server type to the same agent.

Run at the head commit:

  • resources_servers/agentic_turn_simulation/tests, responses_api_agents/agentic_turn_simulation_agent/tests,
    benchmarks/agent_arena/tests, tests/unit_tests/server_runtime, tests/unit_tests/config/test_global_config.py
    (including the AGENT_SESSION_AGENT_TYPES consistency test), tests/unit_tests/test_public_api_facades.py,
    tests/unit_tests/test_session_contract_repo.py, tests/unit_tests/environment/test_benchmarks.py,
    tests/unit_tests/tooling/test_add_legacy_agent_environment_servers.py and
    responses_api_agents/simple_agent/tests: 4215 passed, 2 failed. The 2 failures are
    tests/unit_tests/server_runtime/supervisor/test_component_compatibility.py, which compares an openai pin with
    the version installed in the test venv (2.44.0 against 2.43.0). This PR does not touch that file.
  • environment_servers/single_agent_turn/tests 246 passed, single_agent_turn_legacy/tests 44 passed,
    legacy_agent/tests 12 passed.

Real runs

gym eval run on 3 rows of the Arena validation split, 1 repeat each. The rows are
sandbox-harness turns with 2 to 4 history items and 11 tools. One Nemotron checkpoint, served by vLLM, was the
policy, the tool simulator and the judge. Settings: --max-output-tokens 32768, agent max_time_seconds 1200. The
runs used the commit before the review fixes. Those fixes change only a seed without params (the Resources seed here
always has them), the caching of a masked verify (no row was masked), a config comment and tests, so they were not
rerun.

Config Environment Server Row Reward Stop Steps Calls (answered by) Masked
agent_arena single_agent_turn_legacy 0 1.0 final_message 3 5 (llm 5) no
agent_arena single_agent_turn_legacy 1 1.0 final_message 2 3 (exact 3) no
agent_arena single_agent_turn_legacy 2 1.0 final_message 3 2 (exact 2) no
agent_arena/config_legacy_agent legacy_agent 0 1.0 final_message 3 4 (llm 4) no
agent_arena/config_legacy_agent legacy_agent 1 1.0 final_message 2 2 (exact 2) no
agent_arena/config_legacy_agent legacy_agent 2 1.0 final_message 3 2 (exact 2) no
  • Both runs: 3/3 measured, 0 failed, 0 masked. Rollout quality 3 healthy, 0 unhealthy. 0 of 8 model responses
    faulted.
  • On the session path, "exact" answers to read_file and similar calls show that the typed seed's
    responses_create_params built the session: the workspace was replayed from the row's history at seed, and the
    agent sent nothing but a body-less /harness.
  • An earlier smoke, on the first version of this PR, had one row whose first judge attempt gave no usable verdict.
    The server's own retry succeeded, and Gym's judge-failure recovery then re-verified the row from its saved answer,
    writing a second line for it that aggregation counted once. That is existing Gym behavior. It did not recur here.

Checks

pre-commit run on the changed files passed: ruff, ruff-format, import-linter and the README table hook. The
private guardwords catalog was unavailable, so that hook skipped.

Known limits

  • Harness swaps. The harness can be swapped technically: any agent that drives /harness and
    /simulate_tool_call works, since the session needs nothing from the agent. But the rows are bound to the original
    harness's system prompt, history and tool format. A different harness would change what is being measured, so this
    PR keeps agentic_turn_simulation_agent.
  • Crash recovery. With rollout checkpointing on, a crash restarts the episode rather than continuing it. The
    server declares no checkpoint_mode, so it is restart-only. Its seed reply carries x-ng-checkpoint-restart: 1,
    so single_agent_turn marks the episode as a restart, and after a crash it starts over from its input with a new
    seed and a new session. A half-played turn is never continued against a used workspace.
  • Time cap. fix(agent_arena): treat a time-capped turn as an environment-side failure #5872 turns a time-capped /run turn into a retryable agent_time_cap failure. That PR overrides
    only /run, so on the session path a time-capped turn stays masked until a session equivalent lands. The two PRs
    also touch nearby lines in the agent's app.py and README. The merge order is being coordinated.
  • Scores. The smoke used one Nemotron checkpoint as policy, simulator and judge, not the reference simulator
    and judge setup. No score parity with earlier relay runs is claimed.
  • Training. The session path was not run for training (token-ID capture through agent sessions).
  • Data. Any new data for this benchmark is out of scope. prepare.py still copies whatever turns file it is
    given.

🤖 Generated with Claude Code

weijiac0619 and others added 3 commits November 10, 2026 13:48
An Environment Server seeds the resources session with a typed seed whose task_data is the row without its
responses_create_params, so the server cannot build the history, workspace and simulator preamble at seed time.
The session now uses the base session hooks: a typed seed binds the session to its episode and task and keeps the
row's verifier_metadata, and the agent's first /harness call brings responses_create_params to finish it. The
agent's /run seed (flat row, cookie) still builds the whole session at seed.

/harness, /simulate_tool_call, /verify and close are serialized per session. Close is idempotent; a /harness or
/simulate_tool_call after close or verify answers 404 (session_lost), and a /verify after close is masked. A
retried /verify reports the simulated-call counts the first one saw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
The agent refused agent sessions, so its environment could only run behind the legacy_agent relay. It now serves
them: /harness and /simulate_tool_call go through the session's direct HTTP grant (its URL with the attempt's
rollout prefix, its headers and the session's cookies), and the first /harness call carries the row's
responses_create_params, which the resources server's typed seed does not have. A session seeded without a direct
HTTP grant is refused (422). The episode loop, the Cline XML protocol, the stop tools and the output-budget handling
are unchanged, and /run still calls the configured resources server.

Lists agentic_turn_simulation_agent in AGENT_SESSION_AGENT_TYPES.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
…d keep the relay as *_legacy_agent

benchmarks/agent_arena/config.yaml and the environment's own agentic_turn_simulation.yaml now run each turn as an
Environment Server episode (single_agent_turn_legacy, resources_tool_transports: [direct_http]). The legacy_agent
relay recipes are kept, with a deprecation note, as benchmarks/agent_arena/config_legacy_agent.yaml and
configs/agentic_turn_simulation_legacy_agent.yaml. Instance names, the dataset path and the benchmark identity are
unchanged. A test resolves both benchmark configs and checks the Environment Server each one binds.

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

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

weijiac0619 and others added 3 commits November 10, 2026 14:54
… resources seed

single_agent_turn seeds a resources session with task_data, which leaves out the task's responses_create_params,
then sends them back at /verify. A server whose session is built from the task's history or tools could not build
it at seed.

ResourcesSeedSessionRequest gains an optional responses_create_params, and single_agent_turn fills it on the
Resources server's seed, dumped as _verify_body dumps it. Tool servers' seeds do not get it. The base passes it to
seed_request_model only when the model declares a responses_create_params field; every other server's task_data
validates as before, and a seed without the field (an older caller) still validates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
…ep the whole verify result

The typed seed now carries the row's responses_create_params, so the session is built at seed, as for /run. The
/harness body and the pending-row state are gone, and the agent no longer sends the row: any agent that drives
/harness and /simulate_tool_call can play the turn. A typed seed without responses_create_params is refused (422).

/verify keeps its whole result, bound to a hash of the request: the same request sent again (after a lost reply)
returns the first result without calling the judge again, and another request for the session is scored with the
counts the session left. The obstacle test that verified one request twice on one session now verifies the second
time on an unseeded session.

Adds a test that the server is restart-only under rollout checkpointing: its seed reply carries
x-ng-checkpoint-restart, and the restarted attempt seeds a fresh session. The agent keeps its
_close_agent_session_state override, now commented: test_session_contract_repo requires it of an agent that
defines _seed_agent_session_state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
weijiac0619 and others added 2 commits November 10, 2026 20:31
…s none

A seed without the params (every tool-server seed) dumped them as null, which a
resources server built from an older Gym refuses: its ResourcesSeedSessionRequest
forbids unknown fields. The key is now left out when it is unset, as
ResourcesSeedSessionResponse does for its observation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
…rst result was masked

A verify whose judge gave no usable verdict returns a masked JUDGE_FAILED result.
Keeping it under the request's hash meant the same request, sent again on the
session, always got that masked result back. Only unmasked results are kept now,
so a resend is scored again with the session's call counts.

Also fixes the environment config's comment, which still said the agent's first
/harness call brings the row's history: the typed seed carries it now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: weijia chen <[email protected]>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers labels Nov 16, 2026

This branch has not been deployed

No deployments
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 feature New capabilities, enhancements, or enablement work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants