Repository navigation
Conversation
bf57998 to
ad4850b
Compare
e54313a to
0f694d1
Compare
| class GDPValResourcesServer(SimpleResourcesServer): | ||
| config: GDPValResourcesServerConfig | ||
|
|
||
| def multiple_workers_unsupported_reason(self) -> Optional[str]: |
There was a problem hiding this comment.
Non-blocking: could we keep the refusal before dependency setup? With num_workers=2, GDPVal now calls ensure_libreoffice() before the shared guard; VoiceBench's IFEval path similarly calls _ensure_nltk(). This can install dependencies unnecessarily or mask the worker-count error with a setup failure. Calling the shared guard early in these constructors would preserve the previous fail-fast behavior.
There was a problem hiding this comment.
Fixed. gdpval, voicebench, the partner_if mock tools and speed_bench now call refuse_unsupported_num_workers(self) at the start of model_post_init, before LibreOffice, the NLTK data, the tool backend or the startup metrics snapshot. run_webserver still checks it once the server is built, so nothing else changes.
The other refusing servers build only in-memory objects or read small files in model_post_init, so their worker-count error already comes first.
The gdpval and voicebench tests now fail if LibreOffice or the NLTK data is set up before the refusal, and both fail without the early check.
ad4850b to
d9751c1
Compare
0f694d1 to
8be02af
Compare
676aded to
19153c6
Compare
0ca5d40 to
fd2049b
Compare
19153c6 to
8b1d47e
Compare
fd2049b to
1d40152
Compare
8b1d47e to
476bc54
Compare
1d40152 to
d35232b
Compare
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]>
…ation An override that returns a variable, a call or a conditional expression might return None, so the contract test now asks for the module-level app unless every return is a string literal or an f-string. Signed-off-by: Ananth Subramaniam <[email protected]>
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]>
… sees visual_browser and webarena_browser, which main added, refused several workers in a WebResourcesServerConfig validator. The contract test reads only refusal methods on server classes, so it reported both servers as having neither the module-level app nor a refusal, and a dry run did not report the refusal. Each server now overrides multiple_workers_unsupported_reason() with the reason, and the validator check is gone. Constructing the config with several workers no longer fails; run_webserver refuses it instead. The coverage test no longer expects langchain_deepagents_agent/reasoning_search_agent.py, which no config names since that agent's configs moved to app.py. Signed-off-by: Ananth Subramaniam <[email protected]>
|
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. |
What changed and why
This is the last of three changes that let every resources, agent and environment server either run with
num_workers > 1or refuse it at startup with a reason. #4884 added the refusal method, and #4790 gave every server that is safe with several workers its module-levelapp.#5988, in parallel, gives the module-level
appto the servers whose state session routing already reaches, including those that refused several workers or that main added without either. This change leaves them as they are on main. Merge #5988 first. On main,agentic_if,officeqa,vibench,webvoyager_judge,web_agent,droid_agentandopenhands_agenthave neither the module-levelappnor a refusal method, so this change's repository-wide test fails on them until #5988 lands.The servers below keep state that session routing cannot reach, or own a resource that one process must hold. Each now overrides
multiple_workers_unsupported_reason(), andrun_webserverrefusesnum_workers > 1with that reason before uvicorn starts, and before a dry run returns.aviary(all five entrypoints)env_idin the request body, and the aviary agent sends step, verify and close without the session cookie.toolsandboxenv_idin the request body, andtoolsandbox_agentsends step, close and verify without the session cookie.critptverifycalls are pooled in memory into batches submitted together; the batches, submission counters and API key rotation must be shared by every request.speed_benchmetrics_source: prometheusosworldsessions.jsonstate file are each owned by one process.longmt_evalcompute_segalewmt_translationcompute_cometgdpvalterminal_bench_4client_session_idandrollout_idin the request body, which session routing does not route.vlm_eval_kitharbor_agentdirectory, so the module path uvicorn workers import does not resolve.voicebenchproof_judgezero_reward_incorrect_groupsgenrm_comparefixed_baselineornum_rollouts_per_prompt > 1)ns_toolsPythonToolpython_tool_port.visual_browser,webarena_browser/closecan reach a worker without the browser.speed_bench,longmt_eval,wmt_translation,proof_judge,genrm_compareandns_toolsget the module-levelapptoo, because they are safe in their other configurations:speed_bench's defaultresponsemetrics source scores each request on its own,longmt_evalwithout SEGALE builds no actors and keeps nothing between requests, andwmt_translationwithout COMET, as the IN22 profile runs it, keeps nothing between requests either.proof_judge's debug log takes a file lock around each append, asproof_genselectandproof_verificationdo since #4790, and still writes the record on a filesystem without file locks.ns_toolsnow lists its tools in its lifespan, withawait, instead of callingrun_until_completewhile it builds the server. A uvicorn worker imports the entrypoint from inside its running event loop, so without this every worker would fail at startup with "This event loop is already running" in every shipped config.terminal_bench_4,osworld,genrm_compare,gdpval,voicebench,visual_browserandwebarena_browseralready refused several workers, inmodel_post_init, in a config validator or withnum_workers: Literal[1]. Those checks now go through the method with the same conditions, so they all fail the same way and a dry run reports them.run_webserverasks for the reason after it builds the server, and building a server runsmodel_post_init.gdpval,voicebenchandspeed_benchdo setup there: installing LibreOffice, downloading NLTK data, or taking a metrics snapshot. So each also checks the refusal at the start ofmodel_post_init, which keeps the fail-fast behavior their own checks had: a server with several workers fails on the worker count, not on that setup.A unit test reads every server entrypoint without importing it: each server directory's
app.pyand each module a config names, anywhere in the repository. It fails when a server has neither the module-levelappnor an override of the method, on its class or on a parent server class in the repository, and the message says which to add. A server whose override might return None, so that it refuses only in some configurations, needs the module-levelappas well. Only a string literal or an f-string counts as a reason, so an override that returns a variable, a call or a conditional expression needs it too. A module-levelappalso fails the test when a config names the entrypoint by a path outside its server directory, which uvicorn cannot import. The scan skips dot directories, such as virtual environments, and caches. The only exemptions are the Gymnasium base class module and the local SEC search library, which configs name but which start no server. The resources server guide now mentions the test.Issue
No separate issue: this follows #3905 and completes its multi-worker support for every resources, agent and environment server.
Validation
Run on this revision, on main at b4f6a0d:
langchain_deepagents_agent/reasoning_search_agent.py, which no config names since feat(deepagents): run agent sessions in process or inside a task sandbox #5003. On main at b4f6a0d merged with this change and feat(server): run servers whose sessions routing reaches with several workers #5988 at 909d9c5, the test passes.visual_browser,webarena_browserand the shared web package, including a new refusal test for each server. Both fail on the previous revision, where building the config with several workers fails in the validator instead.pytest -n 16 tests/unit_testsin a virtual environment synced with the extras the unit-test workflow installs. Apart from the repository-wide test, the failures are in the Docker pty and sandbox transfer telemetry tests, which fail the same way on main.pre-commit run --files <changed files>.Run on the previous revision, on main at 79e986f, after dropping the seven servers #5988 enables:
officeqaandvibenchonly, and passes with feat(server): run servers whose sessions routing reaches with several workers #5988 merged as well. No other server main added since, including feat(visual_coding_opencode): visual-coding environment and BabyVision on OpenCode sandbox sessions #5839's, is flagged.Run on an earlier revision, on main at 79e986f:
longmt_eval's tests in its own virtual environment, including a new one that it refuses several workers only withcompute_segale. It fails on the previous revision, which refused in every configuration.pytest -n 16 tests/unit_testsin a virtual environment synced with the extras the unit-test workflow installs. The files with failures fail the same way on main.appin an entrypoint named from outside its server directory. With the module-levelappremoved fromproof_judgeorterminus_2_sandboxed_agent, whose refusals depend on their config, it now fails.ns_tools' tests in its own virtual environment, including a new one that builds the server inside a running event loop, as a uvicorn worker does, and checks that the lifespan loads the tools. It fails on the previous revision with "This event loop is already running".ns_toolsstarted throughgym env startwithnum_workers=2and itsDirectPythonToolconfig, on uvicorn 0.54 (its own lock) and 0.37. Both workers loaded their tools in their lifespan and stayed up, and stateful Python tool calls kept their state within each session, both through the public port and on each worker directly. The previous revision never became ready: both workers failed with "This event loop is already running" and uvicorn restarted them.pre-commit run --files <changed files>.Run on an earlier revision, rebased onto main at 7bceb31:
pytest -n 16 tests/unit_tests, with the same result, and the repository-wide test.Run on an earlier revision, rebased with #4790 onto main at ada2efa:
pytest -n 16 tests/unit_testsin a virtual environment synced with the extras the unit-test workflow installs (uv sync --extra dev --extra ray --extra sandbox --extra openshell --extra mlflow --extra wandb). The files with failures fail the same way on main at the same commit.chartography,copilot_agentandmini_swe_agent/sessions_app.py, the adapter, and this change movesvibench's check into the method.vibench's refusal test.pre-commit run --files <changed files>. CI's per-server run covers the server tests.Run on an earlier revision, rebased with #4790 onto main at f49b582:
pytest -n 16 tests/unit_testsin a virtual environment synced with the extras the unit-test workflow installs (uv sync --extra dev --extra ray --extra sandbox --extra openshell --extra mlflow --extra wandb). Rerunning the files with failures on this branch and on main at the same commit gives the same failures on both; two tests that failed only under the parallel run pass on rerun.officeqarefuse.officeqa,partner_ifandenterpriseops_gym, whose refusals this rebase touched, in the repository's virtual environment.gdpval's tests need packages that environment lacks, so CI's per-server run covers them.pre-commit run --files <changed files>.Run on an earlier revision, on main at 390c954:
gym env testcreates):aviary,toolsandbox,critpt,speed_bench,longmt_eval,wmt_translation,osworld,gdpval,terminal_bench_4,vlm_eval_kit,voicebench,enterpriseops_gym,partner_if,terminus_2_sandboxed_agent,agentic_if,legal_agent_bench,proof_judge,genrm_compareandns_tools. They include a refusal test for each server whose refusal depends on its config, and one forvlm_eval_kit.wmt_translation's venv needs its current requirements, which add the IN22 normalizer.NEMO_GYM_MULTIWORKER_E2E=1 pytest tests/e2e/session_routing.Rollout evidence
The only startup change is
ns_tools' tool listing, and the two-workerns_toolsrun under Validation exercises it: tools load in each worker and serve stateful Python calls. Model rollouts are N/A: no verifier or agent logic changes; the rest is a startup check and a debug log lock.Compatibility
num_workers > 1on a refusing server now fails at startup with the reason, instead of failing in its own way or starting and misbehaving.genrm_comparein its stateless mode (rollout_cohortwithnum_rollouts_per_prompt == 1),speed_benchwith its defaultresponsemetrics source,longmt_evalwithout SEGALE,wmt_translationwithout COMET, andproof_judgeandns_toolsin their other configurations acceptnum_workers > 1.gdpvalrefusesnum_workers > 1both at the start ofmodel_post_initand inrun_webserver, as described above.WebResourcesServerConfigno longer rejectsnum_workers > 1when it is built.visual_browserandwebarena_browserrefuse it inrun_webserver, so the error now names the server and a dry run reports it.