Repository navigation
feat(agentic_mme): run Agentic-MME with simple_agent and OpenCode through agent sessions - #5720
Conversation
The opencode_agent session path rejected any input_image part with a 422, and its model entry declared no image input. OpenCode omits every image from model requests for a model without image input, including images its read tool returns, while still reporting the read as successful. A session now accepts base64 data-URI input_image parts in the user task. The adapter decodes them with nemo_gym.media_utils, uploads them into the session directory, and passes each one to `opencode run --file`. The session model entry declares image input, so images the read tool returns reach the model. Media outside the user task and image URLs are still rejected with a 422. Ported onto main 792fa14 for the Agentic-MME stack (#5720): main's session input now also takes request sampling, and test_unset_extensions_keep_setup_activation_and_capture_unchanged now expects the image options in the model entry. The #4922 test reads the staged activation through params(). Signed-off-by: Ananth Subramaniam <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
c8711eb to
d065813
Compare
|
/ok to test 4d66616 |
|
/ok to test 67d5907 |
|
/ok to test 006eeca |
|
/ok to test 41f8bb9 |
|
/ok to test dae1d0c |
…cipes The lent sandbox's network rule opens every port of the policy model's host, and a launcher's default_host also becomes the head server's address. The head server returns the whole config, keys included, without authentication, so sandbox code could read the credentials. opencode.yaml now sets head_server.host 127.0.0.1, which opencode_server_tools.yaml inherits; the policy model and, with server tools, the resources server keep the reachable address. NeMo RL sets head_server in its own initial config, which wins over the recipe, so under NeMo RL the head server stays on the node's address; the README says so. Tests: the launcher-host test checks the head server, and a new test checks it for both recipes with and without absolute_ip_server_types. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…ions On /run, the Agentic-MME agent scores a model call refused for its context or request size as 0 and raises any other failed call into the failures sidecar. Under an agent session it reported every refusal as model_request_error with its status, and the Environment Server's default policy grades a 400, so a serving limit (vLLM's per-prompt image limit) or an unsupported parameter scored 0. The agent now reports a context or request-size refusal as model_context_limit, and configs/agentic_mme.yaml sets the Environment Server's agent_outcome_policy: model_context_limit is graded, and 400, 413 and 422 fail ungraded. The policy applies to every harness of the benchmark: OpenCode already reports a context overflow as model_context_limit, so it now scores 0 there too; simple_agent reports a context limit as a plain 400, so in server_tools.yaml that rollout fails ungraded. The benchmark README says so. Tests: a session drives a crop and then a context-limit 400 and 413, an image-limit 400, an unsupported-parameter 400, a 503 and a 401, and checks the reported outcome, the kept tool work and the action under the benchmark's policy. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
gym eval prepare requires prepare() to return the dataset's jsonl_fpath, but prepare.py returns the atomic track's file, so the three new recipes failed with ConfigError. prepare_server_tools.py, prepare_opencode.py and prepare_opencode_server_tools.py run the shared conversion and return their track's file, and each recipe points prepare_script at its own. prepare.py also builds the server-tools rows from the image tools, which import OpenCV, and the recipes declared no preparation dependencies. config.yaml now sets prepare_project: resources_servers/agentic_mme in place of prepare_dependencies: [pillow], and each recipe's benchmark dataset sets it. Tests: for all four recipes, the preparer returns the dataset's jsonl_fpath and the dataset sets prepare_project. Checked: gym eval prepare of all four recipes on a one-task local release finishes in the locked project's environment. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…e, refuse unreadable images - Retire. The server keeps its own sessions, so the inherited retire_session_state did nothing, and a retired attempt kept its workspace and lent sandbox. It now stops the sandbox and drops the workspace under the session lock, without close's fence; a failed stop keeps both for a retry. - Tool calls. A call checked the fence before it waited on its own lock, which close did not take, so a call queued behind close changed the dropped workspace and returned success. A call now takes the session's lifecycle lock and checks the fence and the session under it. A client disconnect cancelled the await but not the worker thread, so the next call could run beside it; the await now runs in a shielded anyio cancel scope, so the lock is held until the worker finishes. - Seed. A task image that exists but cannot be read raised a 500, which the Environment Server retries with the same input; it is now a 422. Tests: retire with a failing first stop; close against a running and a queued call; a call cancelled through an anyio cancel scope; an unreadable image. All four fail on the old code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test b6c97ef |
…ions The default recipe runs the agent through agent sessions, and the session path dropped the tool trace: the Environment Server sends verify only the task data and the response, and the model's tool outputs leave out each retrieval call's provider answer, leak-guard count and cache outcome. A collected row therefore lost tool_trace, the counts and overthink. The agent now puts the trace in response.metrics, which the model never sees. Verify moves it into the result and derives the counts and overthink from it, so /run and a session give the same fields, and the row stores the trace once. /run takes them from verify instead of computing them itself. A test collects a rollout of the default recipe through collection, the single-agent-turn Environment Server and the agent's session routes, with a live search result, and checks the trace, its raw, contaminated and cache keys, and the counts. It fails on the previous head. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 385c6f6 |
Brings in main up to efd41fa, so the lock-freshness check compares this branch's locks against current main. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 5ee1e5d |
Reward comparison: main against this PRThe review asked for a reward comparison between the base and this PR, because the default recipe moves from the agent's Setup. The default recipe (
Paired difference over the 418 tasks (this PR minus main, using the mean of each task's two repeats): −0.84 points, standard error 1.26. The difference is smaller than one standard error. Rollouts whose result type changed (3 tasks). Each failure is the same refusal from the hosted model: HTTP 400 "Bad Request". The recipe sets no round or tool-call limit. The PR's two failures came after 25 and 27 tool calls, so the likely cause is the hosted model's limit of 25 images per request.
No rollout of these three tasks scored on either side, so the three failures do not change the paired difference. Two differences in behavior seen in the runs.
Not measured: live retrieval, and the other three recipes ( |
yaoyu-33
left a comment
There was a problem hiding this comment.
Team review at 5ee1e5dad1. Thanks for the careful rounds here: every earlier "Fixed in …" thread holds at this head. That covers the session 400s vs context limit, each recipe's prepare output and dependencies, retire releasing state, tool calls vs close and cancellation, unreadable images getting 422, and the tool trace under sessions.
Verdict: SHIP WITH CARE. No blockers. There are three risks: score comparability of the server_tools track, unbounded workspaces on that track, and the head-server key exposure under NeMo RL, which I answered in its existing thread. The inline notes are smaller follow-ups. Each issue and ask is inline.
On the question of where PolicyCallError belongs: see the inline comment on its definition. Short version: keep it local, build it on AgentOutcome, and leave a shared "failed response with an AgentOutcome" helper to a follow-up PR across agents.
Context:
- CI at this head: everything required passes. Only the non-blocking Environment Server compliance check fails.
- The rollout numbers in the description predate
5a0d0b396, which changed which failures are graded. The paired comparison after it coversconfig.yamlonly. Real smokes ofserver_tools.yaml,opencode.yamlandopencode_server_tools.yamlat this head would confirm the outcome policy on those tracks. - Not verified here: no tests or model rollouts were run for this review; it is a source review against current main (
f0c2feb319).
…nder sessions - A tool call for a session this server does not hold (never seeded, or lost to a restart or a retired attempt) raises ResourcesSessionLostError (404, session_lost) instead of 409, which harnesses passed to the model as an ordinary tool error. The session middleware gives every request an ID, so the two cases look alike; this follows automationbench, enterpriseops_gym and gdpval. - With serve_image_tools on, verify masks a session this server does not hold (lost_session_verification), as for a closed session. - verify records a failed response (a context-limit refusal that the outcome policy grades) as failure_reason "policy_error" with the harness's message in policy_error, as the agent's /run does. - serve_image_tools sets cv2.setNumThreads(1), as the agent does, since the tools run in to_thread workers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…sion branch does ServerClient.post returns a non-ok reply without raising, so the ClientResponseError branch never ran and a confirmed policy timeout was reported as model_request_error/500 without its failure report. - The agent now calls raise_for_status on each model reply. A refusal is classified from the error: model_context_limit for a context or request-size refusal, model_policy_response_timeout when the model server's report shows every attempt timed out, model_request_error with the status for another 4xx or 5xx, and unknown for a 3xx (a redirect loop), which AgentOutcome cannot carry. The response keeps the failure report, merged with the model server's. - PolicyCallError becomes PolicyCallFailure: it holds an AgentOutcome and the message, and derives infrastructure from the outcome. It stays local. - Tests: a timed-out 500 keeps its cause and the model server's report; a default-recipe rollout collected through the Environment Server that ends on a context-limit refusal after one crop scores 0, is graded, counts the crop and records policy_error. The refused-reply fakes now raise as aiohttp does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
… head-server notes - server_tools.yaml: the header says the track matches config.yaml only on rollouts without a context overflow (simple_agent reports one as a plain 400, which this benchmark fails ungraded) and asks for each track's failed-rollout count. The Environment Server admits 32 episodes at a time (max_concurrent_episodes, queue_timeout_seconds), which bounds the image workspaces on the resources server. - READMEs: replay works only on the agent's own /run; repeatable runs use the shared cache with cache_write: false. - Resources README: under NeMo RL, do not run opencode.yaml with real keys until the head server stops returning secrets. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…carries a report The policy model server is a Gym server, so its 400 carries a failure report that selects the refused model request (model_request_error). The Environment Server fails a reply whose selected cause does not match its outcome (model_context_limit), so the context-limit rule stopped grading once the agent attached the report. The agent now keeps that report's events but selects no cause for a context-limit refusal, and the outcome policy grades it. The collected context-limit test now gives the refusal a model-server report; it fails without this change. The timeout test checks that the Environment Server rebuilds the timeout as the reply's selected cause, so its timeout rule (retry by default) applies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…' image_input The review asked for fewer tests of config values. The deadline and admission tests stay, because each compares settings in two blocks that gym env validate does not compare. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test a67d4e0 |
… session config The old rows came from the relay to the agent's /run and named the old Environment Server instance. These come from resources_servers/agentic_mme/configs/agentic_mme.yaml at a67d4e0: the agent's session routes under single_agent_turn_legacy, instance agentic_mme_environment_server, 5 example rows, a hosted vision-language policy. All 5 score 1 after one crop; the rows now carry evaluation_completed, step_limit_reached and failure_report. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 0aade7a |
|
Thanks for the review (5924033396). Each inline point has a reply. The head is now
|
Conflict in nemo_gym/config/global_config.py: main added agentvista_agent to AGENT_SESSION_AGENT_TYPES where this branch adds agentic_mme_agent; both are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Main's #5686 makes policy_timeout_failure return model_server_queue_timeout when every attempt waited in the model server's queue, and simple_agent's session branch now reports the failure's own kind. The agent still reported model_policy_response_timeout, which no longer matches the cause its report selects, so the Environment Server would fail the reply instead of applying the queue timeout's rule (retry by default). The agent now reports the timeout's own kind, as simple_agent does. The timeout test covers a report without a queue reading, with an empty queue, and with requests waiting; the queued case fails without this change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 68f1cd5 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43952904763 |
What does this PR do?
Makes Agentic-MME (#5523, on main) a worked example of one benchmark that several agent harnesses run through the Environment Server, for eval and RL training.
resources_servers/agentic_mme/image_tools.py. The server serves them over HTTP and MCP, and each reply returns its new image intool_output_images.configs/agentic_mme.yamlruns it undersingle_agent_turn_legacy). Under a session, a failed model call fails the response with its cause, classified as simple_agent's session branch does (a context or request-size refusal, a policy timeout that the model server confirmed, another status), and the response keeps the call's failure report; on/runthe behavior is as on main. The agent reports its tool trace in the response'smetrics, which the model never sees, and verify moves it into the row with the tool counts andoverthink, so a session row has the same fields as a/runrow, including each retrieval call'sraw,contaminatedandcache.model_context_limit, andconfigs/agentic_mme.yamlsets the Environment Server'sagent_outcome_policyso thatmodel_context_limitis graded and a 400, 413 or 422 refusal fails ungraded. A serving limit, such as vLLM's per-prompt image limit, or an unsupported parameter therefore does not score 0. The policy applies to every harness of the benchmark (see Compatibility). Verify records a graded failed response asfailure_reason: policy_errorwith the call's message inpolicy_error, as on/run.LentSandboxes, feat: images in tool replies, a lent-sandbox helper and OpenCode session limits for multi-harness training #5719).sandbox_network_accesssets its egress:opencode.yamlusesmodel_only(only the model server), andopencode_server_tools.yamlusesmodel_and_tools(the model server and this server's/mcp). Both OpenCode recipes setimage_input: true, so OpenCode passes the images its tools return to the model.resources_servers/agentic_mme/sandbox_image/Dockerfilebuilds the OpenCode sandbox: Python with OpenCV, NumPy and Pillow, OpenCode 1.17.11, and OpenCode's plugin dependencies. Without those dependencies, OpenCode tries to install them from npm at each start, and a sandbox with no internet access waits about 70 s for that install to fail. The build checks the archive against the SHA-256 thatbenchmarks/agentic_ifpins, andopencode.yamlsets the same pin.opencode.yamlsetshost: 127.0.0.1on the head server (it returns the whole config, keys included), the judge, the agent, the resources server and the Environment Server, whose callers all run on the same host. NeMo RL sets the head server's address itself, which wins over the recipe, so under NeMo RL the head server stays on the node's address: do not runopencode.yamlunder NeMo RL with real keys until the head server stops returning secrets (opencode_server_tools.yamlturns OpenCode's shell off).opencode_server_tools.yamlalso sets the resources server's host back tonull, because OpenCode calls its/mcpfrom the sandbox.session_lost, and verify masks that session.judge_modelis removed: the judge's model server picks the model.score_step_limit_answer(defaultfalse) scores an answer at a harness's step limit 0, as the environment's own agent scores an episode that runs out of rounds.step_limit_reachedshows the share of such rollouts.server_tools.yamlalso admits 32 at a time, which bounds the image workspaces on the resources server (up to about 192 MB each), and that server runs OpenCV with one thread per call.prepare.pyconverts the release once and writes all four tracks;prepare_server_tools.py,prepare_opencode.pyandprepare_opencode_server_tools.pyreturn their recipe's file, asgym eval preparerequires. Every recipe prepares in the resources server's locked project (prepare_project), which has Pillow and OpenCV.prepare.pyalso writestask_idat the row's top level, wheregym eval planreads it.Settings in
benchmarks/agentic_mme/:config.yamlserver_tools.yamlsimple_agentopencode.yamlopencode_server_tools.yamlNo issue: this is the worked example for the multi-harness design.
Validation
At this head (the review fixes, then a merge of main
95c841be0):responses_api_agents/agentic_mme_agenttests: 106 passed. New: a 500 with a timed-out report keeps its cause and report, asmodel_server_queue_timeoutwhen requests waited in the model server's queue at every timeout, andsingle_agent_turnrebuilds the timeout as the selected cause; aconfig.yamlrollout collected through the Environment Server that ends on a context-limit refusal after one crop scores 0, is graded, counts the crop and recordspolicy_error.resources_servers/agentic_mmetests: 175 passed (the test that only checkedimage_input: truewas removed after review). New: a graded failed response recordspolicy_error; a tool call for a session the server lost answers 404 and verify masks it.gym env validate --configof all four recipes: valid.tests/unit_tests/benchmarksandtest_public_api_facades.py: 1955 passed, 2 failed (two cases oftest_super_vllm_launcher.py, which this PR does not touch and which fail the same way on this machine without it).pre-commit run --fileson the changed files: passed.single_agent_turn_legacytests 54 passed,opencode_agenttest_existing_benchmarks.py15 passed,tests/unit_tests/config/test_global_config.pyandtest_public_api_facades.py1242 passed, andscripts/component_locks.pychecked 315 projects with 0 failed.opencode_agenttests (922 passed, 23 skipped) andgym eval prepareof all four recipes, from the previous heads.prepare.pyitself ran ata67d4e094for the smokes.Rollouts. The four-track numbers below predate
5a0d0b396, which changed which failures are graded. After it, the paired comparison coversconfig.yamlonly: main 35.17% against this PR 34.33%, paired difference −0.84 points, standard error 1.26 (comment). Smokes ata67d4e094(the same code as this head, except the example rollouts): 10 real tasks × 2 repeats for each recipe, with the same hosted vision-language model, thegpt-4o-minijudge and search off. Theserver_tools.yamlrows setmax_output_tokens: 16384, as in the comparison. These smokes check the outcome policy on each track. 20 rollouts are too few to compare scores.server_tools.yamlopencode.yamlopencode_server_tools.yamlEach failed rollout is a refusal from the hosted model, HTTP 400 "Bad Request" (once "Invalid request"), after 26 to 65 tool calls. As in the comparison, the likely cause is the hosted model's limit of 25 images per request. The refusal does not name a context limit, so the outcome policy fails it without a grade, as it does for every harness. No smoke rollout ended on a context-limit refusal, so only the unit test covers the
model_context_limitrule here. In both OpenCode smokes, a probe from inside the lent sandbox found the internet blocked and the policy model reachable; the resources server's/mcpwas reachable only underopencode_server_tools.yaml.Before the merge:
simple_agentwith server tools 36.1%, OpenCode with server tools 36.5%, OpenCode with task files 35.2%. A paired difference has a standard error of about 1.5 points.Compatibility
configs/agentic_mme.yamlruns the environment's own agent through agent sessions. Under a session,retrieval.mode=replayis refused, because sessions do not receive the replay list.model_context_limit) now scores 0 instead of failing ungraded, as with the environment's own agent.simple_agentreports a context limit as a plain 400, so inserver_tools.yamlthat rollout now fails ungraded instead of scoring 0. A refused call other than a context limit fails ungraded with every harness.agentic_mme_agent_environment_server(main) toagentic_mme_environment_server. An override that names the old key adds a second, unused block.data/example_rollouts.jsonlis regenerated through this config: 5 rows from the agent's session routes underagentic_mme_environment_server.model_policy_response_timeoutwith the model server's report, in place ofmodel_request_error/500 with no report.single_agent_turn's timeout rule retries it by default, as before. When requests waited in the model server's queue at every timeout, it ismodel_server_queue_timeout, as withsimple_agentsince fix(failures): a policy timeout on a queueing model server is the server's #5686; the default policy retries it.session_lostin place of 409, and verify masks that session.config.yamlprepares inprepare_project: resources_servers/agentic_mmein place ofprepare_dependencies: [pillow].judge_modelsetting is removed. A config that sets it must drop it; the judge's model server picks the model.🤖 Generated with Claude Code