Skip to content

feat(server): run servers whose sessions routing reaches with several workers - #5988

Draft
ananthsub wants to merge 2 commits into
mainfrom
ananthsub/lift-multi-worker-refusals
Draft

ananthsub wants to merge 2 commits into
mainfrom
ananthsub/lift-multi-worker-refusals

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Lets fifteen servers run with several uvicorn workers. Each one keeps its session state in memory, keyed by a session ID that session routing (#3905) follows, so a second worker loses nothing. This PR runs in parallel with #4885, which makes the remaining servers refuse several workers through multiple_workers_unsupported_reason(). The two PRs change different files.

Merge this PR before #4885, or together with it. #4885 adds a contract test that every server entrypoint either serves a module-level app or refuses several workers through multiple_workers_unsupported_reason(). On main, agentic_if, officeqa, vibench, webvoyager_judge, web_agent, droid_agent and openhands_agent have neither, so #4885 alone fails that test. This PR gives each of them the module-level app.

What changed

Session routing sends each session's requests to the worker that holds it. So a server whose per-session state is keyed by a session ID that routing follows does not need to refuse several workers. This PR has two commits.

The first lifts seven servers that raised in model_post_init when num_workers > 1:

Server State Key that routing follows
enterpriseops_gym Gym sandboxes and verifier results per task session resources_session_id, which is also the cookie's session_id
partner_if mock tools (mock_tools_app.py) Episodes, with their tool backends and recorded calls resources_session_id and the cookie
partner_if SWE (swe_app.py) Seeds and actor sandboxes, in maps inherited from scale_swe, which already runs with several workers resources_session_id and the cookie
officeqa Document sandboxes resources_session_id and the cookie
vibench Build sandboxes and harvested app copies resources_session_id and the cookie
agentic_if Episodes, with their task-backend sessions and grading state resources_session_id and the cookie
terminus_2_sandboxed_agent Episode sessions' borrowed sandboxes agent_session_id

The second covers eight servers that main added or changed since. Each one either refused several workers or had no module-level app, so with several workers each uvicorn worker failed at import:

Server State Key that routing follows Change
webvoyager_judge None: the grade reads only the request None needed Module-level app
web_agent An episode's identity, cookies and artifacts, held only inside its /run None needed Module-level app
droid_agent Agent sessions in the base agent-session records; Droid runs in the session's sandbox agent_session_id Module-level app; config drops num_workers: 1
openhands_agent Agent sessions in the base agent-session records; OpenHands runs in the session's sandbox agent_session_id Module-level app; config drops num_workers: 1
crewai_agent Agent sessions in the base agent-session records; the crew runs in the session's sandbox agent_session_id Refusal removed; config and README drop num_workers: 1
chartography Lent sandboxes; verify stops the sandbox before grading resources_session_id and the cookie Refusal removed
gdp_pdf (sandbox_app.py) Lent sandboxes, kept from seed until close resources_session_id and the cookie Refusal removed; session_release_pending override; config drops num_workers: 1
visual_coding_opencode Lent sandboxes, kept from seed until close resources_session_id and the cookie Refusal removed; session_release_pending override; module-level app

For each server I also checked the following:

  • Retried, conflicting and late seeds, and retried closes. An episode's seed and close take ownership of its resources_session_id or agent_session_id, so they reach the worker that saw the ID first. Each resources server records a closed session in ResourcesSessionFences, built from the same session_close_retry_window_seconds that routing uses. Routing's window starts after the close reply, so a late seed reaches the worker that holds the fence and gets a 409. The agents inherit the same behavior from the base agent-session records.
  • Verify, then close. The environment servers send the close-follows header on /verify, so the session stays on its worker until the close.
  • A sandbox kept past verify. gdp_pdf and visual_coding_opencode keep the lent sandbox after /verify and stop it on /close_session. A /verify without the close-follows header ends routing's ownership one retry window later, so a close after that could reach another worker. That worker would fence the ID and answer 200 while the sandbox kept running until its TTL. Both servers now return True from session_release_pending while they hold the session's sandbox, which keeps routing's ownership until a successful close. fix(routing): keep a resources session's owner while the server keeps its state #6061 adds keeps_session_state for the same purpose but does not touch these two servers. Moving their overrides to keeps_session_state is a follow-up once both PRs land.
  • Shared host resources. None of the servers binds a fixed host port or runs startup cleanup on a shared path, and each worker's shutdown stops only its own sandboxes.
    • enterpriseops_gym downloads its seed archive to a temporary file and moves it into place, so two workers that download at once each publish a complete file.
    • agentic_if writes its evidence under a directory per run.
    • ViBench grades with compose stacks on the host's Docker daemon. Its grading scripts choose the stacks' ports and names, and several grades already run at once within one worker, so a second worker does not create a new kind of collision.
    • droid_agent caches the Droid package on the host. A download writes a uniquely named file and moves it into place, so two workers that download at once each publish a complete file. The agents run their harness, and create its working directories, inside the session's sandbox.
  • Terminus 2. It refused only when resources_server is unset, which is the episode-session mode. Those sessions are agent sessions, which routing follows by agent_session_id. miniswe_sandboxed_agent and harbor_oracle_agent already accept several workers in this mode. The legacy /run path keeps its sandbox in one worker for the length of one request, so it was never affected.

Other changes:

  • Harbor task preparation (nemo_gym/data/tasks/harbor/prepare.py) no longer pins terminus_2_sandboxed_agent to one worker. The generated instance keeps the shipped template's num_workers: 4, so a Harbor run with Terminus 2 now starts four agent workers. The table of keys Gym sets in the Harbor guide now matches the code. Its miniswe_sandboxed_agent row has been out of date since feat(server): run every server that can with several workers #4790 and is removed too.
  • agentic_if's max_concurrent_grades, partner_if's judge_max_concurrency, and the concurrency of crewai_agent, droid_agent and openhands_agent are documented as per-worker limits, as feat(server): run every server that can with several workers #4790 did for other limits. With several workers, the server as a whole allows up to num_workers times as many.
  • The tests that checked each refusal now check that the server accepts several workers. For each server that gains the module-level app, a new test imports the entrypoint the way a uvicorn worker does and gets its app. For gdp_pdf and visual_coding_opencode, a new test checks that the session's ownership lasts through verify and a failed close, and ends with a successful close.
  • The READMEs, docstrings and config comments that said these servers need one worker now say that session routing sends a session's requests to the worker that holds it.

Not in this PR: visual_browser and webarena_browser drive one X display and keep in-process site locks, and misalignment_monitor serves endpoints that carry no routed ID. They keep refusing several workers, and #4885 moves the browser servers' refusal into an override. The num_workers: 1 lines in the goose_agent, kimi_code_agent, cline_agent and simple_strands_agent sandboxed configs are unchanged.

Kept refusals

ViBench still refuses several workers when artifact_dir is set, which configures the legacy relay path (configs/vibench_legacy_agent.yaml).

  • vibench_agent's seed carries no resources_session_id, so routing mints one, and the successful seed opens that session on its worker.
  • The agent never calls /close_session. A relay episode that fails before a successful /verify would therefore leave its worker owning that session until the server exits.
  • With one worker, no ownership is recorded at all.

The override returns None when artifact_dir is unset, so the episode-session config (configs/vibench.yaml) runs with several workers.

Known edge

officeqa, vibench, agentic_if and chartography keep a session's state after a failed seed whose teardown also failed, so that a later close can retry the teardown.

  • Routing keeps such a session on its worker only for the close retry window, which is 300 s by default.
  • If a cleanup close arrives later, it lands on another worker, which fences the ID and answers 200. The sandbox and the map entry on the first worker then remain until shutdown or the provider's TTL.
  • Environment servers close within seconds, so this needs a seed and its teardown to fail and the close to arrive more than five minutes later.

#6061 addresses this in session routing, by keeping ownership while the server still holds state for the session.

#6061 also changes agentic_if/app.py, officeqa/app.py, vibench/app.py and their tests. Whichever of the two PRs lands second rebases onto the other.

Issue

None. #4885's description lists these servers as this PR's scope, so no separate issue is needed.

Validation

Rollout evidence

All runs were local, on one workstation, with Docker sandboxes.

partner_if mock tools with two workers. It needs no sandbox provider.

  • Over HTTP. I started the server's entrypoint with two workers and drove 64 concurrent sessions through it. Each session ran a cookieless seed, a retried cookieless seed, a seed for another episode, two tool calls with the session cookie, a verify, a cookieless close, a retried close, a late seed, and a tool call after the close. The owner files showed sessions held by both workers (22 and 42). Each retried seed and close succeeded, and each conflicting or late seed got a 409. Both tool calls of every session were recorded on the worker that seeded it. Each verify scored reward 1, and each tool call after the close was refused. The server logged no tracebacks.
  • Real rollouts. gym env start with resources_servers/partner_if/configs/mock_tools.yaml, ++partner_if_mock_tools.resources_servers.partner_if.num_workers=2, and nvidia/openai/eccn-gpt-oss-20b as the policy model. Then gym eval run --no-serve on data/mock_tools_example.jsonl, with 8 repeats at a concurrency of 16. All 16 rollouts went through partner_if_mock_tools_environment_server. All 16 scored reward 1, none was masked, and the run recorded no failures.

The lending servers with two workers, over HTTP on real Docker sandboxes. For visual_coding_opencode, chartography and gdp_pdf I started the server's entrypoint with two workers, the Docker sandbox provider, and a 3 s close retry window. I drove 12 concurrent sessions through each. Each session ran a seed that lends a container, a retried seed, a verify with the session cookie and no close-follows header, a wait past the retry window, a cookieless close, a retried close, and a late seed. gdp_pdf ran on a Docker --internal network, as its isolation check requires.

  • Sessions were held by both workers in each server (4/8, 2/10 and 2/10).
  • Every seed, verify and close succeeded, and every late seed got a 409.
  • Before the servers shut down, no container of the run's image was still running.
  • As a control, I removed visual_coding_opencode's session_release_pending override and reran. 8 of 12 sessions' closes reached the other worker, and 8 containers were still running before shutdown.

chartography real rollouts with two workers. gym env start with configs/chartography.yaml, configs/judge_model_openai.yaml and ++chartography.resources_servers.chartography.num_workers=2, with us/azure/openai/gpt-4o-mini as the policy and the judge. Then gym eval run --no-serve on data/example.jsonl, with 4 repeats at a concurrency of 20. All 20 rollouts completed through chartography_environment_server: 3 scored reward 1 and 17 scored 0, none was masked, and the run recorded no failures. The owner files showed both workers holding sessions (17 and 3).

The agents on Harbor with two workers. gym eval run terminal_bench_2_1 --sandbox docker with nvidia/openai/eccn-gpt-oss-20b as the policy model, on fix-git, log-summary-date-ranges and git-multibranch, with 2 repeats at a concurrency of 6. The generated agent instance was set to num_workers: 2.

Agent Episodes completed Masked or failed Sessions held by each worker (owner-file samples)
droid_agent 6 of 6 0 both workers (134 and 22 samples)
openhands_agent 6 of 6 0 both workers (157 and 34 samples)
crewai_agent (--allow-unsupported-pairing) 6 of 6 0 both workers (236 and 226 samples)
terminus_2_sandboxed_agent (4 workers, 4 repeats at a concurrency of 12) 12 of 12 9 masked by the transcript export all four workers (7, 5, 4 and 3)
  • Every episode of the three new agents scored 0 with this model. Each one made model calls from its sandbox: Droid's responses hold the model's reasoning, OpenHands recorded 3 model calls per episode, and CrewAI 1 or 2. Four CrewAI episodes ended failed because the model returned no content (EmptyLLMResponseError).
  • No episode got a 410 or a lost session.
  • The model server must be reachable from the sandbox, because these harnesses call it from inside the sandbox. On a host whose firewall denies incoming traffic by default, allow the Docker bridge to reach the host's bridge address. Before I did, every Droid episode failed before its first model call and every OpenHands model call timed out, with one worker as well as with two.
  • Terminus 2's 9 masked episodes failed the transcript export (harbor:trajectory_export_failed), which rejects NeMoGymResponseMcpCall items. A rerun with one worker gave the same result, so it does not depend on the number of workers. fix(trajectory): export MCP calls the model endpoint returns to ATIF #6060 fixes that export.

Startup with two workers. webvoyager_judge and web_agent started with two workers, and each worker served requests. A full web_agent episode needs the browser resources server and an X display. That server keeps refusing several workers, and web_agent keeps an episode's state only inside its /run.

Compatibility

There is no change for deployments that keep one worker. A config that sets num_workers above 1 for these servers used to fail at startup, except a ViBench config that sets artifact_dir. It now starts. The droid_agent, openhands_agent, crewai_agent and gdp_pdf configs drop num_workers: 1, which was already the default, so they still start one worker. A Harbor run that uses terminus_2_sandboxed_agent now starts its template's num_workers: 4 agent workers instead of one. Setting that instance's num_workers back to 1 restores the old behavior.

@copy-pr-bot

copy-pr-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ananthsub
ananthsub force-pushed the ananthsub/lift-multi-worker-refusals branch 2 times, most recently from 9e4901b to 9bed8e0 Compare November 11, 2026 01:27
@ananthsub
ananthsub changed the base branch from ananthsub/multi-worker-refusals to main November 11, 2026 01:27
ananthsub added a commit that referenced this pull request Nov 11, 2026
The seven servers whose state session routing already reaches get the module-level app in #5988,
which lands in parallel. Refusing them here first and lifting the refusals there would churn the same files.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub marked this pull request as ready for review November 12, 2026 05:47
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 12, 2026 05:48
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP WITH CARE — one RISK: enabling several workers exposes a cleanup path that can return success without releasing the retained sandbox.

I reviewed all 23 changed files and traced the affected session-routing, worker startup, cleanup and Harbor configuration contracts. The finding below consolidates the same ownership defect in OfficeQA, ViBench and Agentic IF.

This was a static review; I didn't execute tests or rollouts. The PR reports real multi-worker smokes for Partner IF mock tools and Terminus 2, but not the other adapters.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

super().model_post_init(context)
if self.config.num_workers not in (None, 1):
raise ValueError("OfficeQA process-local sandboxes require num_workers=1")
self._sessions: dict[str, _DocumentSession] = {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RISK — Keep routing ownership while retained session state needs cleanup

With num_workers: 2, let worker A receive a seed whose sandbox start and cleanup both fail. OfficeQA retains the session so a later close can retry cleanup. ViBench and Agentic IF retain failed setup similarly.

These custom maps aren't included in the inherited session_release_pending() callback, which checks only the base class's verification records. Consequently, routing expires ownership after the failed seed's retry window, despite A still holding resources. After expiry and the ownership sweep, a cookieless close arriving on B sees an empty map, fences the ID and returns 200 without retrying A's cleanup. The retained sandbox then survives until shutdown or the provider TTL; a reseed on B can also allocate another session under the same ID. Removing the worker refusal makes this failure newly reachable. The PR acknowledges this edge, but the successful close still misreports cleanup.

Could these three adapters expose their retained state through the existing callback before enabling several workers? The invariant is that routing must not release an ID while its holder retains session state that close needs. A small suggested addition to both OfficeQAResourcesServer and VibenchResourcesServer is:

def session_release_pending(self, session_id: str) -> bool:
    return session_id in self._sessions or super().session_release_pending(session_id)

For AgenticIFResourcesServer, use its episode map:

def session_release_pending(self, session_id: str) -> bool:
    return session_id in self._episodes or super().session_release_pending(session_id)

These suggestions use the callback already passed to routing by owned_session_routing(). Map membership also covers OfficeQA's retained session when serialization fails after ready=True; checking only not ready would miss that case. Verify the suggested code before adopting it.

Preserve identical successful-seed replay, conflicting episode rejection, retryable failed closes and the normal close fence. A successful close must remove the retained entry and allow ownership to expire after the retry window; a failed seed that retains nothing must still expire normally. Keep ViBench's artifact_dir multi-worker refusal and its one-worker relay behavior.

Proposed acceptance checks, not executed: for each adapter, use two routed app instances sharing an ownership directory and a controlled clock. Inject setup and cleanup failures on A, advance beyond a short retry window and sweep ownership, then close through B. The close must reach A, retry cleanup and remove A's retained entry before returning 200; reseeding before cleanup must not allocate on B. Repeat OfficeQA with serialization failure after startup. After successful cleanup, check ownership expiry, 409 for conflicting closes and late seeds within the fence window, and normal expiry for a failed seed with no retained state. Retain the cleanup assertions in OfficeQA's failed-start/release test, ViBench's failed-setup test and Agentic IF's failed-release test, plus ViBench's relay worker-count assertions.

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 13, 2026
ananthsub added a commit that referenced this pull request Nov 13, 2026
The seven servers whose state session routing already reaches get the module-level app in #5988,
which lands in parallel. Refusing them here first and lifting the refusals there would churn the same files.

Signed-off-by: Ananth Subramaniam <[email protected]>
… workers

enterpriseops_gym, officeqa, vibench, agentic_if, partner_if's mock-tools
and SWE servers, and terminus_2_sandboxed_agent refused num_workers > 1
because their sessions live in process memory. Each of them keys that
state by a session that session routing follows: the resources servers by
resources_session_id, which is also the cookie's session_id, and Terminus
2's episode sessions by agent_session_id. Seeds, retried seeds, closes and
late seeds all reach the worker that saw the session first, and each
resources server fences a closed session for the close retry window,
which routing's ownership outlasts. None of them binds a fixed host port
or shares a temporary path between workers.

So these servers drop their refusals. officeqa, vibench and agentic_if
gain the module-level app that each uvicorn worker serves; the others
already had it. Harbor task preparation no longer pins Terminus 2 to one
worker, so its generated instance keeps the shipped template's workers.

ViBench still refuses several workers when artifact_dir configures the
legacy relay path: vibench_agent's seed opens a routed session that the
agent never closes, so a relay episode that fails before a successful
verify would leave a worker owning that session until the server exits.

agentic_if's max_concurrent_grades and partner_if's judge_max_concurrency
are now documented as per-worker limits; the judge's model server bounds
its own load. The tests that checked each refusal now check that the
server accepts several workers, and officeqa, vibench and agentic_if test
that a worker imports their module-level app. The READMEs and the Harbor
guide no longer say these servers need one worker.

Signed-off-by: Ananth Subramaniam <[email protected]>
Servers that main added since this branch's first commit either refused
num_workers > 1 or had no module-level app, so with several workers each
uvicorn worker failed at import. Session routing reaches all of their
per-episode state:

- webvoyager_judge keeps no state, and web_agent keeps an episode's state
  only inside its /run. Both gain the module-level app.
- droid_agent and openhands_agent keep each agent session in the base
  agent-session records, which routing follows by agent_session_id, and
  run their harness inside the session's sandbox. They gain the
  module-level app, and their configs drop the num_workers: 1 pin.
- crewai_agent drops its num_workers check for the same reason, and its
  config and README drop the pin.
- chartography drops its refusal. Its lent sandboxes are keyed by
  resources_session_id, and verify stops the sandbox before grading.
- gdp_pdf's sandbox server and visual_coding_opencode drop their
  refusals, and visual_coding_opencode gains the module-level app. Both
  keep a lent sandbox from seed until close, past a verify that has no
  close-follows header. They now report that sandbox through
  session_release_pending, so routing keeps the session on the worker
  that holds it until the close stops the sandbox. Without that, the
  close could reach another worker after the close retry window, and the
  sandbox would run until its TTL.

The agents' concurrency limits are documented as per-worker limits. The
tests that checked each refusal now check that the server accepts
several workers. New tests import each new entrypoint the way a uvicorn
worker does, and check that gdp_pdf and visual_coding_opencode keep
ownership until a successful close.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/lift-multi-worker-refusals branch from 9bed8e0 to 909d9c5 Compare November 13, 2026 20:16
@yaoyu-33
yaoyu-33 requested review from gchlebus and removed request for sephmard November 16, 2026 00:15
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the feature New capabilities, enhancements, or enablement work label Nov 16, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:core Shared APIs, servers, telemetry, health, and registries needs-review PR is ready for code review and waiting on a reviewer labels Nov 16, 2026

@athitten athitten left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues from my side. I checked the routing claim with real two-worker starts (gdp_pdf sandbox, officeqa, webvoyager_judge, visual_coding_opencode, droid, openhands, crewai, and terminus_2 with 4 workers). All served, exited cleanly and printed the startup report once. A 64-session two-worker run of partner_if mock tools kept every session on its seeding worker (seed, tool, verify and close all 200; late calls 409). The 14 component suites pass on the head and on main + this PR.

  • Question: the overrides also change checkpoint tracking at any worker count. session_ended_by reads session_release_pending (_checkpoint/resources.py#L292-L306), so a verified but unclosed gdp_pdf or visual_coding_opencode session now stays tracked until close. I checked with one worker: tracked with the PR, untracked with the base hook. That is harmless for these restart-only servers, but the base docstring (base_resources_server.py#L710-L715) no longer describes what the overrides return, and #6061 says the hook keeps its meaning. Is this intended? A line in the docstring would help.
  • Optional: use one rule for state kept past /verify. partner_if mock tools, officeqa, agentic_if and enterpriseops also keep per-session resources after /verify until close, without this override. No shipped caller sends them a /verify without close-follows, so it is not reachable today, but mock tools and enterpriseops stay uncovered after #6061. Either add the same two-line override (suites pass: partner_if 500, officeqa 87, agentic_if 928, enterpriseops 71), or drop the defensive overrides and document that callers must send close-follows. The Fern section "State With Several Workers" could mention this hook for server authors.
  • Optional: test_uvicorn_workers_import_a_module_level_app is copied 8 times, and it passes when app is built from the wrong class (app = SimpleResourcesServer.run_webserver() in officeqa). A shared helper with monkeypatch.setattr(SimpleServer, "run_webserver", classmethod(lambda cls: cls)) and assert module["app"] is module["OfficeQAResourcesServer"] catches that.
  • PR body: the sentence that #4885's contract test passes with this PR is out of date. On today's main it fails for deepcad and video_caption, which landed after this PR's base and are not this PR's to fix.
  • Heads-up: rebasing #5981 onto this PR would bring back the agentic_if refusal (multiple_workers_unsupported_reason()).
  • Merge conflict: only the import block of crewai_agent/tests/test_app.py. Keep both BaseRunRequest and refuse_unsupported_num_workers.

Comment on lines +276 to +279
def session_release_pending(self, session_id: str) -> bool:
# verify leaves the lent sandbox running until close, so with several workers the close must still reach
# the worker that holds it.
return session_id in self._sessions or super().session_release_pending(session_id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this override (and gdp_pdf's at sandbox_app.py#L166-L169) misses the sandbox a failed seed leaves behind.

With several workers:

  1. A seed's sandbox start fails and its stop also fails. LentSandboxes keeps the sandbox in _failed_seed_sandboxes for a later close (sandbox_lending.py#L135-L147).
  2. The failed seed never sets _sessions[id] (gdp_pdf deletes _seeds[id]), so session_release_pending returns False and routing holds ownership only for the 300 s retry window.
  3. A close after the window lands on another worker. That worker fences the ID and answers 200, while the first worker keeps the sandbox until shutdown or TTL.

Repro: two in-process workers with real routing over Unix sockets, the local provider and a 0.5 s window. The late close got 200 on worker B, and worker A still held the sandbox after 1 stop attempt. With the fix below, the close was forwarded to A, the stop was retried, and the sandbox was released. gdp_pdf behaves the same. No shipped caller closes that late, so the impact is low. But these two servers are not in the "Known edge" list, and #6061 won't cover them.

Suggested fix. I ran it on this branch: gdp_pdf 131 passed, visual_coding_opencode 59, chartography 75, test_sandbox_lending.py 22.

# nemo_gym/server_runtime/sandbox_lending.py, LentSandboxes
def holds(self, resources_session_id: str) -> bool:
    """Whether a sandbox of the session, lent or left by a failed seed, still waits for a stop."""
    return resources_session_id in self._sandboxes or resources_session_id in self._failed_seed_sandboxes

# resources_servers/visual_coding_opencode/app.py
def session_release_pending(self, session_id: str) -> bool:
    lent = self._lent_sandboxes
    return (
        session_id in self._sessions
        or (lent is not None and lent.holds(session_id))
        or super().session_release_pending(session_id)
    )

gdp_pdf: session_id in self._seeds or self._sandboxes.holds(session_id) or super().session_release_pending(session_id).

Test: in test_sandbox_of_a_failed_seed_is_stopped_later, add assert server.session_release_pending("session") after the failed seed. It fails at this head and passes with the fix.

Comment on lines 129 to +132
# Its shipped template leaves `resources_server.name` unset for benchmark composition;
# here the environment server drives it, so the generated instance declares none (and is not a composition source).
"terminus_2_sandboxed_agent": {"num_workers": 1, "resources_server": None},
# It keeps the template's workers: session routing sends each episode session's requests to the worker that holds it.
"terminus_2_sandboxed_agent": {"resources_server": None},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking question: Harbor's Terminus 2 now runs the template's 4 workers. Was this measured at Harbor concurrency?

Measured on the real entrypoint with the shipped template fields:

  • 1 worker: 1 process, 361 MB unique memory, serving after 3.0 s.
  • 4 workers: 5 processes, 1,464 MB, serving after 6.5 s.

That is about +1.1 GB and +3.5 s per run. A request forwarded to another worker adds about 0.5 ms at p50.

Connections are split too. Each worker gets global_aiohttp_connector_limit_per_host // workers = 1024 / 4 = 256 connections to the model server (connection_pool.py#L99-L102), and a session stays on the worker that accepted its seed's connection. Without uvicorn_reuse_port, the busiest of 4 workers held 41-56% of the sessions (8 runs, 64-256 sessions, keep-alive client). So model calls start queuing at about 460-620 concurrent episodes instead of 1024 with one worker. The PR's own Harbor samples show the same skew (droid 134/22, openhands 157/34).

Options:

  • Keep "num_workers": 1 here until a run shows 4 workers help (test_harbor_tasks.py passes with it).
  • Set uvicorn_reuse_port: true on the generated instance (Linux only).
  • Say in the Harbor guide that the per-host limit is split across workers.

This change could also be its own PR.

@ananthsub
ananthsub marked this pull request as draft November 19, 2026 00:32
@github-actions github-actions Bot removed the sla:review-overdue Review response is over the one-business-day SLA label Nov 19, 2026

This branch was previously deployed

1 inactive (outdated) deployment
public — 9bed8e00 Deployed Nov 12, 2026 by copy-pr-bot[bot] via release / finalize / notify #11898
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants