Repository navigation
feat(Search OpenCode): run the OpenCode preset through Environment Server sessions - #6211
Conversation
A sandbox session's opencode_config accepted compaction.auto but refused every other compaction key, so a benchmark could not choose where OpenCode's automatic compaction starts. OpenCode compacts after a call whose tokens reach the model's input limit minus compaction.reserved; unset, that buffer is the smaller of 20000 and the output limit. With the default max_output_tokens, a session with context_window 262144 therefore compacted at 242,144 tokens, and a benchmark that relies on an earlier trigger could not keep it on the session path. The session allowlist now also accepts compaction.reserved when it is a positive integer, and the session passes it to OpenCode unchanged. It moves only the trigger point and rewrites no history. compaction.prune stays refused, because it rewrites old tool output. A zero, negative, non-integer, boolean or string value is refused at seed with 422, as agent.build.steps is. A configuration without the key produces the same OpenCode configuration as before. The README and the harness guide's OpenCode row list the new key, and the README says how it moves the trigger. Tests: a positive value reaches OpenCode's configuration; prune is refused with and without reserved; 0, a negative value, 8000.5, "8000" and true are refused before the sandbox is used. test_sandbox_sessions.py and test_app.py pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…on output A sandbox session converts every assistant message of OpenCode's session into the response output, compaction summaries included. A summary is an assistant message like any other, so a verifier that grades the last assistant text can grade the summary instead of an answer, for example when a run ends on a compaction. Once the summary is a Responses output item, the environment cannot tell it apart from an answer. A new config field, exclude_compaction_summaries (default false), leaves those messages out of the session's response output, and so out of the text a verifier reads. A summary is an assistant message that OpenCode marks summary: true or that its compaction agent wrote. OpenCode 1.17.11 sets both markers and either one is enough, the rule the deprecated opencode_sandboxed_agent applies with its option of the same name. With the field false, the output is built exactly as before. The trajectory returned at close already leaves summaries out, and the compaction record in the observations keeps the summary text either way. The README describes the field under Owner extensions. Tests: for an export that compacts before the final answer, the output keeps the summary with the field off and drops only the summary with it on; a summary that carries only one of the two markers is dropped too. The new tests fail with the summary check disabled. test_sandbox_sessions.py, test_app.py and the rest of the opencode_agent tests pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…ndbox
The server only understood the agent-run seed: an agent's own /run posts
the dataset row with its session cookie and gets back a sandbox_handle.
An Environment Server's episode seed failed validation, and nothing
stopped a sandbox at close or at server shutdown.
Implement the session state hooks, so the base class serves seed, close,
the session lock and the close fence:
- An episode seed keys the session by resources_session_id. Its
task_data must carry question and ground_truth (422 otherwise); an ID
bound to another episode or already closed gets 409; an identical
re-seed returns the same reply. With the new sandbox_workdir set, the
seed lends the sandbox through LentSandboxes (operate descriptor and
workdir) and creates the workdir with a checked command, since
providers need not create it and a harness never prepares a borrowed
one. The lent sandbox has the agent-run sandbox's image, limits, env
(derive_cpu_env honoured) and labels. sandbox_workdir defaults to null,
which keeps lending off, and is validated at startup.
- The agent-run seed builds the same SandboxSpec as before and replies
with {"sandbox_handle": ...}. The override's return annotation names
SearchSeedSessionResponse: FastAPI serializes the reply through it, and
a union of only the base reply models drops the handle, after which the
agent would silently start a sandbox of its own. The sandbox is
registered before it starts, so a failed or cancelled start is stopped.
- verify runs inside verifying(allow_missing=True). A verify after close
is masked as session_lost; the sandbox is still stopped before the
judge; an identical retry replays the grade and a retry with another
body gets 409 (a body digest is retained with the grade). A judge reply
with no parseable verdict is now masked as judge_unparseable instead of
scored 0, and every verify response carries evaluation_completed. The
judge breaker still answers 500.
- Close stops the sandbox by ID through the base route, and a failed
stop raises and keeps it for a retried close. The app lifespan stops
every sandbox still running at shutdown, with shielded, time-bounded
stops.
Also declare the legacy_agent relay that Gym generated for
browsecomp_opencode.yaml (same instance name and block, so the composed
config only loses the deprecation warning), state why the example
config stays on its relay, add sandbox_workdir: null to
opencode_search.yaml, correct the aggregate_metrics docstring (Gym's
aggregate metrics leave masked rows out), and document sessions in the
README.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: abhibhag <[email protected]>
prepare.py writes rows that carry the BrowseComp research agent's system prompt and tool list next to the user turn. A session harness brings its own system prompt and tools: opencode_agent refuses a request that sets `tools`, and it would add the row's system message to its own instructions. prepare_opencode.py writes benchmarks/browsecomp/data/browsecomp_opencode_benchmark.jsonl with rows that hold only the user turn, plus the question and ground_truth fields the opencode_search server validates and grades with. It imports the sample selection, the decryption and QUERY_SUFFIX from prepare.py, so the rows are the same samples in the same order (400 with seed 42, or all 1266 with BROWSECOMP_RUN_FULL=1) and the user turn is byte for byte the one prepare.py writes. prepare.py is unchanged, and the generated file stays gitignored. The test runs both prepare scripts on one synthetic encrypted CSV. It checks that the user turns are byte-identical and in the same order under each BROWSECOMP_RUN_FULL setting, that every request holds a single user message with no tools and no system message, and that the rows validate as rollout inputs and against the opencode_search task-data schema. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…n episode sessions
On the relay path, opencode_sandboxed_agent uploads the OpenCode plugins and
their settings, reads the plugins' "[nemo-gym-plugin]" lines from the run
output, refuses a run whose sentinel is missing, and forwards how the run
ended (opencode_terminal_reason) in the verify body. On an episode session
none of that happens: a session harness such as opencode_agent keeps
OpenCode's stderr private, and the Environment Server's verify body carries
only the task data, the request and the response. Turn-capped rows would
lose their mask, and a run without its plugins would be graded.
Move those duties to the sandbox owner:
- opencode_bundle/nemo_gym_receipts.js is a small owner plugin. When it is
imported it wraps process.stderr.write, the stream the four existing
plugins write to, and also appends every chunk carrying the marker to the
file NEMO_GYM_PLUGIN_LOG names. It registers no hooks, changes nothing the
model sees, and prints "[nemo-gym-plugin] loaded receipts version=1".
- New server settings, all off by default, so a harness that brings no
OpenCode plugins is served as before:
- episode_sandbox_files: absolute sandbox path -> file relative to the Gym
root, read once at startup and staged through the lend (files=). The
four plugins are referenced in place from
responses_api_agents/opencode_sandboxed_agent/plugins/.
- episode_sandbox_env: static environment of the lent sandbox, over
sandbox_config.env; empty values set nothing, as on the relay. With
exa_cache_root set, NEMO_GYM_EXA_BASE_URL defaults to this server's
/mcp proxy, the URL the relay agent derives, and a loopback or
unspecified host is refused at startup, since a remote sandbox could
not reach it.
- plugin_log_path and required_plugin_markers. plugin_log_path also sets
NEMO_GYM_PLUGIN_LOG in the lent sandbox; a NEMO_GYM_PLUGIN_LOG in
episode_sandbox_env must equal it, and markers need a log path, both
checked at startup.
The agent-run sandbox is unchanged.
- With plugin_log_path set, an episode session's verify reads the log from
the lent sandbox before the sandbox stops. It takes the ending with a
server copy of the relay agent's reading (an unrecovered context overflow
outranks max_iteration; no agent timeout is inferred) and puts it on the
verify body, so the existing mapping sets mask_sample and the failure
fields exactly as on the relay path. The response also carries
opencode_plugins_loaded and opencode_plugin_log, and the log is kept with
the verify evidence, so a retry replays or regrades with the same
receipts.
- A log that was read but lacks the sentinel plugin's line or a required
marker is refused with 422, which an Environment Server does not retry.
A missing file counts as an empty log. The receipts plugin's own load
line does not stand in for the sentinel.
- A read that fails raises (HTTP 500), which an Environment Server treats
as retryable, and nothing is retained, so a repeated verify of that
session is masked as lost rather than graded without the log. This is
the relay's behaviour for a run whose output could not be captured; a
masked row would instead stay in the results and count as a wrong answer
in a score that keeps masked rows.
Tests cover the staged files and environment, the ending (including
precedence and recovered overflows), the refusals, a failed read, harness
neutrality, and the startup checks. A Node test exercises the receipts
plugin, and another runs the staged plugins under Node with the lent
sandbox's environment and checks verify's reading of what they wrote. Both
are skipped when Node is not installed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: abhibhag <[email protected]>
… on opencode_search browsecomp_opencode.yaml runs BrowseComp on opencode_search through the deprecated opencode_sandboxed_agent and its legacy_agent relay. The server can now lend its per-question sandbox to an episode session, stage the OpenCode plugins in it and read their log; opencode_agent accepts compaction.reserved and can leave compaction summaries out of its output; and prepare_opencode.py writes user-only rows. This preset puts those together. browsecomp_opencode_sessions.yaml runs opencode_agent through single_agent_turn_legacy, with the relay agent's settings where opencode_agent has them: - The resources server lends the sandbox with /workspace as its working directory, since opencode_agent refuses /, and a TTL above the episode deadline. It stages the receipts plugin and the relay agent's four plugins, unchanged, under /tmp; the relay agent's opencode_env becomes the sandbox environment; and verify reads the plugin log, requiring the search guard's and the turn budget's lines besides the sentinel's. allowed_agents lists only opencode_agent: the model's tools are OpenCode's own, shaped by those plugins, and the server serves none. - The agent, browsecomp_opencode_agent, runs OpenCode 1.17.11 on its stock system prompt with thinking on. It uses the relay's tools map over opencode_agent's permission rules, which resolves as on the relay (webfetch, websearch and task allowed, skill denied), compacts at 192000 of 262144 tokens, leaves compaction summaries out of its output, has a 21600 s run budget and loads the receipts plugin first. It gets a new instance name, because overlays written for the relay agent set fields opencode_agent does not have. - The OpenCode binary and ripgrep are pinned through environment variables without defaults, so a run cannot fall back to a download or a distribution package. The run names the judge's endpoint and model the same way. Neither is written in the repository. - Only the policy model takes the host's address. The agent, the Environment Server and the judge are pinned to loopback; the resources server is left unpinned, so a run with the search cache can give it an address the sandbox reaches. - Admission (64 episodes) matches the agent's per-worker concurrency, and the episode deadline covers the seed, OpenCode's install and run, the agent's close and the judge's retries, within the sandbox's TTL. A run that failed at the context window is graded, as on the relay. The config test composes both presets. It checks the routing, a single Environment Server and no missing values, that every agent and resources setting is one Gym reads, the host pins, timing and admission, and that the sandbox environment, tools map, permission rules, plugins, judge, output cap and rows match the relay preset's. It also runs the staged plugins under Node (skipped without it) to check that they print every line verify requires, checks that an unset pin or judge stops the composition, and checks that the relay preset keeps its explicit relay. The browsecomp README describes both presets, what still differs between them (the working-directory line, the truncation-file path, failure accounting, the web-search key and the artifacts), how to supply the pins, the judge and the web-search key, what a paired comparison needs, and how to wire a scripted smoke. The opencode_search README now describes the plugin log, the supported harnesses and what differs from the relay, and lists the episode settings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…entSandboxes uses The server stops the sandbox of an agent's own /run itself, with the same shielded, time-bounded stop and the same shutdown concurrency that LentSandboxes applies to the sandboxes it lends. It restated both bounds as private constants, so the two could drift apart. Export STOP_TIMEOUT_S and SHUTDOWN_STOP_CONCURRENCY from nemo_gym.server_runtime, beside LentSandboxes, and import them from there: code outside nemo_gym imports public names from a package's public API, never from its submodules. The local shielded-stop wrapper stays, now using the shared bound. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The server checks that a lent sandbox can reach its search cache proxy with reachable_host, which it imported from the defining submodule, nemo_gym.utils.network_policy. Code outside nemo_gym imports public names from a package's public API, and a name the package does not export is added to its _PUBLIC_API rather than imported from the submodule. The facade tests check this only for names already exported, so the import passed CI. Export reachable_host from nemo_gym.utils (its _PUBLIC_API and the matching TYPE_CHECKING import) and import it from there. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…aker and keep a budget ending's kind A judge reply with no parseable verdict is now masked rather than scored 0, which has two consequences this change handles. The dead-judge breaker counted only judges that never answered. A judge that always answers without a verdict (a reasoning judge that spends judge_max_output_tokens thinking, or a misconfigured judge model) now masked every row, and Gym's aggregate leaves masked rows out of the quality scores, so the run burned its wall clock and reported a score over whatever parsed. Both judge failures now count toward judge_max_consecutive_failures, and a parsed verdict still resets it. Recovery re-judges a masked judge_unparseable row from its saved answer, and that payload carries no opencode_terminal_reason. So a run cut off by its turn or context budget whose first judge reply had no verdict came back graded and unmasked, while the same run with a verdict stayed masked. A budget ending now keeps its own failure_kind and failure_reason, which recovery leaves alone; judge_parsed and evaluation_completed still record the missing verdict. judge_unparseable stays the kind for a normal ending. The README also states that a verify grading a saved answer again (gym eval reverify, or recovery after a judge failure) cannot mask a budget ending on either pairing, since the ending is not in its body. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…d read the plugin log as base64 With plugin_log_path set, an episode's grade depends on the plugin log in its sandbox: the log supplies the plugin gate and the turn-cap and context-window masks. A verify for a session this process holds no sandbox or retained evidence for was still graded from its body alone, so the gate and the masks were skipped silently. That happens after a restart, whose shutdown stops every sandbox, when the Environment Server's verify arrives with the old session cookie; a capped run was then saved as a measured, unmasked grade. Mask that verify as session_lost instead. Only an Environment Server's episode verify sends CHECKPOINT_CLOSE_FOLLOWS_HEADER, so a verify without it (the relay agent's, gym eval reverify) is still graded from its body, as before. The log was read as exec stdout with cat. A provider may return a command's output as messages joined by newlines, and a message boundary inside a marker line would split it: a lost terminal=max_iteration grades a capped row unmasked, and a split sentinel or required marker refuses a healthy run with a terminal 422. Read the file with base64 instead; decoding skips every newline. A missing file still reads as an empty log. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…he relay does
The tests behind the relay-arm claims (the seed replies exactly
{"sandbox_handle": ...}, the SandboxSpec matches field for field, and
verify grades, masks a budget ending and stops the sandbox before the
judge) all built the server with sandbox_workdir set. The relay preset
composes opencode_search.yaml with sandbox_workdir: null, so none of
them ran in the relay's own configuration: no LentSandboxes and no
lending branch in release_session_state.
Run each of them with lending off as well as on. Also find the
repository root with Path(__file__).resolve().parents[3], as the
repository's test convention and the sibling server tests do.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: abhibhag <[email protected]>
…indow A session accepted any positive compaction.reserved. OpenCode compacts after a call whose tokens reach context_window minus that buffer, and the session sets limit.input to context_window, so a buffer of the whole window or more leaves no usable input: every call triggers a compaction, and the run loops on compaction calls until its turn budget or timeout ends it. Refuse such a value at the seed with a 422, next to the existing check that max_output_tokens does not exceed context_window. The allowlist check itself is unchanged, so its callers keep their signature. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…allowlist The README said that with token capture on, a session refuses agent.build.steps. The session code accepts it: no check in the allowlist depends on capture, a seed with capture on accepts a step limit, and the paragraph below explains that token capture recognizes OpenCode's step-limit message and joins the calls after it. The claim predates this branch, but the compaction.reserved change re-wrapped the sentence that holds it, leaving it on a touched line that also ran past the paragraph's width. Drop the claim, which also brings the line back within the paragraph's width. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…modules The BrowseComp OpenCode preset test imported ServerClient from nemo_gym.client and get_first_server_config_dict from nemo_gym.config, the packages' public APIs. Tests under tests/ import each name from the module that defines it, so the import-linter contract sees every dependency, and test_public_api_facades enforces it: the core unit suite failed on this file. Import ServerClient from nemo_gym.client.server_client and get_first_server_config_dict from nemo_gym.config.global_config, as the sibling preset tests do. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
…e, workers and the search key - The presets table said /close_session releases the sandbox after /verify reads the plugin log. /verify stops the sandbox before it calls the judge; /close_session then fences the session and releases the sandbox only if verify did not run. The opencode_search README's relay comparison said the same of close and is corrected too. - The opencode_search README said that with lending on the server runs with one worker. It refuses num_workers above 1 at startup instead. - The session preset's header showed the web-search key as a command-line override, which puts the key in shell history and process listings. It now names the config path and points to the README's uncommitted overlay file, as the relay preset does for its key pool. - A comment called the agent's instance name "new"; it now says what the name is for. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The OpenCode session preset allowed webfetch and websearch with the
relay agent's tools map {webfetch: true, websearch: true, task: false}.
opencode_agent asks for permission rules rather than a tools map, and
the map's task: false read as a deny, although OpenCode places the keys
of a tools map ahead of the "*": allow rule, so task resolved to allow.
The preset now sets permission {webfetch: allow, websearch: allow},
which replaces opencode_agent's two web denies in place, after
"*": allow. The decisions are unchanged: webfetch, websearch and task
are allowed and skill denied, as on the relay, and every bash deny is
kept.
The config test now checks that opencode_config holds only permission
and compaction, that the permission rules equal the relay's apart from
the two web keys, and that each pattern map (bash, edit) keeps the
relay's order, since OpenCode applies the last matching pattern. Every
other relay rule, and task, external_directory and doom_loop, must
resolve as on the relay; external_directory and doom_loop must resolve
to allow, because with /workspace as the workdir a read of /tmp or of a
truncated output is an external_directory request.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: abhibhag <[email protected]>
The comment on the session pairing's agent_outcome_policy override said the default policy would leave a run that failed at the context window ungraded. It would not: opencode_agent reports such a run as an incomplete response, and the outcome policy verifies every response that is not failed, so the plugin log then masks the row as context_window. The comment now calls the override harmless and not needed with opencode_agent, kept so a run reported as a failed response of kind model_context_limit is graded too, as on the relay. The config test now pins the pairing's override, and checks that neither the pairing nor the agent sets tool_servers or skip_verification, and that the resources server does not expose tools over MCP. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The session preset's config test asserts that the composed config has
no missing ('???') value; the relay preset's test did not say the same.
Both now do. Composing either preset already refuses a value left unset
(the config parser raises ConfigMissingValuesError), so the assert
records the presets' shared contract next to the relay's other checks.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: abhibhag <[email protected]>
The session preset's comment said its 25200 s episode deadline covered the judge's retries. It does not: the judge's worst case, with call_judge's own retries inside each of the resources server's attempts, is longer than the deadline leaves after a run that used its whole 21600 s budget. The deadline stays at 25200 s, and the comment now says what it covers (the seed with the sandbox start, workdir and OpenCode install, the run, the agent's close, and verify's plugin-log read and sandbox stop), that a slower judge then times the episode out as a non-terminal failure that a resumed run retries, and that a job time limit shorter than the run budget ends such runs first. The comment on ttl_s now says that verify stops the lent sandbox before the judge grades, and that after an episode timeout the cleanup does. The config test's timing check no longer counts the judge. It sums the steps before the judge from the composed settings, each at its bound, including the workdir creation, the plugin-log read and the sandbox stop (STOP_TIMEOUT_S), and requires that sum to fit in the deadline. It also requires ttl_s to exceed the deadline plus two cleanup timeouts: after the deadline the Environment Server closes the agent's session and then the resources server's, which stops the sandbox, each within cleanup_timeout_seconds. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
verify refuses a run whose plugin log lacks a required line, so the session preset may require only lines that every arm prints, and an arm's own lines belong in the overlay that sets its environment. The config test ran the staged plugins for the default arm only, and its plugin host never called grep's tool.definition hook, so it could not see the grep description line the bash-off arm prints. The plugin host now also passes grep's definition, with the two lines of its stock description that name bash and the task tool, through the plugins' tool.definition hooks. The test runs three arms: bash on, bash off (NEMO_GYM_DISABLE_BASH=1 with NEMO_GYM_FIX_GREP_DESCRIPTION=1) and deep search (OPENCODE_WEBSEARCH_TYPE=deep). Every arm must print the preset's required lines; the bash-off arm must print its four lines (tool surface with bash off, grep description patched, the search guard with its domain count and MCP transport, and the bash guard), and the other arms neither the bash-off nor the patched-grep line; the deep arm must report the REST transport and the others MCP. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The README's bash-off overlay for the OpenCode session preset required two plugin lines and did not mention NEMO_GYM_FIX_GREP_DESCRIPTION, which the relay preset advises setting together with NEMO_GYM_DISABLE_BASH. It now says to set both, and its overlay requires the four lines the plugins print for that arm: the tool surface with bash off, the patched grep description, the search guard with its domain count and MCP transport, and the bash guard. The first and third extend the preset's own two lines, so the overlay still requires them. The preset's comment on required_plugin_markers now says that its lines are the ones every arm prints, and that an arm's other lines go in the overlay that sets its environment. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The core config test for BrowseComp's OpenCode presets imported opencode_search's app and opencode_agent's app and runtime. CI's core shards run with coverage over the whole repository (source "."), the omit list leaves resources_servers/ and responses_api_agents/ in, and the combined core report covers every tracked file that was measured, against fail_under 95. Importing those modules from the core suite put both servers' modules, most of whose statements the config test never runs, into that gate. No other core test imports either server. The three tests that need those classes move, with every assertion, to resources_servers/opencode_search/tests/test_browsecomp_presets.py, which runs in the server's own suite (the server and opencode_agent share the same dependencies, and the server suite has the repository root on its path): the check that every preset setting is one Gym reads, the check that the search cache refuses a loopback host, and the check that the agent runs OpenCode as the relay agent does. The moved setting check takes the fields Gym's config layer declares for a server block from the parsed instance, so it needs no name the nemo_gym.config public API does not export. The core test keeps the other checks, imports neither server, and says why in its docstring. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
New files carry the standard NVIDIA SPDX Apache-2.0 header, and the benchmark presets added most recently under benchmarks/*/configs carry it too. The session preset had none; it now starts with the two header lines, above its description. Comments do not change the composed config. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The compaction export test checked only the response output, and its compaction summary carried no token counts. A _session_usage that skipped summaries, or that followed exclude_compaction_summaries, would have passed it. The summary in compacted_events() now records tokens (100 input, 20 output, 5 reasoning and 7 cache reads), and the test checks the response usage for both settings of exclude_compaction_summaries: 120 input, 28 output and 148 total tokens, of which 10 cached and 6 reasoning. The setting removes summaries from the output only; usage keeps counting every model call, the summary calls included. A _session_usage that skips summaries now fails the test for both settings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
A seed refuses a compaction.reserved at or above context_window, but the allowlist test tried only a buffer equal to the window (32000 in the test's setup). A seed that refused only that exact value would have passed it, although a larger buffer leaves no usable input either: OpenCode would compact after every call. Add a buffer of 40000, above the window, to the refused values. With an equality check in place of the seed's comparison, this case fails while the 32000 case still passes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
A session writes OpenCode's provider options with timeout false and no chunkTimeout, so only the run's own deadline bounds a model call. That matches opencode_sandboxed_agent with opencode_model_call_timeout null, whose chunkTimeout is the whole run budget, and the BrowseComp session preset states it. No test read those options, so a change that set either would have gone unnoticed. The borrowed-sandbox flow test now checks that the generated provider options have timeout false and no chunkTimeout. It fails when a session sets a numeric timeout or a chunkTimeout. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The README and the session allowlist's docstring said that compaction.prune "rewrites old tool output". AGENTS.md asks identifiers, comments and docs to avoid qualifiers such as "old" that carry no information. What prune rewrites is the output of tool calls earlier in the session, the prefix that later calls would otherwise extend, so both now say "earlier tool output". The meaning and the allowlist are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The owner-staged plugins section said that the adapter's environment is fixed, so plugins should read their settings from files beside them. A session does refuse the adapter's env setting, but the harness runner starts OpenCode in the sandbox's own environment and exports only the adapter's variables over it. A plugin therefore also sees what the sandbox's owner set: sandbox_config.env, or, in the sandbox opencode_search lends, episode_sandbox_env. BrowseComp's session preset passes its plugins' settings that way, and officeqa_pro already sets OpenCode variables through sandbox_config.env. The section now says so. It names variables the adapter sets itself (HOME, the XDG directories, OPENCODE_CONFIG_CONTENT), which take the adapter's value, and keeps files beside the plugin for an owner that cannot set the environment. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The add-harness skill asks an adapter README to state the harness's supported pairings. This README named the presets that run the agent (HLE and APEX Shortlist, and HLE Diamond and GPQA further down) but not BrowseComp's browsecomp_opencode_sessions.yaml, which runs it in the sandbox opencode_search lends. Name that preset next to HLE and APEX Shortlist, with the agent settings it relies on: owner-staged plugins, compaction.reserved and exclude_compaction_summaries. Say that browsecomp_opencode.yaml keeps the deprecated agent and that the BrowseComp README lists how the two presets differ. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
The section on exclude_compaction_summaries said what the setting removes from the output and that the observations keep the summary text, but not what happens to the response usage. The usage counts every model call of the session, so it includes the summary calls whatever the setting; the compaction export test checks this for both settings. Add that sentence to the section. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: abhibhag <[email protected]>
yaoyu-33
left a comment
There was a problem hiding this comment.
Re-reviewed at 36a62e0: no remaining blocker found. The orchestration boundary violation is fixed, and the PR now includes author-reported real-model comparison evidence. Session cleanup/retries, bounded plugin-log reads, default scoring compatibility and version-specific compaction settings look good.
Workstation validation: 1,337 unique Python tests passed after completing the review checkout, 9 skipped; 4 Node tests passed. One existing pinned-executable test fails on this workstation's shell (exit 2 vs expected 126), reproduced unchanged on the base. Full CI is still outstanding; the reported 400-question model run is at e7020ea, not a fresh run by me.
Minor follow-up: please use a Conventional Commit title before merging.
|
/ok to test 36a62e0 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44376670261 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44412991450 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44416034671 |
Main's opencode_search (#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
Main's opencode_search (#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
Main's opencode_search (#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]>
…oxed harnesses (NVIDIA-NeMo#5010) * feat(single_agent_turn): drive the agent one step at a time and end the episode on the task state A resources server whose task ends through its state, rather than through one tool's call, can now have its episode end right after the step that ended the task. OfficeEnv's task ends when its user app's task row leaves pending, which several operations reach, depending on how a row exposes its apps. - single_agent_turn: max_episode_steps drives the agent one step per activation, up to that many steps, and end_on_task_state reads the resources session's task state between steps (GET /task_state, ResourcesTaskState in nemo_gym.server_runtime). Each step's failure report is kept. The server checks at startup that its agent keeps a session, runs the tools it calls and stops after one step. Driven episodes take part in checkpoints as restarts (BaseEnvironmentServer.checkpoint_mode_in_effect). - simple_agent: with x-ng-agent-episode-step-limit, a step stopped by its own one-step limit counts as completed unless it is the episode's last, and the session keeps one invocation for the episode, as the agent's own loop does, instead of one per step that repeats the whole history. - OfficeEnv: GET /task_state answers ResourcesTaskState; close_tools_on_task_end refuses the calls a step makes after the one that ended its task; its rows route by taskset to single_agent_turn with the step loop on, and the config allows only the simple agent. A retired attempt no longer keeps its episode, so its replacement can seed the same session ID. The server runs OfficeEnv 1.14.0 (1.13.0 at least), with its example rows emitted again. Signed-off-by: Daniele Molinari <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(single_agent_turn): run the step loop's tests in the core suite, and keep a simple_agent subclass in step CI on the step loop found two things: - agentic_turn_simulation_agent overrides simple_agent's _create_episode, which now takes step_limit_owned_by_caller. The override accepts it; only an agent session sets it, and this agent refuses those. - The core coverage gate counts single_agent_turn's and simple_agent's app.py, but the step loop's tests ran in the server suite only. They move to the core suite unchanged, and simple_agent's step limit and invocation folding get core tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(single_agent_turn): import each name in the moved step-loop tests from the module that defines it Tests under tests/ import from the defining module, not a package's public API, and test_the_librarys_tests_import_from_the_module_that_defines_each_name failed on the two files this PR moved into the core suite. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(simple_agent): one step per activation that names the episode's step limit, counted by its index With x-ng-agent-episode-step-limit, the agent takes one step (one model call and the tool calls it makes) whatever its max_steps says, so a pairing no longer needs max_steps: 1, which composition drops when --agent-type simple_agent replaces the environment's agent. Requests without the header run as before. - The step is the activation's index (x-ng-agent-activation), which such a caller sends with every step, not the count of requests, so a step resent after a dropped connection is not counted as the next one. - The session keeps the model server's cookies from step to step, so the episode keeps one model server session. - A step that raises ends the episode's folded invocation as failed (or incomplete when cancelled), not with the completed status of the step before. - The step keywords go to _create_episode only with the header, so an override that predates them keeps working; agentic_turn_simulation_agent's override no longer needs to accept one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(single_agent_turn): drive only agents that take one step per activation, and keep what the steps did - STEP_DRIVEN_AGENT_TYPES (nemo_gym.config, beside AGENT_SESSION_AGENT_TYPES) lists the agent types that take one step per activation that names the episode's step limit: simple_agent. The startup check refuses any other type, such as hermes_agent or browsecomp_agent, which keep a session but run their own loop in an activation; a unit test keeps the list in step with the agent apps. The check no longer reads max_steps, and reads execute_tools as the agent's config does, so a string "false" is false. - A failure after a step completed keeps the completed steps, their output and summed usage, as its partial response, unless it already carries one; a failure before the first reply has none. - An episode that runs out of steps with every step calling a tool says so in its reply's metadata (ng_termination_reason: max_episode_steps). Its status stays the last step's: incomplete_details names only the model's own cutoffs, and an incomplete reply would read as malformed to rollout recovery. - The task state is not read after the last step, which ends the episode either way. - GET /task_state answering 404 with failure_kind session_lost ends the episode, which goes on to /verify and its masked lost-session result, as when a tool call finds the session gone. Other failed reads fail the episode as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(server_runtime): an environment server's checkpoint mode in effect sets its participant and its episodes A server whose class declares exported but whose instance runs as restart_only installs a restart_only participant, and its episodes begin as restarts; an unknown mode in effect stops the server at setup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): run on single_agent_turn_legacy, so flat rows and session-less agents run too single_agent_turn's /run takes only episode requests, so flat rows (training corpora, rows routed by their agent) failed. single_agent_turn_legacy takes flat rows and taskset episodes, and runs the same step loop: OfficeEnv keeps max_episode_steps 50, end_on_task_state, direct HTTP tools and the example taskset's route, and the simple agent no longer sets max_steps: 1. Composition's fallback relays an agent without agent sessions through legacy_agent to its own /run, so allowed_agents also admits simple_agent_with_compaction; the relay takes flat rows, not the taskset's episodes. The test that restated the YAML (skipped in CI with OfficeEnv absent) gives way to core tests that resolve the config with a model and build its environment server: as shipped, with simple_agent.yaml added as --agent-type simple_agent does, and with the compaction agent's config, where the server becomes a legacy_agent relay. The config comment and README say what --agent-type and allowed_agents do, and that rollout_recovery.target_level: sibling applies to the whole training run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs: GET /task_state and the episode step-limit header The Seed/Verify Protocol Extensions table lists GET /task_state, its reply, and what a 404 or 5xx does to the episode. The agent integration page describes x-ng-agent-episode-step-limit beside x-ng-agent-activation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(core): LentSandboxes lends a sandbox with its own image, environment and setup, and releases all within a deadline What the OfficeEnv sandboxed server needs from core's lent sandboxes, so it builds on them instead of a copy: - lend() takes a per-sandbox image, more environment variables and a setup that runs against the started sandbox, its files delivered, before it is lent (start_with_setup); a setup that fails stops the sandbox. - The start runs to its end once begun, within start_timeout_s (30 minutes by default), even while the request that asked for it is cancelled: a create cut in flight leaves a sandbox whose id the provider never returned. A lend cancelled meanwhile lends nothing and stops what it started, and says so in the log. - release_all(timeout_s=...) refuses new lends (503) from its start, waits for those still starting, stops everything within the deadline, and returns and logs the sessions whose sandbox may still run, for a reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv): run OfficeEnv episodes in a sandbox, for Gym's sandboxed harnesses resources_servers/officeenv_sandbox's OfficeEnvSandboxResourcesServer subclasses the OfficeEnv server and lends each episode session a sandbox through LentSandboxes (an operate descriptor: the harness uses it, only the server stops it), stopped before the episode is graded. - The harness reaches the apps as the row's exposure says: MCP tools, a command per app (cli), or endpoints it finds over MCP and calls with curl (api_search). - File content stays out of the conversation through OfficeEnv's workspace mode: downloads land in the workspace, uploads and attachments name a workspace file, and a file API moves bytes directly. - The sandbox sees an ordinary company API. Only Gym's servers on this node (any of the node's own addresses) and trusted_networks reach seeding, closing, verification, metrics, the reverify mode, the app catalog, the task state and the tool routes, which answer others 404 before reading a body; sessions are signed with a per-process secret. - Seeds take turns, and a seed is admitted again before it lends; a close or a retire stops the sandbox, a failed seed's stop is tried again at its session's close, and shutdown stops everything within the run's grace. - A sandbox provider failure fails the call (502) and masks the episode's reward. - Configs for Pi (Docker and OpenSandbox), Codex CLI, mini-SWE, OpenCode, OpenClaw and Terminus 2; nine sandbox tasks (OfficeEnv 1.14.0), the first five as example rows with Pi's rollouts of them; images and a README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes logs a start its limit cut before the provider returned the sandbox's id When start_timeout_s cuts a provider's create in flight, the sandbox's id is unknown, so the lend's stop cannot reach what the create left. The lend now logs that cut at ERROR with the resources session, the task (id and taskset), the provider, the image and the labels, so a reaper can find the sandbox. A start cut after the create returned stops its sandbox as before and asks for no reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): name each harness's instances after it, so harness configs compose in one run Every harness config defined `oe` and `single_agent_turn_legacy`, so two of them could not run together. Now: - the episodes' resources server is officeenv_sandbox_resources_server; - each config adds officeenv_sandbox_<harness>_agent (`_inherit_from` Gym's instance of the harness, as benchmarks do) and officeenv_sandbox_<harness>_environment_server (`_inherit_from: single_agent_turn_legacy`); - Pi, Codex and OpenCode, which name MCP tools their own way, run on their own copy of the episodes' server (officeenv_sandbox_<harness>_resources_server, `_copy` with its mcp_tool_prefix); the other harnesses run on the shared one. A copy takes the shared server's settings from the merged config, so one override reaches every harness. The interpolations, the documented overrides, the probe script and the README follow (a table of the names; the OpenSandbox config is listed after the other harness configs, since a later one pulls the episodes' config in again). A core test resolves each config alone and all six together with a model config, and replaces the server test that restated their YAML; it needs no OfficeEnv, so it runs in CI. The OpenCode and OpenClaw configs and the README no longer say those harnesses refuse MCP tool grants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): sandbox_config.start_timeout_s bounds a sandbox's start; host_relay needs trusted_workstation - sandbox_config.start_timeout_s (1800 s by default, a finite number above 0) is passed to LentSandboxes, which fails the seed at that limit and logs a create it cut for a reaper. The README says when to raise it: creates on a busy OpenSandbox cell have taken up to 2,430 s. - host_relay forwards sandbox connections from the host's loopback, which the caller check takes for Gym's own servers, so code in a sandbox could call the routes kept for Gym for any session. Config validation now refuses host_relay unless sandbox_config.trusted_workstation is true, which a config sets only on a single-user workstation; its description and the README state the risk. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): officeenv_sandboxless.yaml runs the OfficeEnv server's instances under names of their own It composes resources_servers/officeenv/configs/officeenv.yaml and copies (`_copy`) its three instances as officeenv_sandboxless_resources_server, officeenv_sandbox_simple_agent and officeenv_sandbox_environment_server, each copy pointing at the other copies, while the OfficeEnv server's instances keep their names. The copied agent declares no dataset, so the example rows and their taskset stay with the OfficeEnv server's instances, and rows that name officeenv_sandbox_simple_agent (flat rows, agent_ref) route to the copied environment server. A `_copy` takes its source as written, before the source's own `_inherit_from` applies, so the environment server is copied as the instance of the server type officeenv_environment_server inherits, with that server's own settings for it on top. The core test checks each copy against its source, references aside, alone and beside the Pi and Codex configs, so a change to the source's server type fails it rather than leaving the copy behind. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): the sandboxless arm copies single_agent_turn_legacy, which the OfficeEnv server now runs officeenv_environment_server inherits single_agent_turn_legacy now, so the copy takes that instance, then the server's own settings for it under that type, with its references still pointing at the other copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): every harness runs the episodes' server under its own name, so none is left idle Each harness config now adds officeenv_sandbox_<harness>_resources_server with `_inherit_from: officeenv_sandbox_resources_server`, OpenClaw, mini-SWE and Terminus 2 included, and no harness names the episodes' server. `_inherit_from` reads it from the merged config and takes it out of the run, so a run of one or several harness configs starts no idle episodes' server, while the episodes config alone still runs it under its own name. Settings on the episodes' server, the OpenSandbox config's included, reach every harness's server. The OpenSandbox config still goes after the other harness configs (the first harness config listed pulls the episodes' config in), and the README now says why. The core test checks that no episodes' server starts or is named beside the harnesses', alone and with all six, and that the episodes config runs on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): the cut-start log says OpenSandbox deletes what an abandoned create left Main's OpenSandbox provider now deletes the sandbox of a create its caller gave up on (NVIDIA-NeMo#4799), so a start that LentSandboxes' start_timeout_s cuts before the provider returned the sandbox's id no longer needs a reaper there. The ERROR log, LentSandboxes' docstring and the officeenv_sandbox README now say so, and keep the reaper for providers without that cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): Pi's run ends once its task has ended, on every exposure - The sandboxed server holds the call that ends a watched episode's task, on every way in (tools, commands, endpoints, the file API), until the environment server releases it; the episode's lock is let go first. Only Gym's node reaches GET /task_state and POST /task_state/release. - Pi supports POST /rollouts/{rollout_id}/stop (_rollout_sandbox_session): a run stopped as completed answers so, marked in ng_rollout_stop, and is not reported as a wall-time timeout. - The Pi config sets end_on_task_state on its environment server and drops finish_tool_names (now []): the stop ends the run on cli and api_search rows too, which offer no finish tool. Its comment no longer asks cli rows to drop the MCP transport, which they run with as it is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs(officeenv): the servers run OfficeEnv 1.14.2 1.14.2 is the OfficeEnv release N4's training runs grade with. 1.14.1 and 1.14.2 are patch releases; neither changes the API these servers use. The READMEs' install lines name it, and the example rows are emitted again by it (officeenv emit for resources_servers/officeenv, sandbox/prepare_rows.py for officeenv_sandbox), which changed only their version stamp. The example rollouts stay the ones collected against 1.14.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): refuse calls after the task ended with ResourcesSessionConflictError Main's session contract (NVIDIA-NeMo#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. The sandboxed server refused a tool call once verification began, and a file API call once the episode's files closed, with plain HTTPException(409)s; both now raise the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes shields a start only with start_timeout_s Main's opencode_search (NVIDIA-NeMo#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * build(officeenv_sandbox): lock against main's upgraded dependency locks Main's lock upgrade (NVIDIA-NeMo#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(core): a cut start's test counts the closes the provider made Main's NVIDIA-NeMo#6410 changed the stopped fixture from AsyncSandbox.stop calls to the closes the provider made. A start cut before the provider returned its sandbox's id leaves nothing to close, so the hung-start test now expects none, as the ERROR line it checks says. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(single_agent_turn): stop an agent's own loop once its task has ended With end_on_task_state and no max_episode_steps, single_agent_turn now ends an agent that runs its own loop (a sandboxed harness) at its task's end, as the step loop ends a step-driven one: - Before the agent runs it reads GET /task_state?watch=true; while the agent runs it reads again, each read waiting up to 30 s (wait_s). - Once the task has ended it stops the run with POST /rollouts/{id}/stop {"reason": "task_ended", "completed": true}, waits for the activation to answer (at most 120 s), then posts /task_state/release. - The resources server holds its answer to the call that ended the task until that release, so the harness never reads it while its run could go on, and no model call follows the call that ended the task. - The server refuses at startup an agent type outside ROLLOUT_STOP_AGENT_TYPES (the agents whose runs the stop route can end; a unit test keeps the list in step with the apps). Core: RolloutStopRequest.completed; such a stop answers as completed (report_rollout_stop) and says so in ng_rollout_stop. Docker uploads take a bound of their own, so a stop's marker never waits for the exec slot a running harness holds (uploads_independent_of_execs). OfficeEnv: GET /task_state takes watch and wait_s (at most 60 s); POST /task_state/release; task_end_hold_seconds (180) bounds the hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(officeenv_sandbox): the stand-in sandbox stops as main's AsyncSandbox.stop does Main's NVIDIA-NeMo#6410 moved the shielded, bounded stop into AsyncSandbox.stop(timeout_s=...), which LentSandboxes now calls. The tests' FakeSandbox.stop took no timeout_s and had no shield, so a seed or close cancelled during a stop failed or hung. FakeSandbox.stop now takes timeout_s and shields its provider-side _stop, as AsyncSandbox.stop does, and the tests that slow down, refuse or hang a stop patch _stop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(cline_agent): the fake sandbox session carries expire_completed report_rollout_stop now reads SandboxSession.expire_completed (a run stopped once its task has ended answers as completed), so the stand-in that Cline's session tests use carries it too, as the real session does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): sign sessions with Gym's run secret NVIDIA-NeMo#6161 now makes a secret per server and run in server_runtime, which every worker of the server shares (signs_sessions_with_run_secret). The sandboxed server sets that flag instead of minting its own secret in model_post_init and overriding get_session_secret(): its cookies and MCP tokens are signed, as before, with a secret code in a sandbox cannot derive from the server's name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): refuse a tool call after the task ended with ResourcesSessionConflictError Main's session contract (NVIDIA-NeMo#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. With close_tools_on_task_end, the OfficeEnv server refused a call after the task ended with a plain HTTPException(409); it now raises the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): release_all stops the lent sandboxes while a lend is still starting release_all waited for every start in flight before it stopped any lent sandbox, all inside one time limit. One slow start at shutdown then left every lent sandbox running until its TTL. Now the lent sandboxes stop at once, and each starting sandbox is stopped when its start ends. The new test fails before this change (no sandbox stopped) and passes after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv_sandbox): keep the agent and environment servers on 127.0.0.1 NeMo RL sets default_host to the node's address, and an explicit default_host applies to every server, not only to the types in absolute_ip_server_types. A sandbox's network rule opens every port of an allowed host. So code in a sandbox could call the agent and environment servers: run Pi on Gym's host (/v1/responses without a session), start episodes (/run) and stop another episode's run (/rollouts/{rollout_id}/stop). Each harness config now sets host: 127.0.0.1 on its agent and its environment server. No sandbox calls them: each harness in a sandbox calls only the model server and the resources server, and NeMo RL calls /run from the same node. Without default_host, Gym already binds them to 127.0.0.1. The comment in officeenv_opensandbox.yaml and the README now say this. The new config test resolves every harness config under default_host: 10.0.0.5, on Docker and on OpenSandbox. It fails before this change (the agent server gets 10.0.0.5) and passes after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv_sandbox): refuse calls after the task ends for every harness No sandboxed config set close_tools_on_task_end, though the README said that it refuses a harness's later calls. Only Pi's environment server stops the run at the task's end. So under Codex, OpenCode, OpenClaw, mini-SWE and Terminus 2, a tool or file API call after complete_task could still change what /verify grades: a late upload made a task pass. The episodes' config, which every harness's resources server inherits, now sets close_tools_on_task_end: true. The config test asserts the resolved value for each harness in every composition. It fails before this change and passes after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * refactor(officeenv_sandbox): leave the mini-SWE pairing to a follow-up PR The mini-SWE config ran on miniswe_sandboxed_agent, which is deprecated for new configs in favor of mini_swe_agent's agent sessions. A follow-up PR will add the pairing on mini_swe_agent/mini_swe_agent_sandboxed, with one real `cli` row. This removes configs/officeenv_sandbox_miniswe.yaml, its rows in both config tests and its mentions in the README. The other five harness configs are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(single_agent_turn): make the task-end stop reach the agent and fail for good on 501 The stop that ends an agent's own loop at the task end now: - goes over the reserved control connection pool, with the release, so it never waits for a connection that the running activation holds; - counts its 120 s bound from the time the stop is sent, and waits for the activation also when the stop answers stopped: false; - logs a warning and marks the reply (ng_task_end_stop: unconfirmed) when the activation still runs at that bound; - fails the episode for good when the agent answers 501 (the sandbox provider cannot stop a running harness), since every attempt would fail the same way. 500 and 502 stay retryable. A task that has already ended, or a lost resources session, at the first watch starts no run: the episode goes on to verification with a reply that has no output (ng_termination_reason: task_ended_before_run). The step loop logs a warning at startup when the driven agent sets max_steps, which it does not use. The single_agent_turn README names bwrap among the providers that can stop a running harness, and the providers whose stop answers 501. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv): report tool_drift for episode seeds, and document close_tools_on_task_end An episode seed (ResourcesSeedSessionRequest) now passes the task's responses_create_params to OfficeEnv with the row, as a seed of the whole row did through legacy_agent, so tool_drift is reported again for rows whose tools are stale. The README no longer says that checks read every message sent after complete_task: with close_tools_on_task_end, which this configuration turns on, such a call gets 409 and changes nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * docs(agent-server): describe completed rollout stops and the providers that can stop a running harness The harness guide now names RolloutStopRequest.completed and the completed status it gives a stopped run, and lists Local, bwrap, Docker and OpenSandbox with background_exec as the providers that can stop a running harness. The others answer HTTP 501. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv_sandbox): report tool_drift for episode seeds NVIDIA-NeMo#6162 makes the OfficeEnv server's episode seed keep the task's responses_create_params, so tool_drift compares the row's tools with the ones the server serves. This server overrides _new_episode with the same task_data-only seed, so it reported no drift for an episode seed. It now passes responses_create_params the same way. The new test seeds a row whose first tool has a stale description. It fails before this change (tool_drift 0.0) and passes after it (1.0). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(simple_agent): run a caller-driven step once when it is sent again Without checkpointing, the environment server's client sends a step again after a dropped connection, and the step ran its model call and tool calls a second time: a second email, say, while the environment recorded one reply. A step of a session that a caller drives one step per activation (x-ng-agent-episode-step-limit) is now keyed by its session and its activation index. A step sent again while it runs shares its run, and one sent after it answered gets the same reply and cookies; neither calls the model or runs a tool again. The step runs apart from the request that sent it, so a disconnect that cancels that request does not cut it short, and closing the session cancels a step that still runs. A step older than the session's latest is refused with 409. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(agents): a run stopped as completed closes with its invocation completed A stop with completed: true, for a run whose task ended, makes the run's response completed (report_rollout_stop), but the harness agents record their invocation before that, as incomplete. So the same run had two statuses: completed in its response and incomplete in its agent observations (for Prime, and for every agent in ROLLOUT_STOP_AGENT_TYPES). The base agent's session close now applies report_completed_rollout_stop when the rollout's sandbox session ended with a completed stop: each top-level invocation the stop left incomplete says completed, with no error type. The sandbox observation keeps the supervisor's raw timeout, and a child invocation keeps its own status. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * docs(agent-server): a step sent again runs once, and a completed stop closes completed The integration guide says that simple_agent runs a caller-driven step once without checkpointing, and that the session close of a run stopped as completed reports its top-level invocation as completed. The harness guide says the same of the close. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(simple_agent): drop a session's saved step when it closes The close now clears the step the session kept for a step sent again, so a session never keeps it after it ends. The docstring says why only caller-driven steps without checkpointing need it: with checkpointing, the activation tracking already gives a repeated activation its saved reply, and any other activation is the episode's only one or a continuation session's turn on new input. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * test(goose_agent): a stop for an ended task closes with the invocation completed A second agent from ROLLOUT_STOP_AGENT_TYPES, besides Prime, whose close after a completed stop has the shape the base close fixes: a top-level invocation left incomplete, which report_completed_rollout_stop marks completed, and a sandbox observation that keeps the supervisor's timeout. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * build(officeenv_sandbox): lock against main's bumped root dependencies CI tests this branch merged onto NVIDIA-NeMo#6162's merge ref with main. Main's NVIDIA-NeMo#6268 bumped hydra-core (>=1.4.0rc3), omegaconf (>=2.4.1rc2), mlflow and gitpython in the root pyproject, which this server's lock includes through nemo-gym. So `uv sync --locked` and the lock check refused this lock in CI. This lock was made with `uv lock` on a tree shaped like CI's: this branch merged onto NVIDIA-NeMo#6162's merge ref 5c7691f (942c31a on main 6aa1fd6). There, `uv lock --check` and `uv sync --locked` pass, and the server's tests pass. On this branch alone, `uv lock --check` fails until NVIDIA-NeMo#6162 contains main, because the branch still has the older root pyproject. The lock is the one that is right once NVIDIA-NeMo#6162 has main. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(single_agent_turn): keep task-end watches and stops progressing Signed-off-by: yaoyu-33 <[email protected]> * fix(officeenv_sandbox): bind sandboxless services to loopback Signed-off-by: yaoyu-33 <[email protected]> * fix(pi): report task-end stops after classifying the invocation Signed-off-by: yaoyu-33 <[email protected]> * chore(officeenv_sandbox): add the test package license header Signed-off-by: yaoyu-33 <[email protected]> --------- Signed-off-by: Daniele Molinari <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Yi-Fu Wu <[email protected]> Co-authored-by: yaoyu-33 <[email protected]>
…ion to keep the recorded history (NVIDIA-NeMo#6672) * feat(core): session secrets, cookie names and MCP endpoint options for servers that sandboxed code calls A resources server that lends a sandbox is reached by code the model controls, so the session key that every caller can compute from the server's class and name must not sign its cookies and MCP tokens, and its endpoint should look like an ordinary one. - SimpleServer.get_session_secret() signs session cookies and MCP session tokens (default: the session middleware key, so nothing changes). Session routing reads cookies and tokens with it. Its docstring states what an override must keep: one secret in every worker, and a secret that changes ends every open session. - SimpleServer.get_session_cookie_name() names the session cookie (default: the same key). - mcp_server_name: the name the MCP endpoint lists itself under; verify-time normalization strips its namespace. - mcp_bearer_token: tokens ride as Authorization: Bearer, tools/list needs one and lists only the session's tools, a tool outside the grant is an unknown tool, and errors name no framework. - Both options are refused without expose_tools_over_mcp, and a name outside MCP's tool-name alphabet is refused. A single_agent_turn pairing refuses to grant two MCP endpoints listed under one name. Signed-off-by: Daniele Molinari <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(server_runtime): honor mcp_server_name end to end and refuse bearer tokens without a secret Review fixes for the MCP endpoint options. - mcp_server_name is also checked against the name pattern of an MCP grant (MCP_TOOL_ACCESS_NAME_PATTERN in tool_access, which MCPToolAccess uses), so a name that an Environment Server cannot grant, one that starts with '_' or '-', is refused at config instead of failing every episode before the agent seed. The grant contract is unchanged. A dot stays refused: Pi's MCP adapter and Codex refuse server names outside [A-Za-z0-9_-]. - seed_mcp_servers keys each entry by the seed metadata's server_name, else the server's name, and refuses two servers listed under one name. URLs, headers and routing still use the server's reference. The sandboxed OpenCode agent's required-server list uses the same keys; the sandboxed Pi agent reads them as given. - An MCP endpoint with mcp_bearer_token refuses to start while get_session_secret() is the public session middleware key, since code that reads one bearer token could sign another session's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * revert(agents): keep MCP endpoint names off the legacy seeder Review asked to keep the MCP changes on the agent-session path. The only callers of seed_mcp_servers, the sandboxed Pi and OpenCode agents, run on the agent-owned /run path that #5222 deprecates, and OfficeEnv's Pi preset gets the advertised name and headers through its MCPToolAccess grant. The seeder keys its entries by server name again, and the aliasing's tests go with it. It no longer refuses two servers under one name, a refusal that came after the primary server may have started a task sandbox and before OpenCode's cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(opencode_agent): refuse MCP grants whose tools OpenCode could name alike Review found that distinct endpoint names can still hide a tool in opencode_agent. OpenCode keys each MCP tool <grant>_<tool>, writing characters outside [a-zA-Z0-9_-] as '_', and a later tool under a key already taken replaces the earlier one without a word: `company` serving `files_list` and `company_files` serving `list` both register `company_files_list`. The agent's seed now refuses two MCP grants whose tools could share a key, which the grant names decide: equal once written as OpenCode writes them, or one the other followed by '_'. single_agent_turn's README and check, and the mcp_server_name field, describe tool naming as each harness's own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(server_runtime): sign sessions with a secret made for the run Review asked for per-run session secrets in server_runtime, as episode_token_secret() does (#5346), instead of each server overriding get_session_secret(). run_session_secret(name) makes one secret per server for the run and keeps it in the environment, so the workers uvicorn starts after the main process built the server inherit it. get_session_secret() returns it when the server sets signs_sessions_with_run_secret or its config sets mcp_bearer_token, so bearer tokens work from YAML alone and with any number of workers; otherwise it is the public key, as before. The session_secret property resolves it once per server (a cached_property, so it holds for a server built without its model_post_init too), and the session middleware, session routing and the MCP endpoint all read it there, so an override that answers differently from call to call cannot split them. Exposure still refuses bearer tokens signed with the public key, which only an override can now produce. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(single_agent_turn): drive the agent one step at a time and end the episode on the task state A resources server whose task ends through its state, rather than through one tool's call, can now have its episode end right after the step that ended the task. OfficeEnv's task ends when its user app's task row leaves pending, which several operations reach, depending on how a row exposes its apps. - single_agent_turn: max_episode_steps drives the agent one step per activation, up to that many steps, and end_on_task_state reads the resources session's task state between steps (GET /task_state, ResourcesTaskState in nemo_gym.server_runtime). Each step's failure report is kept. The server checks at startup that its agent keeps a session, runs the tools it calls and stops after one step. Driven episodes take part in checkpoints as restarts (BaseEnvironmentServer.checkpoint_mode_in_effect). - simple_agent: with x-ng-agent-episode-step-limit, a step stopped by its own one-step limit counts as completed unless it is the episode's last, and the session keeps one invocation for the episode, as the agent's own loop does, instead of one per step that repeats the whole history. - OfficeEnv: GET /task_state answers ResourcesTaskState; close_tools_on_task_end refuses the calls a step makes after the one that ended its task; its rows route by taskset to single_agent_turn with the step loop on, and the config allows only the simple agent. A retired attempt no longer keeps its episode, so its replacement can seed the same session ID. The server runs OfficeEnv 1.14.0 (1.13.0 at least), with its example rows emitted again. Signed-off-by: Daniele Molinari <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(single_agent_turn): run the step loop's tests in the core suite, and keep a simple_agent subclass in step CI on the step loop found two things: - agentic_turn_simulation_agent overrides simple_agent's _create_episode, which now takes step_limit_owned_by_caller. The override accepts it; only an agent session sets it, and this agent refuses those. - The core coverage gate counts single_agent_turn's and simple_agent's app.py, but the step loop's tests ran in the server suite only. They move to the core suite unchanged, and simple_agent's step limit and invocation folding get core tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(single_agent_turn): import each name in the moved step-loop tests from the module that defines it Tests under tests/ import from the defining module, not a package's public API, and test_the_librarys_tests_import_from_the_module_that_defines_each_name failed on the two files this PR moved into the core suite. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(simple_agent): one step per activation that names the episode's step limit, counted by its index With x-ng-agent-episode-step-limit, the agent takes one step (one model call and the tool calls it makes) whatever its max_steps says, so a pairing no longer needs max_steps: 1, which composition drops when --agent-type simple_agent replaces the environment's agent. Requests without the header run as before. - The step is the activation's index (x-ng-agent-activation), which such a caller sends with every step, not the count of requests, so a step resent after a dropped connection is not counted as the next one. - The session keeps the model server's cookies from step to step, so the episode keeps one model server session. - A step that raises ends the episode's folded invocation as failed (or incomplete when cancelled), not with the completed status of the step before. - The step keywords go to _create_episode only with the header, so an override that predates them keeps working; agentic_turn_simulation_agent's override no longer needs to accept one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(single_agent_turn): drive only agents that take one step per activation, and keep what the steps did - STEP_DRIVEN_AGENT_TYPES (nemo_gym.config, beside AGENT_SESSION_AGENT_TYPES) lists the agent types that take one step per activation that names the episode's step limit: simple_agent. The startup check refuses any other type, such as hermes_agent or browsecomp_agent, which keep a session but run their own loop in an activation; a unit test keeps the list in step with the agent apps. The check no longer reads max_steps, and reads execute_tools as the agent's config does, so a string "false" is false. - A failure after a step completed keeps the completed steps, their output and summed usage, as its partial response, unless it already carries one; a failure before the first reply has none. - An episode that runs out of steps with every step calling a tool says so in its reply's metadata (ng_termination_reason: max_episode_steps). Its status stays the last step's: incomplete_details names only the model's own cutoffs, and an incomplete reply would read as malformed to rollout recovery. - The task state is not read after the last step, which ends the episode either way. - GET /task_state answering 404 with failure_kind session_lost ends the episode, which goes on to /verify and its masked lost-session result, as when a tool call finds the session gone. Other failed reads fail the episode as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(server_runtime): an environment server's checkpoint mode in effect sets its participant and its episodes A server whose class declares exported but whose instance runs as restart_only installs a restart_only participant, and its episodes begin as restarts; an unknown mode in effect stops the server at setup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): run on single_agent_turn_legacy, so flat rows and session-less agents run too single_agent_turn's /run takes only episode requests, so flat rows (training corpora, rows routed by their agent) failed. single_agent_turn_legacy takes flat rows and taskset episodes, and runs the same step loop: OfficeEnv keeps max_episode_steps 50, end_on_task_state, direct HTTP tools and the example taskset's route, and the simple agent no longer sets max_steps: 1. Composition's fallback relays an agent without agent sessions through legacy_agent to its own /run, so allowed_agents also admits simple_agent_with_compaction; the relay takes flat rows, not the taskset's episodes. The test that restated the YAML (skipped in CI with OfficeEnv absent) gives way to core tests that resolve the config with a model and build its environment server: as shipped, with simple_agent.yaml added as --agent-type simple_agent does, and with the compaction agent's config, where the server becomes a legacy_agent relay. The config comment and README say what --agent-type and allowed_agents do, and that rollout_recovery.target_level: sibling applies to the whole training run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs: GET /task_state and the episode step-limit header The Seed/Verify Protocol Extensions table lists GET /task_state, its reply, and what a 404 or 5xx does to the episode. The agent integration page describes x-ng-agent-episode-step-limit beside x-ng-agent-activation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(single_agent_turn): stop an agent's own loop once its task has ended With end_on_task_state and no max_episode_steps, single_agent_turn now ends an agent that runs its own loop (a sandboxed harness) at its task's end, as the step loop ends a step-driven one: - Before the agent runs it reads GET /task_state?watch=true; while the agent runs it reads again, each read waiting up to 30 s (wait_s). - Once the task has ended it stops the run with POST /rollouts/{id}/stop {"reason": "task_ended", "completed": true}, waits for the activation to answer (at most 120 s), then posts /task_state/release. - The resources server holds its answer to the call that ended the task until that release, so the harness never reads it while its run could go on, and no model call follows the call that ended the task. - The server refuses at startup an agent type outside ROLLOUT_STOP_AGENT_TYPES (the agents whose runs the stop route can end; a unit test keeps the list in step with the apps). Core: RolloutStopRequest.completed; such a stop answers as completed (report_rollout_stop) and says so in ng_rollout_stop. Docker uploads take a bound of their own, so a stop's marker never waits for the exec slot a running harness holds (uploads_independent_of_execs). OfficeEnv: GET /task_state takes watch and wait_s (at most 60 s); POST /task_state/release; task_end_hold_seconds (180) bounds the hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(cline_agent): the fake sandbox session carries expire_completed report_rollout_stop now reads SandboxSession.expire_completed (a run stopped once its task has ended answers as completed), so the stand-in that Cline's session tests use carries it too, as the real session does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): refuse a tool call after the task ended with ResourcesSessionConflictError Main's session contract (#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. With close_tools_on_task_end, the OfficeEnv server refused a call after the task ended with a plain HTTPException(409); it now raises the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(core): LentSandboxes lends a sandbox with its own image, environment and setup, and releases all within a deadline What the OfficeEnv sandboxed server needs from core's lent sandboxes, so it builds on them instead of a copy: - lend() takes a per-sandbox image, more environment variables and a setup that runs against the started sandbox, its files delivered, before it is lent (start_with_setup); a setup that fails stops the sandbox. - The start runs to its end once begun, within start_timeout_s (30 minutes by default), even while the request that asked for it is cancelled: a create cut in flight leaves a sandbox whose id the provider never returned. A lend cancelled meanwhile lends nothing and stops what it started, and says so in the log. - release_all(timeout_s=...) refuses new lends (503) from its start, waits for those still starting, stops everything within the deadline, and returns and logs the sessions whose sandbox may still run, for a reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv): run OfficeEnv episodes in a sandbox, for Gym's sandboxed harnesses resources_servers/officeenv_sandbox's OfficeEnvSandboxResourcesServer subclasses the OfficeEnv server and lends each episode session a sandbox through LentSandboxes (an operate descriptor: the harness uses it, only the server stops it), stopped before the episode is graded. - The harness reaches the apps as the row's exposure says: MCP tools, a command per app (cli), or endpoints it finds over MCP and calls with curl (api_search). - File content stays out of the conversation through OfficeEnv's workspace mode: downloads land in the workspace, uploads and attachments name a workspace file, and a file API moves bytes directly. - The sandbox sees an ordinary company API. Only Gym's servers on this node (any of the node's own addresses) and trusted_networks reach seeding, closing, verification, metrics, the reverify mode, the app catalog, the task state and the tool routes, which answer others 404 before reading a body; sessions are signed with a per-process secret. - Seeds take turns, and a seed is admitted again before it lends; a close or a retire stops the sandbox, a failed seed's stop is tried again at its session's close, and shutdown stops everything within the run's grace. - A sandbox provider failure fails the call (502) and masks the episode's reward. - Configs for Pi (Docker and OpenSandbox), Codex CLI, mini-SWE, OpenCode, OpenClaw and Terminus 2; nine sandbox tasks (OfficeEnv 1.14.0), the first five as example rows with Pi's rollouts of them; images and a README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes logs a start its limit cut before the provider returned the sandbox's id When start_timeout_s cuts a provider's create in flight, the sandbox's id is unknown, so the lend's stop cannot reach what the create left. The lend now logs that cut at ERROR with the resources session, the task (id and taskset), the provider, the image and the labels, so a reaper can find the sandbox. A start cut after the create returned stops its sandbox as before and asks for no reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): name each harness's instances after it, so harness configs compose in one run Every harness config defined `oe` and `single_agent_turn_legacy`, so two of them could not run together. Now: - the episodes' resources server is officeenv_sandbox_resources_server; - each config adds officeenv_sandbox_<harness>_agent (`_inherit_from` Gym's instance of the harness, as benchmarks do) and officeenv_sandbox_<harness>_environment_server (`_inherit_from: single_agent_turn_legacy`); - Pi, Codex and OpenCode, which name MCP tools their own way, run on their own copy of the episodes' server (officeenv_sandbox_<harness>_resources_server, `_copy` with its mcp_tool_prefix); the other harnesses run on the shared one. A copy takes the shared server's settings from the merged config, so one override reaches every harness. The interpolations, the documented overrides, the probe script and the README follow (a table of the names; the OpenSandbox config is listed after the other harness configs, since a later one pulls the episodes' config in again). A core test resolves each config alone and all six together with a model config, and replaces the server test that restated their YAML; it needs no OfficeEnv, so it runs in CI. The OpenCode and OpenClaw configs and the README no longer say those harnesses refuse MCP tool grants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): sandbox_config.start_timeout_s bounds a sandbox's start; host_relay needs trusted_workstation - sandbox_config.start_timeout_s (1800 s by default, a finite number above 0) is passed to LentSandboxes, which fails the seed at that limit and logs a create it cut for a reaper. The README says when to raise it: creates on a busy OpenSandbox cell have taken up to 2,430 s. - host_relay forwards sandbox connections from the host's loopback, which the caller check takes for Gym's own servers, so code in a sandbox could call the routes kept for Gym for any session. Config validation now refuses host_relay unless sandbox_config.trusted_workstation is true, which a config sets only on a single-user workstation; its description and the README state the risk. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): officeenv_sandboxless.yaml runs the OfficeEnv server's instances under names of their own It composes resources_servers/officeenv/configs/officeenv.yaml and copies (`_copy`) its three instances as officeenv_sandboxless_resources_server, officeenv_sandbox_simple_agent and officeenv_sandbox_environment_server, each copy pointing at the other copies, while the OfficeEnv server's instances keep their names. The copied agent declares no dataset, so the example rows and their taskset stay with the OfficeEnv server's instances, and rows that name officeenv_sandbox_simple_agent (flat rows, agent_ref) route to the copied environment server. A `_copy` takes its source as written, before the source's own `_inherit_from` applies, so the environment server is copied as the instance of the server type officeenv_environment_server inherits, with that server's own settings for it on top. The core test checks each copy against its source, references aside, alone and beside the Pi and Codex configs, so a change to the source's server type fails it rather than leaving the copy behind. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): the sandboxless arm copies single_agent_turn_legacy, which the OfficeEnv server now runs officeenv_environment_server inherits single_agent_turn_legacy now, so the copy takes that instance, then the server's own settings for it under that type, with its references still pointing at the other copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): every harness runs the episodes' server under its own name, so none is left idle Each harness config now adds officeenv_sandbox_<harness>_resources_server with `_inherit_from: officeenv_sandbox_resources_server`, OpenClaw, mini-SWE and Terminus 2 included, and no harness names the episodes' server. `_inherit_from` reads it from the merged config and takes it out of the run, so a run of one or several harness configs starts no idle episodes' server, while the episodes config alone still runs it under its own name. Settings on the episodes' server, the OpenSandbox config's included, reach every harness's server. The OpenSandbox config still goes after the other harness configs (the first harness config listed pulls the episodes' config in), and the README now says why. The core test checks that no episodes' server starts or is named beside the harnesses', alone and with all six, and that the episodes config runs on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): the cut-start log says OpenSandbox deletes what an abandoned create left Main's OpenSandbox provider now deletes the sandbox of a create its caller gave up on (#4799), so a start that LentSandboxes' start_timeout_s cuts before the provider returned the sandbox's id no longer needs a reaper there. The ERROR log, LentSandboxes' docstring and the officeenv_sandbox README now say so, and keep the reaper for providers without that cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): Pi's run ends once its task has ended, on every exposure - The sandboxed server holds the call that ends a watched episode's task, on every way in (tools, commands, endpoints, the file API), until the environment server releases it; the episode's lock is let go first. Only Gym's node reaches GET /task_state and POST /task_state/release. - Pi supports POST /rollouts/{rollout_id}/stop (_rollout_sandbox_session): a run stopped as completed answers so, marked in ng_rollout_stop, and is not reported as a wall-time timeout. - The Pi config sets end_on_task_state on its environment server and drops finish_tool_names (now []): the stop ends the run on cli and api_search rows too, which offer no finish tool. Its comment no longer asks cli rows to drop the MCP transport, which they run with as it is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs(officeenv): the servers run OfficeEnv 1.14.2 1.14.2 is the OfficeEnv release N4's training runs grade with. 1.14.1 and 1.14.2 are patch releases; neither changes the API these servers use. The READMEs' install lines name it, and the example rows are emitted again by it (officeenv emit for resources_servers/officeenv, sandbox/prepare_rows.py for officeenv_sandbox), which changed only their version stamp. The example rollouts stay the ones collected against 1.14.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): refuse calls after the task ended with ResourcesSessionConflictError Main's session contract (#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. The sandboxed server refused a tool call once verification began, and a file API call once the episode's files closed, with plain HTTPException(409)s; both now raise the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes shields a start only with start_timeout_s Main's opencode_search (#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * build(officeenv_sandbox): lock against main's upgraded dependency locks Main's lock upgrade (#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(core): a cut start's test counts the closes the provider made Main's #6410 changed the stopped fixture from AsyncSandbox.stop calls to the closes the provider made. A start cut before the provider returned its sandbox's id leaves nothing to close, so the hung-start test now expects none, as the ERROR line it checks says. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(officeenv_sandbox): the stand-in sandbox stops as main's AsyncSandbox.stop does Main's #6410 moved the shielded, bounded stop into AsyncSandbox.stop(timeout_s=...), which LentSandboxes now calls. The tests' FakeSandbox.stop took no timeout_s and had no shield, so a seed or close cancelled during a stop failed or hung. FakeSandbox.stop now takes timeout_s and shields its provider-side _stop, as AsyncSandbox.stop does, and the tests that slow down, refuse or hang a stop patch _stop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): sign sessions with Gym's run secret #6161 now makes a secret per server and run in server_runtime, which every worker of the server shares (signs_sessions_with_run_secret). The sandboxed server sets that flag instead of minting its own secret in model_post_init and overriding get_session_secret(): its cookies and MCP tokens are signed, as before, with a secret code in a sandbox cannot derive from the server's name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(stirrup_agent): stop a run once its task has ended, and run Stirrup on OfficeEnv's sandboxed episodes Stirrup could not be stopped in flight, so single_agent_turn's end_on_task_state refused it and OfficeEnv's sandboxed episodes had no Stirrup harness: - stirrup_agent returns its sandbox session for a rollout stop (_rollout_sandbox_session) and marks the run a stop ended (report_rollout_stop): a stop once the task has ended answers as completed, with ng_rollout_stop and without the deadline's stop_reason. stirrup_agent joins ROLLOUT_STOP_AGENT_TYPES. - The runner, ended by its supervisor while a turn's tool calls run, reports that turn's reply too (its calls without answers) rather than the history as of the turn's start. A stop once the task has ended lands so: the call that ended the task waits for its answer until the run is over, and it stays the run's last item, as Pi's does. - resources_servers/officeenv_sandbox/configs/officeenv_sandbox_stirrup.yaml: Stirrup on `cli` rows, under the harness configs' names (officeenv_sandbox_stirrup_agent, _environment_server, _resources_server), no MCP transports, end_on_task_state, admitted episodes capped at Stirrup's concurrency. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * feat(stirrup_agent): options to keep the run's history as it was recorded Training on recorded tokens needs one unbroken history per episode, and Stirrup's defaults rewrite it: past 0.7 of the context window it replaces the history with a summary, and on a context overflow it unwinds completed turns. Two options keep those defaults and let a training config turn them off: - context_summarization_cutoff (default 0.7, Stirrup's): None never summarizes, so an episode at the context limit ends there; - recover_from_context_overflow (default true, Stirrup's): false raises instead of unwinding. The runner passes them to Stirrup's agent; a payload without them keeps Stirrup's defaults. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * test(officeenv_sandbox): cover the Stirrup harness config in the core config tests The server's own config tests skip without OfficeEnv, and CI does not install OfficeEnv. The core config tests resolve each harness config without it, so they now include officeenv_sandbox_stirrup.yaml. The tests make sure that its instances carry Stirrup's name, that it composes beside the other harness configs with its own cap of 32, and that its environment server stops the run once the task has ended. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * docs(stirrup_agent): describe rollout stops and the history options The README now says how a rollout stop ends a Stirrup run and what the response carries. A run that ends while a turn's tool calls run ends with that turn's reply. The options table lists context_summarization_cutoff and recover_from_context_overflow, and a new section names the settings that keep the recorded history for training. With context_overflow_recovery off, its default, the client never reports an overflow to Stirrup. So recover_from_context_overflow changes a run only when a config also turns context_overflow_recovery on. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): keep a compaction summary out of a stopped run's output The runner kept the last reply of every model call, a compaction summary's included. A summary can carry tool calls, since its first attempts offer the tools. If the run then ended while the next policy call waited for the model, the runner added the summary and its calls to the output as the running turn, although those calls never ran. The runner now keeps only the reply of the policy turn that is running. Each model call clears the reply first, and a reply made during a compaction is never kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): answer a stop that arrives before the runner starts A rollout stop accepted during the seed or before the activation keeps the supervisor from launching the runner. The runner then writes no output.json, so the activation failed with "Stirrup sandbox runner exited without output", although the agent server had answered the stop as stopped. When the session reports an expiry before launch, the runner's report is now an empty run that ended at its time limit, with the session's cookies. The agent server then marks the stop and gives the status the stop asked for, as for a run that a stop ended. Missing output from a runner that did launch still fails the activation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): report the live turn of a run stopped around a compaction The previous commit kept no summary reply, but a run cut during a compaction still lost its last turn. Stirrup takes its history snapshot at the start of each turn and summarizes after the turn has answered. So during a summary request, the snapshot does not hold the turn that just ran, and the output was empty or ended with that turn's call without its answer. The runner now watches Stirrup's step, as it watches summarize_messages. It keeps the message list that step gets, which Stirrup extends with the answered turn, and keeps a reply only when its request is that list and only while step runs. On a cut, it reports that live list and the running turn's reply. A summary request sends a new list, so its reply is never kept. The test covers a cut after a summary, in the second summary attempt and in the first. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): answer a stop that ends the runner while it starts The runner installs its SIGTERM handler only after its imports. A rollout stop in that window ends the runner before it writes its report, and the activation still failed with "Stirrup sandbox runner exited without output". collect now also returns the empty stopped report when the session expired (a stop that the supervisor acted on) and the runner left no output file. A runner that crashed, or a deadline that ended it with no stop, still fails the activation. The report helper is now _stopped_without_output, since it covers both windows. Tests: a stop after the seed and before the run answers as an empty stopped run with no observation gaps. A runner that never gets past its start answers as an empty stopped run when a stop ended it, and fails when its deadline did. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * refactor(stirrup_agent): drop recover_from_context_overflow Stirrup reads this option only when the client raises ContextOverflowError, and the client raises it only with context_overflow_recovery on. With that option off, its default, Stirrup drops no turn whatever this option says. With it on and this option false, the episode ends at the first overflow, as it does with context_overflow_recovery off. So the option added no behavior, and a training config needs only context_summarization_cutoff: null. This removes the field, its payload key, the runner argument, its README row and paragraph, and its test cases. Draft #5835 adds the same option. No release has it, so no removed-option entry is needed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(stirrup_agent): bound context_summarization_cutoff at 1 Stirrup compares the cutoff with the last call's tokens divided by the context window, and it does not reject a value above 1. Such a value fires only when one call uses more tokens than the window. So a percent such as 70 turned compaction off with no error. The field now accepts values above 0 and at most 1, and null still never summarizes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * docs(stirrup_agent): name the other history rewrites, and fix the Stirrup config's network note The Stirrup README section on keeping the recorded history now also names truncation_recovery, which sends one call with an instruction that the history never records. It also names the two rewrites that stay: an assistant turn with no parsed tool call loses its tool-call text, and reasoning that comes back in its own field is not sent back. The header of officeenv_sandbox_stirrup.yaml said that Stirrup's sandboxes need the package index. The agent server builds Stirrup's Python runtime on its own host and uploads it, so the sandboxes need no internet. Only the host needs the package index. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * feat(single_agent_turn): drive the agent one step at a time and end the episode on the task state A resources server whose task ends through its state, rather than through one tool's call, can now have its episode end right after the step that ended the task. OfficeEnv's task ends when its user app's task row leaves pending, which several operations reach, depending on how a row exposes its apps. - single_agent_turn: max_episode_steps drives the agent one step per activation, up to that many steps, and end_on_task_state reads the resources session's task state between steps (GET /task_state, ResourcesTaskState in nemo_gym.server_runtime). Each step's failure report is kept. The server checks at startup that its agent keeps a session, runs the tools it calls and stops after one step. Driven episodes take part in checkpoints as restarts (BaseEnvironmentServer.checkpoint_mode_in_effect). - simple_agent: with x-ng-agent-episode-step-limit, a step stopped by its own one-step limit counts as completed unless it is the episode's last, and the session keeps one invocation for the episode, as the agent's own loop does, instead of one per step that repeats the whole history. - OfficeEnv: GET /task_state answers ResourcesTaskState; close_tools_on_task_end refuses the calls a step makes after the one that ended its task; its rows route by taskset to single_agent_turn with the step loop on, and the config allows only the simple agent. A retired attempt no longer keeps its episode, so its replacement can seed the same session ID. The server runs OfficeEnv 1.14.0 (1.13.0 at least), with its example rows emitted again. Signed-off-by: Daniele Molinari <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(single_agent_turn): run the step loop's tests in the core suite, and keep a simple_agent subclass in step CI on the step loop found two things: - agentic_turn_simulation_agent overrides simple_agent's _create_episode, which now takes step_limit_owned_by_caller. The override accepts it; only an agent session sets it, and this agent refuses those. - The core coverage gate counts single_agent_turn's and simple_agent's app.py, but the step loop's tests ran in the server suite only. They move to the core suite unchanged, and simple_agent's step limit and invocation folding get core tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(single_agent_turn): import each name in the moved step-loop tests from the module that defines it Tests under tests/ import from the defining module, not a package's public API, and test_the_librarys_tests_import_from_the_module_that_defines_each_name failed on the two files this PR moved into the core suite. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(simple_agent): one step per activation that names the episode's step limit, counted by its index With x-ng-agent-episode-step-limit, the agent takes one step (one model call and the tool calls it makes) whatever its max_steps says, so a pairing no longer needs max_steps: 1, which composition drops when --agent-type simple_agent replaces the environment's agent. Requests without the header run as before. - The step is the activation's index (x-ng-agent-activation), which such a caller sends with every step, not the count of requests, so a step resent after a dropped connection is not counted as the next one. - The session keeps the model server's cookies from step to step, so the episode keeps one model server session. - A step that raises ends the episode's folded invocation as failed (or incomplete when cancelled), not with the completed status of the step before. - The step keywords go to _create_episode only with the header, so an override that predates them keeps working; agentic_turn_simulation_agent's override no longer needs to accept one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(single_agent_turn): drive only agents that take one step per activation, and keep what the steps did - STEP_DRIVEN_AGENT_TYPES (nemo_gym.config, beside AGENT_SESSION_AGENT_TYPES) lists the agent types that take one step per activation that names the episode's step limit: simple_agent. The startup check refuses any other type, such as hermes_agent or browsecomp_agent, which keep a session but run their own loop in an activation; a unit test keeps the list in step with the agent apps. The check no longer reads max_steps, and reads execute_tools as the agent's config does, so a string "false" is false. - A failure after a step completed keeps the completed steps, their output and summed usage, as its partial response, unless it already carries one; a failure before the first reply has none. - An episode that runs out of steps with every step calling a tool says so in its reply's metadata (ng_termination_reason: max_episode_steps). Its status stays the last step's: incomplete_details names only the model's own cutoffs, and an incomplete reply would read as malformed to rollout recovery. - The task state is not read after the last step, which ends the episode either way. - GET /task_state answering 404 with failure_kind session_lost ends the episode, which goes on to /verify and its masked lost-session result, as when a tool call finds the session gone. Other failed reads fail the episode as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(server_runtime): an environment server's checkpoint mode in effect sets its participant and its episodes A server whose class declares exported but whose instance runs as restart_only installs a restart_only participant, and its episodes begin as restarts; an unknown mode in effect stops the server at setup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): run on single_agent_turn_legacy, so flat rows and session-less agents run too single_agent_turn's /run takes only episode requests, so flat rows (training corpora, rows routed by their agent) failed. single_agent_turn_legacy takes flat rows and taskset episodes, and runs the same step loop: OfficeEnv keeps max_episode_steps 50, end_on_task_state, direct HTTP tools and the example taskset's route, and the simple agent no longer sets max_steps: 1. Composition's fallback relays an agent without agent sessions through legacy_agent to its own /run, so allowed_agents also admits simple_agent_with_compaction; the relay takes flat rows, not the taskset's episodes. The test that restated the YAML (skipped in CI with OfficeEnv absent) gives way to core tests that resolve the config with a model and build its environment server: as shipped, with simple_agent.yaml added as --agent-type simple_agent does, and with the compaction agent's config, where the server becomes a legacy_agent relay. The config comment and README say what --agent-type and allowed_agents do, and that rollout_recovery.target_level: sibling applies to the whole training run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs: GET /task_state and the episode step-limit header The Seed/Verify Protocol Extensions table lists GET /task_state, its reply, and what a 404 or 5xx does to the episode. The agent integration page describes x-ng-agent-episode-step-limit beside x-ng-agent-activation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(core): LentSandboxes lends a sandbox with its own image, environment and setup, and releases all within a deadline What the OfficeEnv sandboxed server needs from core's lent sandboxes, so it builds on them instead of a copy: - lend() takes a per-sandbox image, more environment variables and a setup that runs against the started sandbox, its files delivered, before it is lent (start_with_setup); a setup that fails stops the sandbox. - The start runs to its end once begun, within start_timeout_s (30 minutes by default), even while the request that asked for it is cancelled: a create cut in flight leaves a sandbox whose id the provider never returned. A lend cancelled meanwhile lends nothing and stops what it started, and says so in the log. - release_all(timeout_s=...) refuses new lends (503) from its start, waits for those still starting, stops everything within the deadline, and returns and logs the sessions whose sandbox may still run, for a reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv): run OfficeEnv episodes in a sandbox, for Gym's sandboxed harnesses resources_servers/officeenv_sandbox's OfficeEnvSandboxResourcesServer subclasses the OfficeEnv server and lends each episode session a sandbox through LentSandboxes (an operate descriptor: the harness uses it, only the server stops it), stopped before the episode is graded. - The harness reaches the apps as the row's exposure says: MCP tools, a command per app (cli), or endpoints it finds over MCP and calls with curl (api_search). - File content stays out of the conversation through OfficeEnv's workspace mode: downloads land in the workspace, uploads and attachments name a workspace file, and a file API moves bytes directly. - The sandbox sees an ordinary company API. Only Gym's servers on this node (any of the node's own addresses) and trusted_networks reach seeding, closing, verification, metrics, the reverify mode, the app catalog, the task state and the tool routes, which answer others 404 before reading a body; sessions are signed with a per-process secret. - Seeds take turns, and a seed is admitted again before it lends; a close or a retire stops the sandbox, a failed seed's stop is tried again at its session's close, and shutdown stops everything within the run's grace. - A sandbox provider failure fails the call (502) and masks the episode's reward. - Configs for Pi (Docker and OpenSandbox), Codex CLI, mini-SWE, OpenCode, OpenClaw and Terminus 2; nine sandbox tasks (OfficeEnv 1.14.0), the first five as example rows with Pi's rollouts of them; images and a README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes logs a start its limit cut before the provider returned the sandbox's id When start_timeout_s cuts a provider's create in flight, the sandbox's id is unknown, so the lend's stop cannot reach what the create left. The lend now logs that cut at ERROR with the resources session, the task (id and taskset), the provider, the image and the labels, so a reaper can find the sandbox. A start cut after the create returned stops its sandbox as before and asks for no reaper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): name each harness's instances after it, so harness configs compose in one run Every harness config defined `oe` and `single_agent_turn_legacy`, so two of them could not run together. Now: - the episodes' resources server is officeenv_sandbox_resources_server; - each config adds officeenv_sandbox_<harness>_agent (`_inherit_from` Gym's instance of the harness, as benchmarks do) and officeenv_sandbox_<harness>_environment_server (`_inherit_from: single_agent_turn_legacy`); - Pi, Codex and OpenCode, which name MCP tools their own way, run on their own copy of the episodes' server (officeenv_sandbox_<harness>_resources_server, `_copy` with its mcp_tool_prefix); the other harnesses run on the shared one. A copy takes the shared server's settings from the merged config, so one override reaches every harness. The interpolations, the documented overrides, the probe script and the README follow (a table of the names; the OpenSandbox config is listed after the other harness configs, since a later one pulls the episodes' config in again). A core test resolves each config alone and all six together with a model config, and replaces the server test that restated their YAML; it needs no OfficeEnv, so it runs in CI. The OpenCode and OpenClaw configs and the README no longer say those harnesses refuse MCP tool grants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): sandbox_config.start_timeout_s bounds a sandbox's start; host_relay needs trusted_workstation - sandbox_config.start_timeout_s (1800 s by default, a finite number above 0) is passed to LentSandboxes, which fails the seed at that limit and logs a create it cut for a reaper. The README says when to raise it: creates on a busy OpenSandbox cell have taken up to 2,430 s. - host_relay forwards sandbox connections from the host's loopback, which the caller check takes for Gym's own servers, so code in a sandbox could call the routes kept for Gym for any session. Config validation now refuses host_relay unless sandbox_config.trusted_workstation is true, which a config sets only on a single-user workstation; its description and the README state the risk. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): officeenv_sandboxless.yaml runs the OfficeEnv server's instances under names of their own It composes resources_servers/officeenv/configs/officeenv.yaml and copies (`_copy`) its three instances as officeenv_sandboxless_resources_server, officeenv_sandbox_simple_agent and officeenv_sandbox_environment_server, each copy pointing at the other copies, while the OfficeEnv server's instances keep their names. The copied agent declares no dataset, so the example rows and their taskset stay with the OfficeEnv server's instances, and rows that name officeenv_sandbox_simple_agent (flat rows, agent_ref) route to the copied environment server. A `_copy` takes its source as written, before the source's own `_inherit_from` applies, so the environment server is copied as the instance of the server type officeenv_environment_server inherits, with that server's own settings for it on top. The core test checks each copy against its source, references aside, alone and beside the Pi and Codex configs, so a change to the source's server type fails it rather than leaving the copy behind. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): the sandboxless arm copies single_agent_turn_legacy, which the OfficeEnv server now runs officeenv_environment_server inherits single_agent_turn_legacy now, so the copy takes that instance, then the server's own settings for it under that type, with its references still pointing at the other copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): every harness runs the episodes' server under its own name, so none is left idle Each harness config now adds officeenv_sandbox_<harness>_resources_server with `_inherit_from: officeenv_sandbox_resources_server`, OpenClaw, mini-SWE and Terminus 2 included, and no harness names the episodes' server. `_inherit_from` reads it from the merged config and takes it out of the run, so a run of one or several harness configs starts no idle episodes' server, while the episodes config alone still runs it under its own name. Settings on the episodes' server, the OpenSandbox config's included, reach every harness's server. The OpenSandbox config still goes after the other harness configs (the first harness config listed pulls the episodes' config in), and the README now says why. The core test checks that no episodes' server starts or is named beside the harnesses', alone and with all six, and that the episodes config runs on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): the cut-start log says OpenSandbox deletes what an abandoned create left Main's OpenSandbox provider now deletes the sandbox of a create its caller gave up on (#4799), so a start that LentSandboxes' start_timeout_s cuts before the provider returned the sandbox's id no longer needs a reaper there. The ERROR log, LentSandboxes' docstring and the officeenv_sandbox README now say so, and keep the reaper for providers without that cleanup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(officeenv_sandbox): Pi's run ends once its task has ended, on every exposure - The sandboxed server holds the call that ends a watched episode's task, on every way in (tools, commands, endpoints, the file API), until the environment server releases it; the episode's lock is let go first. Only Gym's node reaches GET /task_state and POST /task_state/release. - Pi supports POST /rollouts/{rollout_id}/stop (_rollout_sandbox_session): a run stopped as completed answers so, marked in ng_rollout_stop, and is not reported as a wall-time timeout. - The Pi config sets end_on_task_state on its environment server and drops finish_tool_names (now []): the stop ends the run on cli and api_search rows too, which offer no finish tool. Its comment no longer asks cli rows to drop the MCP transport, which they run with as it is. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs(officeenv): the servers run OfficeEnv 1.14.2 1.14.2 is the OfficeEnv release N4's training runs grade with. 1.14.1 and 1.14.2 are patch releases; neither changes the API these servers use. The READMEs' install lines name it, and the example rows are emitted again by it (officeenv emit for resources_servers/officeenv, sandbox/prepare_rows.py for officeenv_sandbox), which changed only their version stamp. The example rollouts stay the ones collected against 1.14.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv_sandbox): refuse calls after the task ended with ResourcesSessionConflictError Main's session contract (#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. The sandboxed server refused a tool call once verification began, and a file API call once the episode's files closed, with plain HTTPException(409)s; both now raise the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(core): LentSandboxes shields a start only with start_timeout_s Main's opencode_search (#6211) lends through LentSandboxes and expects a seed cancelled while its sandbox starts to stop that sandbox at once, as LentSandboxes did before this branch; the shielded start made it wait for the start's end. The shield is now opt-in. Without start_timeout_s a cancel cuts the start as it cuts any await, as on main, and the lend stops the sandbox it began. With it, the start runs to its end within that limit, which the OfficeEnv sandbox server sets (sandbox_config.start_timeout_s, 1,800 s by default). START_TIMEOUT_S goes, since no default limit remains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * build(officeenv_sandbox): lock against main's upgraded dependency locks Main's lock upgrade (#6528) moved the root lock, and `uv sync --locked` refused the sandboxed server's older lock, so neither its suite nor a run could start it. `uv lock` with uv 0.13.4 takes the root lock's versions (e2b 2.50.0, protobuf-py 0.1.1, pyqwest 0.10.0), keeps the tzdata OfficeEnv pins (2026.6), and passes scripts/component_locks.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(core): a cut start's test counts the closes the provider made Main's #6410 changed the stopped fixture from AsyncSandbox.stop calls to the closes the provider made. A start cut before the provider returned its sandbox's id leaves nothing to close, so the hung-start test now expects none, as the ERROR line it checks says. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * feat(single_agent_turn): stop an agent's own loop once its task has ended With end_on_task_state and no max_episode_steps, single_agent_turn now ends an agent that runs its own loop (a sandboxed harness) at its task's end, as the step loop ends a step-driven one: - Before the agent runs it reads GET /task_state?watch=true; while the agent runs it reads again, each read waiting up to 30 s (wait_s). - Once the task has ended it stops the run with POST /rollouts/{id}/stop {"reason": "task_ended", "completed": true}, waits for the activation to answer (at most 120 s), then posts /task_state/release. - The resources server holds its answer to the call that ended the task until that release, so the harness never reads it while its run could go on, and no model call follows the call that ended the task. - The server refuses at startup an agent type outside ROLLOUT_STOP_AGENT_TYPES (the agents whose runs the stop route can end; a unit test keeps the list in step with the apps). Core: RolloutStopRequest.completed; such a stop answers as completed (report_rollout_stop) and says so in ng_rollout_stop. Docker uploads take a bound of their own, so a stop's marker never waits for the exec slot a running harness holds (uploads_independent_of_execs). OfficeEnv: GET /task_state takes watch and wait_s (at most 60 s); POST /task_state/release; task_end_hold_seconds (180) bounds the hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(officeenv_sandbox): the stand-in sandbox stops as main's AsyncSandbox.stop does Main's #6410 moved the shielded, bounded stop into AsyncSandbox.stop(timeout_s=...), which LentSandboxes now calls. The tests' FakeSandbox.stop took no timeout_s and had no shield, so a seed or close cancelled during a stop failed or hung. FakeSandbox.stop now takes timeout_s and shields its provider-side _stop, as AsyncSandbox.stop does, and the tests that slow down, refuse or hang a stop patch _stop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * test(cline_agent): the fake sandbox session carries expire_completed report_rollout_stop now reads SandboxSession.expire_completed (a run stopped once its task has ended answers as completed), so the stand-in that Cline's session tests use carries it too, as the real session does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * refactor(officeenv_sandbox): sign sessions with Gym's run secret #6161 now makes a secret per server and run in server_runtime, which every worker of the server shares (signs_sessions_with_run_secret). The sandboxed server sets that flag instead of minting its own secret in model_post_init and overriding get_session_secret(): its cookies and MCP tokens are signed, as before, with a secret code in a sandbox cannot derive from the server's name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * fix(officeenv): refuse a tool call after the task ended with ResourcesSessionConflictError Main's session contract (#5691) has every 409 a resources server answers raise ResourcesSessionConflictError, and tests/unit_tests/test_session_contract_repo.py checks it. With close_tools_on_task_end, the OfficeEnv server refused a call after the task ended with a plain HTTPException(409); it now raises the named error. The status and the detail are the same, so callers see no change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Daniele Molinari <[email protected]> * docs(officeenv_sandbox): say when the task-end stop ends a Stirrup run Stirrup cannot run without a finish tool, so with its default finish tool most runs end when the model calls finish. The environment server's task-end stop ends a run that calls `user complete-task`, before its next model call. Pi's config sets finish_tool_names: [], so for Pi the stop is the normal end. The README now says so. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(core): release_all stops the lent sandboxes while a lend is still starting release_all waited for every start in flight before it stopped any lent sandbox, all inside one time limit. One slow start at shutdown then left every lent sandbox running until its TTL. Now the lent sandboxes stop at once, and each starting sandbox is stopped when its start ends. The new test fails before this change (no sandbox stopped) and passes after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]> * fix(officeenv_sandbox): keep the agent and environment servers on 127.0.0.1 NeMo RL sets default_host to the node's address, and an explicit default_host applies to every server, not only to the types in absolute_ip_server_types. A sandbox's network rule opens every port of an allowed host. So code in a sandbox could call the agent and environment servers: run Pi on Gym's host (/v1/responses without a session), start episodes (/run) and stop another episode's run (/rollouts/{rollout_id}/stop). Each harness config now sets host: 127.0.0.1 on its agent and its environment server. No sandbox calls them: each harness in a sandbox calls only the model server and the resources server, and NeMo RL calls /run from the same node. Without default_host, Gym already binds them to 127.0.0.1. The comment in officeenv_opensandbox.yaml and the README now say this. The new config test resolves every harness config under default_host: 10.0.0…
Summary
This PR moves the
opencode_searchBrowseComp resources server onto the Environment Server. One resources server now backs two presets:benchmarks/browsecomp/configs/browsecomp_opencode.yamlruns BrowseComp onopencode_agentsessions, in a sandbox that the resources server lends to each episode.benchmarks/browsecomp/configs/browsecomp_opencode_legacy_agent.yamlkeeps the existing relay throughlegacy_agentandopencode_sandboxed_agent.What changes for current users
browsecomp_opencode.yamlnow selects the sessions preset. Launches that need the relay must switch tobrowsecomp_opencode_legacy_agent.yaml. Server and agent instance names are unchanged.main, the row scores 0 and counts. It now also recordsfailure_kind: judge_unparseableand a reason. Training can mask these rows instead by settingunparseable_verdict_policy: mask, the same settingwebvoyager_judgeuses.failure_kindandfailure_reason.compaction.reservedon an OpenCode 2 binary is refused, and the error namescompaction.buffer.compaction.reservedapplies to OpenCode 1.x only.default_episode_timeout_seconds: 21600, which matches its agent'ssandbox_timeout.Evidence
Full BrowseComp runs (400 questions) used a real policy, a real judge and a real sandbox provider. Both runs used the same checkpoint and settings: compaction at 192k tokens, Exa for search and fetch, bash disabled, and no search cache.
Review response
Thanks for the review. All seven points are addressed in the latest push, and the branch is merged with current main.
Also changed: