Repository navigation
feat(resources): answer Environment Server seed and close by default - #3786
Merged
Merged
Conversation
SimpleResourcesServer now serves an Environment Server's typed session calls without overrides. /seed_session accepts a ResourcesSeedSessionRequest and returns the caller's resources_session_id, while an Agent's /run keeps getting the empty legacy response. /close_session is registered in the base and calls close_resources_session, which does nothing by default. A Resources Server without per-rollout state can therefore run through single_agent_turn unchanged; before, its seed reply failed validation and /close_session returned 404. The hook is named close_resources_session so it does not expose the close_session helpers that Gymnasium-based servers already define for their own state. SWE-bench Pro moves its close handler onto the hook, since the base route is registered first and would otherwise shadow a route the server registers itself. Signed-off-by: Ananth Subramaniam <[email protected]>
Contributor
|
🌿 Preview your docs: https://nvidia-preview-ananthsub-resources-session-defaults.docs.buildwithfern.com/nemo/gym Here are the markdown pages you've updated: |
ffrujeri
reviewed
Sep 29, 2026
… seeds With expose_tools_over_mcp on, the seed wrapper added an "mcp" key to every seed reply. An Environment Server validates the reply as ResourcesSeedSessionResponse, which forbids extra keys, so a server that keeps the default seed and opts into MCP failed the seed check. Typed seeds now get the MCP metadata in resources_tools, which single_agent_turn grants to the agent; the per-session tool hook sees the task's fields. Legacy seeds keep the "mcp" key. Signed-off-by: Ananth Subramaniam <[email protected]>
ffrujeri
approved these changes
Sep 30, 2026
ananthsub
enabled auto-merge
September 30, 2026 00:06
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36649153226 |
7 tasks
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36650613718 |
8 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Lets any Resources Server take part in an Environment Server episode without writing session code.
The single-agent-turn Environment Server seeds each episode with a typed
ResourcesSeedSessionRequest, expects the caller'sresources_session_idback, and closes the session through/close_sessionduring cleanup. Onmain, only Resources Servers that implement both calls themselves can run an episode. For every other server, the base/seed_sessionreturns an empty body that fails validation, so the episode fails before verification, and/close_sessionreturns 404.SimpleResourcesServernow answers both calls by default:/seed_sessionaccepts aResourcesSeedSessionRequestand returns itsresources_session_id. An Agent's/runstill seeds with its legacy body and still gets the empty response, so existing agents are unaffected./close_sessionis registered in the base and callsclose_resources_session, which does nothing by default.A Resources Server with per-rollout state overrides
seed_session()andclose_resources_session(). The hook is not calledclose_sessionbecause several Gymnasium-based servers (gymnasium,openair_congestion,tales) already define aclose_session(session_id)helper for their own state. Registering that name would have exposed those helpers as HTTP routes with the wrong signature.SWE-bench Pro, the only server on
mainwith its own/close_session, moves its handler onto the hook. The base route is registered first, so a route the server registered itself would never be reached. Its behavior is unchanged: the same handler still accepts both the typed close and the empty cookie-session close thathermes_sandboxed_agentsends.The Resources Server API guide describes the defaults and when to override them.
Issue
No issue is linked. This fills a gap found while reviewing the Environment Server stack (#3720).
Validation
pytest tests/unit_tests/test_base_resources_server.py -q: 14 passed. A new HTTP-level test checks that a server with no session code answers a typed seed with itsresources_session_id, a legacy seed with an empty body, and a typed close. It fails onmain.pytest resources_servers/swebench_pro/tests -q: 84 passed, including the HTTP test that sends a typed close, an empty cookie close, and a malformed close to/close_session.gym env testforgymnasium(10),grl_sokoban(9), andtales(10), which define their ownclose_session, and forfinance_sec_search(96), which callssuper().seed_session(); all pass.example_mcp_weather(6) andexample_session_state_mgmt(1) pass.pytest tests/unit_tests -q: passes except two tests that also fail onmainin the local environment (missingsandboxextras and a pip notice).pre-commit runon the changed files.Rollouts
N/A. This adds default responses to two session calls that
main's agents do not make, and moves SWE-bench Pro's close handler without changing its behavior, which its HTTP tests cover. No agent onmainseeds typed sessions yet, so an end-to-end Environment Server episode needs #3784 or #3720.Compatibility
/seed_sessionbodies get the same empty response as before, and servers that overrideseed_session()are unchanged./close_sessionroute after callingsuper().setup_webserver()is shadowed by the base route and must overrideclose_resources_session()instead. Onmainthat applies only to SWE-bench Pro, which this PR migrates. #3784 also registers one for the example single-tool-call server. Whichever of the two PRs merges second should move that server onto the hook.