Repository navigation
Conversation
With num_workers > 1, each uvicorn worker imports the server's entrypoint and serves its module-level app. Most resources, agent and environment servers had no such app, so every worker exited at startup and uvicorn stopped the server. Every server that is safe with several workers now ends its entrypoint with it. For langgraph_agent that is its four entrypoint modules, and for langchain_deepagents_agent it is reasoning_search_agent.py. The langgraph configs and environment pairings no longer pin one worker. interactive_browser, swebench_pro and terminal_bench_2_1 no longer refuse several workers. Their per-session state is keyed by the session cookie or by resources_session_id, and session routing sends an environment server's cookieless seed and close by resources_session_id to the worker that holds the session. An opt-in end-to-end test runs interactive_browser with two workers and real browsers. It seeds through each worker's private socket in turn, so both workers hold browsers whichever worker the TCP listener picks, and checks that a cookieless retried seed, a conflicting seed, a close and a late seed each act on the worker that holds the browser. miniswe_sandboxed_agent drops its num_workers: Literal[1] for episode sessions, which are routed by agent_session_id, and refuses several workers when a resources_server enables its own /run path, which replays a retried run from process memory keyed by the cookie's session_id and the rollout ID; and harbor_oracle_agent drops its own num_workers check, because its sessions are agent sessions, which routing follows. browsecomp_agent drops the num_workers: Literal[1] main gave it with its sandboxed session harness, for the same reason. The CI job for the routing tests now builds interactive_browser's environment and Chromium, so its two-worker test runs there instead of skipping. tool_simulation_agent's own /run path calls its /v1/responses, which activates the episode this worker holds. The call now names this worker in x-ng-session-owner, as simple_agent's does, so with several workers it returns here instead of restarting the rollout on another worker. nemo_user_sim keeps a closed session's tombstone for session_ttl_seconds, 1980 seconds by default, while a closed session keeps its owner only session_close_retry_window_seconds after the close. It now keeps its owner for the longer of the two, so with several workers a delayed seed still reaches the worker that holds the tombstone and is refused there. interactive_browser, swebench_pro and example_single_tool_call already keep closed sessions in ResourcesSessionFences, which forgets a close when the session's owner expires. The Claude Code, Codex, CVDP, Kilo Code, OpenClaw, OpenCode and Pi agents install their command line tools on first local use, into one shared directory per agent, so the first calls in several workers raced. Each install now runs under nemo_gym.utils.install_lock beside the install directory, and checks inside the lock for an install another worker finished. The record names the version it installed and is reused only for that version, so a changed pin reinstalls instead of running the old tool. The Node.js toolchain and the CVDP runtime are reused only when a marker written last says the install finished, so an interrupted install is redone from an empty directory. Cline and AnyTerminal install before uvicorn starts the workers, and a comment at each install states that ordering. interactive_browser counts Chromium as installed only once Playwright marks the install complete, and iheval fetches its IFEval corpus in the main process before the workers start. Other servers that are safe with several workers needed a change: - finance_sec_search divides requests_per_second among the workers, so the server as a whole stays within SEC.gov's rate limit, and refuses more workers than requests_per_second, where a worker's share would round to zero; - legal_agent_bench rebuilds its runtime task tree only in the main process, which runs setup_webserver before uvicorn starts the workers; - the proof_genselect, proof_verification and competitive_coding_challenges debug logs take a file lock around each append, and still write the record on a filesystem without file locks; - tavily_search and browsecomp_advanced_harness write one session metrics file per worker at exit, named by the main process and the worker, and the plot script reads one run's files; - finance_agent_v2 and finance_sec_search configure their logging in the workers too; - opencode_search, indian_banking, competitive_coding_challenges, agentic_mme and agentic_mme_agent say which caches, counters, concurrency limits and memory are per worker. Signed-off-by: Ananth Subramaniam <[email protected]>
Some servers keep state that session routing cannot reach, or own a resource that one process must hold, so they cannot run with several workers. They now override multiple_workers_unsupported_reason(), and run_webserver refuses num_workers > 1 with that reason before uvicorn starts: - aviary and toolsandbox keep environments in memory by the env_id in the request body, and their agents send step, verify and close without the session cookie; - critpt pools verify calls in memory into batches submitted together; - osworld owns the Docker host capacity, startup cleanup and its state file; - longmt_eval builds a Ray GPU actor pool per worker; - gdpval claims deliverable directories in memory by task and rollout ID; - terminal_bench_4 deduplicates seeds by the client_session_id and rollout_id in the request body; - vlm_eval_kit waits in memory for every row of an MMBench group; - voicebench's legacy scoring draws every rule-scored row from one random stream shared by the whole server; - enterpriseops_gym sessions and the partner_if mock-tool episodes are process-local, agentic_if sessions hold their sandbox connections in one process, and the officeqa document sandboxes and partner_if SWE actor sandboxes live in the server's memory; - the Legal Agent Bench Harbor bridge has an entrypoint outside its server directory, which uvicorn workers cannot import. speed_bench, wmt_translation, proof_judge, genrm_compare, ns_tools and terminus_2_sandboxed_agent refuse only in the configurations that need one process, and get the module-level app otherwise: speed_bench with the Prometheus metrics source, which measures from a snapshot in memory; wmt_translation with COMET, which builds a Ray GPU actor pool per worker; proof_judge with zero_reward_incorrect_groups; genrm_compare with cohort verification; ns_tools with the HTTP PythonTool sidecar on a fixed port; and terminus_2_sandboxed_agent without a resources server, which serves only process-local episode sessions. proof_judge's debug log also takes a file lock around each append, and still writes the record on a filesystem without file locks. The checks that did this job in model_post_init, in config validators and as num_workers: Literal[1], including those main added to voicebench, enterpriseops_gym, agentic_if, officeqa, the partner_if mock tools and SWE server and terminus_2_sandboxed_agent, become the method with the same conditions. gdpval, voicebench, the partner_if mock tools and speed_bench check the refusal at the start of model_post_init as well, before they install dependencies, load their backend or take a metrics snapshot, so a misconfigured server fails on the worker count rather than on that setup. A unit test reads every server entrypoint without importing it, including the entrypoints configs name outside app.py, and fails when a server has neither the module-level app nor a refusal. It fails on the parent commit. Signed-off-by: Ananth Subramaniam <[email protected]>
…rom public packages Servers imported the multi-worker helpers by submodule path, against the rule that code outside nemo_gym imports public names from a package's public API. - Rename nemo_gym.utils.install_lock to nemo_gym.utils.local_install, so the install_lock function can be exported from nemo_gym.utils without colliding with the submodule of the same name. The module first ships in 0.8.0, so only the old nemo_gym.install_lock path and its docs redirect need to point at the new name. - Export install_lock, async_install_lock, record_install and adopt_recorded_install from nemo_gym.utils. - Export refuse_unsupported_num_workers from nemo_gym.server_runtime. - Move the agent installers, servers and server tests to these imports. Fixes #5980. Signed-off-by: Ananth Subramaniam <[email protected]>
The library reference already serves nemo_gym/utils/install_lock from main, so redirect it to nemo_gym/utils/local_install instead of leaving it to 404. Signed-off-by: Ananth Subramaniam <[email protected]>
Contributor
ananthsub
marked this pull request as draft
November 11, 2026 00:18
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
ananthsub
force-pushed
the
ananthsub/multi-worker-refusals
branch
4 times, most recently
from
November 13, 2026 19:00
05af882 to
c0c8e81
Compare
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Fixes #5980. Stacked on #4885: review and merge that first, and this PR then retargets to
main.The multi-worker PRs import their helpers by submodule path, which goes against the AGENTS.md rule that code outside
nemo_gym/imports public names from a package's public API. This PR exports those helpers and moves their callers to the public imports.nemo_gym.utils.install_lockbecomesnemo_gym.utils.local_install. Exporting theinstall_lockfunction fromnemo_gym.utilswould collide with a submodule of the same name: once that submodule is imported, the package attribute is the module, not the function. The module first ships in 0.8.0, so no released path breaks. The old pathnemo_gym.install_lockinnemo_gym/_moved_paths.pyand its docs redirect infern/docs.ymlnow point at the new name. The module's unit test and its CI durations entry are renamed to match.nemo_gym.utilsexportsinstall_lock,async_install_lock,record_installandadopt_recorded_install.nemo_gym.server_runtimeexportsrefuse_unsupported_num_workers.setup_*.py) andcvdp_agent;finance_sec_search,gdpval,speed_bench,voicebenchandpartner_ifservers;Code inside
nemo_gym/and its tests still imports from the defining module, as the import rules require.Compatibility
No import breaks. Every name keeps its object, and the old path
nemo_gym.install_lockstill resolves (with its deprecation warning) to the renamed module.The library reference on main already serves a page for
nemo_gym/utils/install_lock.fern/docs.ymlnow redirects that page, with and without the version slug, tonemo_gym/utils/local_install, so existing links keep working.Two open PRs against main add the submodule import this PR retires,
from nemo_gym.server_runtime.base_server import refuse_unsupported_num_workers: #5839 and #5371. Once this PR merges, the public API check fails on them until they switch tofrom nemo_gym.server_runtime import refuse_unsupported_num_workers.Validation
git grepfinds no submodule imports of these helpers outsidenemo_gym/.pre-commit run --fileson the changed files passes, and the docs link and redirect checks pass with the new redirects.Rollout evidence
N/A: this change only moves imports and renames a module that has not shipped in a release, so server behavior does not change.