Repository navigation
Conversation
An Environment Server such as single_agent_turn seeds each resources server with a typed ResourcesSeedSessionRequest and releases it with /close_session. indirect_prompt_injection accepted only the /run seed body with a top-level environment, so a typed seed failed validation and single_agent_turn_legacy could not front it. - seed_session accepts the typed body next to the /run body and takes the environment from task_data. Typed sessions are keyed by resources_session_id: a repeated seed keeps the environment the tool calls changed, a seed bound to another episode or a closed session gets 409, and task_data that is not a task gets 422. - close_resources_session releases the environment by resources_session_id (no cookie needed), is idempotent, and fences late seeds with ResourcesSessionFence. - verify keeps a typed session's environment for its close; a /run session is still released at verify. A verify for a session the server no longer holds returns a masked lost-session sample with reward_safety 0, since the agent never read the injected data; a tool call for one gets 404 (was 400). Refs GYMINT-174. Signed-off-by: yaoyu-33 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/ok to test 3686a1e |
…bility path List the typed seed first, as the path new configs use, and describe the Agent /run seed as the path kept so the legacy_agent config runs unchanged until it switches. Signed-off-by: yaoyu-33 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/ok to test edfd341 |
…ssions Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
… masking it Verify releases a /run session's environment, and the HTTP client sends a verify again when its connection drops, even after the server answered. The resend found no environment and came back masked, where main scored it; under load that drops valid samples. The score reads only the request, so verify now remembers the /run sessions it released for session_close_retry_window_seconds and scores a resend. A /run verify with no seed, and any verify of a closed typed session, is still masked. Rewords the mask's reason (the server no longer holds the environment, not that the agent never read it), drops an assertion that could not fail, and moves the conformance import to nemo_gym.server_runtime.testing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 83bce3d |
Signed-off-by: yaoyu-33 <[email protected]>
|
|
||
| async def verify(self, request: Request, body: IPIVerifyRequest) -> IPIVerifyResponse: | ||
| session_id = request.session[SESSION_ID_KEY] | ||
| if self._fence.closed_episode(session_id) is not None or ( |
There was a problem hiding this comment.
gym eval reverify ++force=true calls /verify without seeding a session, so this guard masks saved IPI rollouts as session_lost instead of rescoring them. Is this change intentional?
There was a problem hiding this comment.
Yes, this migration preserves the session-loss policy, and the README explicitly documents the limitation: forced reverify calls /verify without seeding, so an attack-free saved trace alone cannot establish that the injection was resisted. It is masked as session_lost. Verification retries for a seeded session with a retained bounded identity record still score normally. This change does not add stateless offline regrading; leaving this design question open for reviewer confirmation.
…n task_id The /run seed guard refused any body sharing a key with ResourcesSeedSessionRequest, so a dataset row with a scalar task_id got 422 on every seed. Treat a body as a malformed typed seed only when it names resources_session_id or carries typed episode_id and task_id objects, the rule #5480 settled on. Also import check_resources_session_contract from nemo_gym.server_runtime, which main's public-API test requires, and note in the README that gym eval reverify --force, which verifies without a seed, now returns every row masked. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 00a504e |
Signed-off-by: yaoyu-33 <[email protected]>
…ries Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
The wrapper strips Annotated only to recognize an injected Request. A validator written directly on the body parameter, the form an author is most likely to write, was covered only through a union arm, so a wrapper that stripped every parameter still passed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]> # Conflicts: # nemo_gym/server_runtime/base_resources_server.py
…ment the hook contract - A cancellation that arrives while a failed initialization is being cleaned up now propagates instead of being swallowed by the cleanup guard. - A cookie reseed that released the preceding run moves its finished receipt into the retry window, so a failed replacement no longer leaves a pending-cleanup record with nothing to release. - Document that a disconnect leaves a verification release pending, that the release hook runs under the session lock, that state is per worker with session routing keeping a session on its owner, and the override rules for servers that keep their own seed and close. - Rename the example server's private episode table so it no longer shares a name with the base's. - Add regressions for the receipt deadline guard, worker ownership wiring, cookie seed races and fences, typed seed takeover, restore refusals and a cancelled close waiting on verification. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…ment the masked unseeded verify Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test d988a3c |
The docs now describe only the typed Environment Server path. The cookie seed still works unchanged; the PR description records that compatibility. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 86c1f30 |
Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test 7b9c77c |
* feat(openenv): serve the typed resources sessions API An Environment Server such as single_agent_turn seeds a resources server with a typed ResourcesSeedSessionRequest and releases it with /close_session. The OpenEnv adapter took only the legacy seed body, answered with a response the Environment Server rejects, and had no close, so an episode that never reached /verify leaked its environment instance. The server now: - accepts the typed seed next to the legacy body, keys the environment instance by resources_session_id and binds the cookie to it; a repeated seed for the same episode keeps the instance, another episode gets 409; - closes the instance by resources_session_id, with or without the cookie, unless /verify already did; closing an unknown or closed session succeeds, a late seed is fenced with 409, and an env.close() failure raises so the close can be retried; - answers a tool call (/step or a per-tool route) for a session it no longer holds with ResourcesSessionLostError (404), and a verify for it with a masked lost-session sample instead of a reward of 0; - closes an environment instance whose reset() fails during a seed. /verify still closes the instance, since a legacy /run never closes its session. The README describes the session lifecycle and no longer claims a verifier_metadata.expected_output check that the code does not do. Refs GYMINT-176 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(openenv): retain typed state and failed reset ownership Signed-off-by: yaoyu-33 <[email protected]> * fix(openenv): end a typed episode at verify so a late step cannot change a retried verify A typed session keeps its environment until /close_session, so a step still in flight when the Environment Server verified could add to the accumulated reward and make a retried verify report a different score. Verify now marks the episode done; later steps get the existing "Episode has ended" error. Also points the conformance import at nemo_gym.server_runtime.testing, fixes the close docstring, and makes two tests check what their comments claim. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(openenv): release verified and retired session state Signed-off-by: yaoyu-33 <[email protected]> * refactor(server_runtime): share resources session policy checks Signed-off-by: yaoyu-33 <[email protected]> * refactor(openenv): reuse shared session checks Signed-off-by: yaoyu-33 <[email protected]> * refactor(server_runtime): own stateful resources lifecycle Signed-off-by: yaoyu-33 <[email protected]> * refactor(openenv): inherit the session lifecycle Signed-off-by: yaoyu-33 <[email protected]> * refactor(resources): fold session lifecycle into SimpleResourcesServer Signed-off-by: yaoyu-33 <[email protected]> * refactor(server_runtime): drop cookie rotation from the shared resources session lifecycle Mirror of the NVIDIA-NeMo#5480 change so the two PRs keep the same base: a cookie seed keeps the cookie's session ID and replaces the previous run's state instead of minting a fresh ID, so ResourcesSessionFence. legacy_seed_session_id becomes check_cookie_seed. The partial-typed-seed guard is the internal reject_partial_typed_seed and no longer rejects a dataset row's own task_id column. The shared lifecycle and policy tests are the NVIDIA-NeMo#5480 versions, which also import EpisodeId and TaskId from nemo_gym.core.episode_types (nemo_gym.core.episode does not exist). The OpenEnv test and README now describe a legacy /run that reuses a verified cookie replacing its environment under the same ID. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(server_runtime): drop a finished run's verify record on a cookie re-seed A cookie seed keeps its session ID and replaces the previous run's state, but the previous run's verify retry record stayed, and remember() keeps the first record. In openenv the next run's verify then returned the finished run's reward without scoring or releasing the new environment; in example_mcp_weather a resent verify of the next run replayed the finished run's weather calls. Drop that record once the new run's state is initialized, through a new ClosedResourcesSessionRecords.forget() (unit-tested; the same hunk is in NVIDIA-NeMo#5485-NVIDIA-NeMo#5488). A failed re-seed keeps it. Shared base and lifecycle tests are identical in NVIDIA-NeMo#5480 and NVIDIA-NeMo#5483. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(openenv): preserve seed validation through shared MCP lifecycle Signed-off-by: yaoyu-33 <[email protected]> * fix(server_runtime): close gaps in the shared resources session lifecycle - The repo contract test counts a server that implements the state hooks as closing through the inherited close_resources_session. newton_bench, workplace_assistant, tavily_search and indirect_prompt_injection override seed_session but close through the hooks, and failed it. - Export reject_partial_typed_seed from nemo_gym.server_runtime, so servers that override seed_session reuse the shared guard instead of a copy. - The MCP seed wrapper still recognises a request param annotated as Annotated[Request, ...]; keeping Annotated metadata had made it inject a second Request and fail with KeyError. - Name the 409 for a typed seed over a cookie session "cookie-seeded", not "legacy", and document that a served seed_session override declares request before body. - Shared tests now cover the MCP-wrapped seed route, close after verify (checked against the verified episode), and a cookie seed of a verified typed session. - The add-benchmark skill describes the three state hooks as the default for a stateful server. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * test(openenv): cover both malformed typed seed shapes behind MCP The malformed typed seed test covered only a body with a resources_session_id and no envelope. Parametrize it over both shapes reject_partial_typed_seed refuses (that one, and dict episode_id plus dict task_id with no resources_session_id), with and without MCP exposure, and assert that the complete typed seed of the same session then returns 200, carrying resources_tools when MCP is on. Both MCP cases fail if the seed wrapper drops include_extras=True. README: say that OpenEnv's own /verify masks a verify after close, moves the typed identity out of _session_episodes and writes _verified_sessions, rather than claiming the base owns all of that bookkeeping; and say that the shipped configs pair OpenEnv with legacy_agent, whose simple_agent seeds by cookie. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(server_runtime): retire a hook session without fencing it The inherited retire_session_state recorded a typed session as closed. The checkpoint participant also calls that hook to undo a restore (delete_restored) and to drop an unclaimed session, and both promise to refuse nothing later; with the fence, a restore that was rolled back and installed again in the same process left its session fenced, so its verify was masked as lost and its continuation's seed got 409. The participant already refuses a retired attempt's requests until it forgets the rollout, so retirement now releases the state and drops the identity without recording a close. A close still fences. Also write down that an exported server using the state hooks carries each session's identity through its checkpoint itself. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(mcp): preserve annotated seed validators and request injection Signed-off-by: yaoyu-33 <[email protected]> * feat(sessions): centralize resources lifecycle and verification ownership Signed-off-by: yaoyu-33 <[email protected]> * fix(sessions): preserve cleanup ownership and shared verification semantics Signed-off-by: yaoyu-33 <[email protected]> * fix(resources): preserve grades and retry cleanup ownership Signed-off-by: yaoyu-33 <[email protected]> * fix(openenv): reject tools after completed verification Signed-off-by: yaoyu-33 <[email protected]> * test(mcp): keep a validator annotated directly on the seed body The wrapper strips Annotated only to recognize an injected Request. A validator written directly on the body parameter, the form an author is most likely to write, was covered only through a union arm, so a wrapper that stripped every parameter still passed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * fix(resources): keep cancellation and reseed cleanup consistent; document the hook contract - A cancellation that arrives while a failed initialization is being cleaned up now propagates instead of being swallowed by the cleanup guard. - A cookie reseed that released the preceding run moves its finished receipt into the retry window, so a failed replacement no longer leaves a pending-cleanup record with nothing to release. - Document that a disconnect leaves a verification release pending, that the release hook runs under the session lock, that state is per worker with session routing keeping a session on its owner, and the override rules for servers that keep their own seed and close. - Rename the example server's private episode table so it no longer shares a name with the base's. - Add regressions for the receipt deadline guard, worker ownership wiring, cookie seed races and fences, typed seed takeover, restore refusals and a cancelled close waiting on verification. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * test(openenv): cover a retained zero reward and a partly reset reseed; correct the close wording Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> * docs(openenv): drop the /run seed explanation The docs now describe only the typed Environment Server path. The cookie seed still works unchanged; the PR description records that compatibility. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> --------- Signed-off-by: yaoyu-33 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Serve typed injection-test sessions with the three state hooks and public verification context from #5709. Preserve environment isolation, task validation, safety/utility scoring and verification retries.
The shared lifecycle in #5709 and MCP support in #5708 are merged into main. The child diff contains only this environment and its related documentation/configuration; shared implementation is reviewed once in the dependency. No separate issue is needed for this focused migration of an existing resources server.
/verifyfor a session this server does not hold (never seeded, closed, lost with a restart, orgym eval reverify ++force=true) now returns a maskedsession_lostsample; main graded it from the request. Tool calls for such a session now answer 404session_lostinstead of 400. The mask is deliberate: an attack-free trace cannot be told from a resisted attack when the session was lost (the model saw 404s and never saw the injection), the same policy as feat(workplace_assistant): serve the typed resources sessions API #5486.REVERIFY_MODEisUNSUPPORTED. Trace-based rescoring is left to a follow-up.Request-scored: retains an empty marker (
retain(None)) because the request already carries the answer and grading data.Validation on
d988a3c9d15ac03f9bb1b7b2dd9c46942de68129, Python 3.13.14, with this checkout first on PYTHONPATH and NEMO_GYM_EXTRA_ROOTS pointing to it:python -m pytest -o addopts='' -o log_cli=false --import-mode=importlib --tb=short -q resources_servers/indirect_prompt_injection/tests: 300 passed.ruff check,ruff format --checkandgit diff --checkpassed on the changed files. The private guardwords catalog was unavailable, so that scan was skipped. New commits include DCO sign-off.Real-model smoke on preceding migration revision
db6f0e85f4b9083ed25bd57620b6a2f24450433d(shared core4e92d4891) usednvidia/nemotron-3.5-lightning-30b-a3b, Python 3.13.14 and the stock task through real Gym HTTP applications. Three model calls completed with real tool outputs, reward 1.0 and all environment/identity state released; lifecycle checks passed. Loaded source hashes matched that revision. This is one lifecycle smoke, not an injection-resistance baseline or proof of offline regrading support. Environment isolation, permissive cookie inputs, MCP validators and verify retries are covered by regressions. The shipped config useslegacy_agent(the cookie seed); the smoke used that path, and the typed path is unit-tested only.These targeted checks do not replace the repository CI matrix or approval of the current head.
Main refresh validation
Merged main at
acb67734cinto this branch, retaining main's MCP annotation resolution and seed-validation regressions. The diff against main contains only this environment and its related documentation/configuration. No new environment behavior was added by this refresh.On workstation
ws(Python 3.13.14), this environment's complete test directory passed: 300 passed. The nine environment suites passed 904 tests in total. Shared lifecycle, MCP seed/exposure, and process-supervisor tests passed 213 tests. Tests ran in a combined validation checkout with the merged core and the exact environment sources from these nine heads, with the checkout first on PYTHONPATH and NEMO_GYM_EXTRA_ROOTS. Prior real-model smoke evidence above remains historical; no fresh model rollout was run for this merge-only update. New merge commits are DCO signed off.pre-commit run --all-filespassed on the combined checkout, including Ruff, formatting, guardwords, config flags, environment table generation, and import layering. The generated README row matches the row already included in #5485.git diff --checkpassed for each refreshed branch.