Skip to content

feat(auto_ontology_agent): run Auto Ontology's ReAct agent in Gym, one sandbox per episode - #6289

Open
ffrujeri wants to merge 14 commits into
ffrujeri/birdbench-auto-ontology-catalogfrom
ffrujeri/birdbench-auto-ontology-agent
Open

ffrujeri wants to merge 14 commits into
ffrujeri/birdbench-auto-ontology-catalogfrom
ffrujeri/birdbench-auto-ontology-agent

Conversation

@ffrujeri

@ffrujeri ffrujeri commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What

An Agent Server, responses_api_agents/auto_ontology_agent, that runs Auto Ontology's own ReAct agent (its loop, prompts and tools) on the policy model. benchmarks/birdbench/auto_ontology_agent.yaml pairs it with BIRD dev through single_agent_turn, and bird_sql grades its query the way it grades simple_agent's.

How

  • Task. The task comes in the seed's agent context: question, evidence and database. prepare.py --agent-context (prepare_script_args.agent_context) writes these rows to their own file, with no schema. simple_agent refuses a seed that carries an agent context.
  • Seed. The episode runs in a sandbox from the catalog image (feat(birdbench): build the Auto Ontology catalog image in Gym, pinned once #6288). BIRD dev's config has single_agent_turn start that sandbox for each attempt and lend it at seed (sandbox_provider, sandbox_config). The agent borrows it, uploads episode_runner.py and starts the catalog's Postgres on a port of its own. A seed that lends no sandbox, as BIRD-Interact's does, has the agent start one with its own sandbox_provider, with the runner delivered through SandboxSpec.files; the seed reply then names that sandbox (x-ng-agent-owned-sandbox-id).
  • Activation. The agent runs run_episode in the sandbox, the way Auto Ontology's ReactSQLAgent does for a SQL answer. Auto Ontology's reasoning client points at the policy's Model Server, on the rollout's route, so Gym serves and captures every model call. The agent answers with the submitted query in a fenced sql block.
  • Close. The close releases a lent sandbox, which single_agent_turn stops, or stops the agent's own.
  • Model failures. When Auto Ontology's loop gives up on a model call, the runner reports the call's HTTP status, or that it got no reply. The agent answers failed with model_request_error or model_transport_error, so the Environment Server's outcome policy grades, retries or fails the episode. An episode with no submission for another reason is graded.
  • Dependencies. The agent's process imports only Gym; Auto Ontology runs in the sandbox.
  • Sessions only. The agent is listed in AGENT_SESSION_AGENT_TYPES and does not override run(). A request without an agent session, /run included, gets AgentSessionConflictError (409).

Why

Auto Ontology's catalog and loop stay inside the agent harness's sandbox, so this arm reproduces Auto Ontology's product loop exactly: last-turn narrowing to submit, nudges and its client settings. The other approach, the bird_sql Resources Server serving Auto Ontology's tools to any harness (#6285), is closed for now.

Stacked on #6288.

Validation

  • gym env test +entrypoint=responses_api_agents/auto_ontology_agent: 12 passed.

  • pytest benchmarks/birdbench/tests: 80 passed, 3 skipped. This includes the new agent_context rows.

  • tests/unit_tests/environment/test_benchmarks.py, tests/unit_tests/config/test_global_config.py and tests/unit_tests/test_session_contract_repo.py: 339 passed.

  • pre-commit on the stack's changes: passed.

  • gym env validate --config benchmarks/birdbench/auto_ontology_agent.yaml: valid.

  • Environment Server compliance (non-blocking): python -m scripts.environment_server_compliance.ci check responses_api_agents/auto_ontology_agent reports one finding, A4. The probe lends a sandbox in a seed with no agent context. The agent accepts a lent sandbox but refuses a seed without its task (question, database), so the probe counts the seed as failed and cannot observe A5. test_a_lent_sandbox_runs_the_episode_and_its_owner_stops_it covers both: the agent borrows the lent sandbox, and its close releases the client without stopping the sandbox. The smoke below runs the lent path.

  • After the rebase onto main (4954b38, 2026-11-23), with the BIRD-Interact stack merged: uv lock --check passes after the relock (main bounded e2b below 2.51.0 and ray[default] below 2.60); the agent's tests at the stack's top: 86 passed, 1 skipped.

  • Review fixes (f8d96f8, 340dd8b, 6456cb8):

    • A failed setup whose cleanup also fails keeps the sandbox for close (AgentSessionSetupError, as codex_agent does).
    • An activation that sets a control the loop does not honor gets a 422, as pi_agent's does.
    • bird_sql's instance declares the dataset, so collation checks the rows against bird_sql's TaskData: a row without gt_sql now fails collation with task_data_validation=error, where it reached the servers before.
    • The prepare examples pass the embedding key.
    • The published sandboxed-harnesses table lists the agent.
    • Agent tests: 18 passed; core: 1781 passed; benchmarks/birdbench/tests: 82 passed, 5 skipped. Smoke at the stack's top (55a17b0), with the 1.3.0 catalog: 5 of 5 BIRD dev tasks correct through the new dataset layout.
  • Third review round, rebased onto main (6f6f4c7, 2026-11-24), 99f2db8:

    • A model call that the loop gave up on fails the activation for the outcome policy, as above. In the catalog image, with the pinned Auto Ontology, a Model Server answering 503 gave status_code: 503, and a closed port no_reply: true.
    • A sandbox that start() created, but could not deliver the runner to or stop, is stopped through the session, and kept for close when that stop fails too.
    • Agent tests at this PR: 24 passed; the new tests fail with the previous code. Core (tests/unit_tests/benchmarks/, environment/, config/, CLI) at the stack's top: 2834 passed, 13 skipped; agent tests: 108 passed, 1 skipped; pre-commit run --all-files: passed.
    • Smoke at the stack's top (43784ab), Claude Opus 5.5: 5 of 5 BIRD dev tasks correct; BIRD-Interact Full on the interactive pipeline and the full-meanings image, c-Interact rewards 1.0, 1.0, 1.0, 0.0 and a-Interact 1.0, 1.0, 1.0, 0.0 (16 to 19 BIRD-COIN; the 0.0 is the agent's own repeated_sql stop). No failures, nothing masked, rollout health unobserved only, every sandbox stopped.
  • Rebased onto main (5398501, 2026-11-30), dfe2f38: the agent's uv.lock is relocked for main's dependency bumps (hydra-core 1.4.0rc3, omegaconf 2.4.1rc3, antlr4 dropped), in the relock commit. Core suite (tests/unit_tests) at the stack's top: 27647 passed, 39 skipped; one failure under xdist, test_indic_in22.py::test_manifest_is_discoverable_under_its_catalog_path, passes alone and is outside this stack; agent tests: 108 passed, 1 skipped; component locks: 342 checked, 0 failed; pre-commit on the stack's files: passed. Smoke at the stack's top: 5 of 5 BIRD dev tasks correct with the agent on the catalog image at this stack's pin (nemo-gym/bird-catalog:dev-1.3.0), 3 model calls each, all captured, no failures, every sandbox stopped.

  • Pinned Auto Ontology's main (a00a3906, the merge of Let a ReAct episode ask the user NVIDIA/auto-ontology#559) and rebased onto main (bc5383b), 2026-11-30, 5f33f75: on Auto Ontology's main, the ReAct tools open the catalog's retrievers themselves and ToolContext no longer takes them; the runner passes the connectors and the question, as Auto Ontology's ReactSQLAgent does. Core suite (tests/unit_tests) at the stack's top: 27674 passed, 39 skipped; one failure under xdist in test_openshell_provider.py, which passes alone and is outside this stack; agent tests: 110 passed, 1 skipped; benchmarks/birdbench/tests: 82 passed, 5 skipped; component locks: 343 checked, 0 failed; pre-commit on the stack's files: passed. Smoke on the rebuilt image: 5 of 5 BIRD dev tasks correct with Claude Opus 5.5, 3 model calls each, no failures, every sandbox stopped.

  • Rebased onto main (dd09637), 2026-12-01, aba8c46: no conflicts; no change in this PR. tests/unit_tests/benchmarks, config, cli and tooling pass, as do the test files that failed locally with a partial environment (the rest fail on main too, on this machine); benchmarks/birdbench/tests: 82 passed; agent tests: 110 passed, 1 skipped; component locks: 343 checked, 0 failed; pre-commit on the stack's files: passed.

  • Fourth review round, rebased onto main (0b7bcdc), 2026-12-02, 21c8645. Conflict with main's feat(birdbench): add BIRD's 2025-11-06 dev and both Mini-Dev releases as dated versions, and a schema-only prompt #6711 in prepare.py: output_fpath_for and prepare() take the version and prompt format beside agent_context, and refuse the schema-only prompt with it. Review fixes: an episode stopped at episode_timeout_seconds answers with no query as an incomplete, graded response, while any other missing result still fails (9ba8b8d); the sandbox gets the provider's default_metadata under the agent's own labels (d92bb27); auto_ontology_agent.yaml sets num_samples_in_parallel: 8, the agent's episode bound, so queued rows do not each hold a sandbox (21861c9); prepare.agent_task() refuses a task with no question of its own and a core test parses its output as AutoOntologyTask (46a05a9); the pairing has its own manifest, birdbench/auto_ontology_agent (21c8645). Core suite (tests/unit_tests) at the stack's top: 27972 passed; the 8 that fail (tool and sandbox-transfer telemetry, two OpenSandbox script-help tests) fail on main on this machine too. benchmarks/birdbench/tests: 121 passed; agent tests: 124 passed, 1 skipped; component locks: 345 checked, 0 failed; pre-commit on the stack's files: passed. Smoke: BIRD dev, 5 tasks, ReAct agent: 1, 1, 1, 1, 1.

  • Sandbox Everything, rebased onto main (0cfc8d1, with feat(environment): own each attempt's sandbox groups in the base Environment Server, with per-task verifier modes #6752), 2026-12-04, 6f960ac: BIRD dev's config has single_agent_turn start each attempt's sandbox from the catalog image and lend it; the agent borrows it and no longer refuses a lent sandbox. With none lent it starts its own, and its seed reply names it (calls_model_from_sandbox), as feat(environment): require sandbox placement for tool-enabled sessions #7146's check will require. A lent sandbox with network_access other than inherit, or no lent sandbox and no sandbox_provider, is refused at seed. The rebase had no conflicts; restacking feat(auto_ontology_agent): take part in BIRD-Interact's c-Interact, asking the user through the Environment Server #6323 and feat(auto_ontology_agent): run Auto Ontology's interactive pipeline in BIRD-Interact's c-Interact and a-Interact #6450 on this commit merged their seed changes with it. Agent tests at this PR: 30 passed, and each new test fails with its behavior reverted; at the stack's top: 118 passed, 1 skipped. Core (tests/unit_tests/benchmarks, environment, config, agents, server_runtime) at the stack's top: 6353 passed, 14 skipped; the one failure, test_resolve_config_servers_logs_unresolvable_configs[recursive_alias-ConfigError], fails on main on this machine too. Component locks: 350 checked, 0 failed; pre-commit on the stack's files: passed. Smoke, Claude Opus 5.5, Docker: BIRD dev 5 of 5 correct in lent sandboxes, and 2 of 2 with the agent's own sandbox_provider set to null, which shows single_agent_turn started them. BIRD-Interact Full on the interactive pipeline, where the agent still starts its own sandbox: c-Interact 1.0, 1.0, 1.0, 0.0 and a-Interact 1.0, 1.0, 1.0, 0.7 (archeology_scan_1, its first phase in a-Interact). No failures, nothing masked, every sandbox stopped.

Rollout evidence

Smoke on the first 5 BIRD dev tasks, AWS Claude Opus 5.5, local Docker sandboxes on the host network: 5/5 correct. Each episode submitted after 3 tool calls. Its 3 model calls were captured on the rollout's route, and every sandbox was stopped.

200-task results (first 200 BIRD dev questions, AWS Claude Opus 5.5, graded by bird_sql):

Arm Accuracy Model calls per question Tokens per question
Control: simple_agent, schema in prompt (config.yaml) 86.0% 1.0 4.5k
Auto Ontology agent (auto_ontology_agent.yaml) 79.5% 3.1 12.2k
Catalog tools + simple_agent (closed #6285, for reference) 80.0% 4.1 17.3k

The agent arm ran on rows from the earlier prepare path. Those rows carried the same agent context, so the agent's input was the same. No infrastructure failures, and every sandbox stopped.

After the rebase, the 5-task smoke again, on freshly prepared rows and the same image: 5/5 correct, 3 model calls per episode (retrieve, run_sql, submit), no failures, every sandbox stopped.

Sandbox Everything (2026-12-04): BIRD dev, 5 of 5 correct with single_agent_turn starting and lending each sandbox; details in the last entry above.

@copy-pr-bot

copy-pr-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ffrujeri
ffrujeri added this pull request to stack #6286 November 17, 2026 07:32
@ffrujeri ffrujeri added area:agent Agent harnesses and Responses API agent behavior feature New capabilities, enhancements, or enablement work labels Nov 17, 2026
@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 47ddd27

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 7bc9636

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test a9f980f

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 068fdd8

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 6b6ea78

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:high Autobot PR risk: high label Nov 23, 2026
@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test a88e18a

@ffrujeri
ffrujeri marked this pull request as ready for review November 23, 2026 18:28
@ffrujeri ffrujeri added the needs-review PR is ready for code review and waiting on a reviewer label Nov 23, 2026
@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test a88e18a

Copy link
Copy Markdown
Contributor

Invalid /review command: arguments must use key=value syntax. Usage: /review [<sha>] [approve=<true|false>] [mode=<light|strict>] [model=<codex|claude>] [prompt="<value>"] [reset=<true|false>] [role=<automation|engineer>].

@adil-a

adil-a commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

/review aba8c46 reset=true

@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.

I found three RISK issues and three non-blocking NOTEs. No BLOCKER was established. I reviewed all 16 changed files with three delegated reviewers and checked the findings against the shared session, sandbox, collation, model-server and environment-server code.

Previous review: failed-setup cleanup, unsupported activation controls, grading-field validation, the prepare-key example and published documentation are fixed. The resource-admission concern persists in the standalone preset despite clearer documentation. The data-contract comment below concerns the remaining prepare-to-agent synchronization gap, not the fixed gt_sql validation defect. The previous review commit a88e18a1026fd63f7d512ccf032d9927fb420b30 was unavailable, so I verified its findings against this head without claiming a since-baseline diff.

CI: I relied on green Lint check, component-lock checks, all eight server-suite shards and their aggregate, core shards 1–3, Sandbox tests and Auto Ontology compliance. CI is not wholly green: run 46549066589, attempt 1, tested this admitted head and failed core shard 0, Unit tests / Test and Nemo_CICD_Test. The shard reported 1 failed, 6861 passed and 98 skipped. Its failure was test_hub_allowance_counts_waiting_on_the_hub_not_local_work, where a recorded delay of 1.4423449259993504 missed 1.5 ± 0.05. The test and implementation are unchanged by this PR, but the corresponding base run passed, so attribution remains uncertain. Container, GPU/provider E2E and combined core coverage were skipped, not passed.

Local evidence: CPU probes ran in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:c2974f7bd962fd921ae90176f19d983bccbdebff, a default-branch CI image selected because this head's container build was skipped. I verified that probes loaded the admitted source rather than the image's installed Gym. Lifecycle, control/replay, runner/model-server bridge and data-preparation probes completed after fixture corrections. They confirmed the fixes above and reproduced the findings below. The image's baked dependencies differ from the component lock, so these are targeted probes, not an exact-lock suite result. I did not rerun green CI suites or reproduce real Auto Ontology, Docker/Postgres or model episodes. The PR supplies representative smoke-rollout and 200-task comparison evidence; those results are author-provided.

The admitted trees stayed unchanged.

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

return SandboxCommand(argv=[self.config.catalog_python, SANDBOX_RUNNER, task_path, result_path])

async def collect() -> dict[str, Any]:
return json.loads(await read_text(session.sandbox, path=result_path))

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: Handle a confirmed episode deadline separately from a missing-result failure.

The runner writes result.json only after run() returns. If the supervisor ends it at episode_timeout_seconds, this unconditional collection raises because no result exists. _run_episode() then rethrows instead of returning a time-limited attempt. The agent boundary turns that into a route failure, which single_agent_turn treats as a retryable dependency error. Slow tasks can exhaust retries and leave evaluation incomplete rather than be graded.

python /workspace/review-probes/app-lifecycle-1/timeout_probe.py, using the real head SandboxSession and LocalProvider with a sleeping runner, reproduced FileNotFoundError while cleanup reported cleanup_confirmed=true, timed_out=true, return_code=143.

Could you use the confirmed supervisor receipt to return an incomplete, gradable response when the episode deadline expires without a result? Preserve genuine errors for non-timeout crashes, malformed results and unconfirmed provider failures. Acceptance: a supervised sleeping runner returns an incomplete activation without HTTP 5xx; a missing result after a non-timeout crash still fails, and an unconfirmed provider timeout is not graded as a model outcome.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9ba8b8d. collect() checks for result.json first and raises NothingCapturedError when the runner wrote none. When the supervisor's receipt says the episode was stopped at its limit (timed_out and cleanup_confirmed), the agent answers with no query, as an incomplete response that the outcome policy grades. A missing result after a crash, with no receipt, or with an unconfirmed stop still fails the activation. Tests: test_an_episode_stopped_at_its_time_limit_is_graded_as_incomplete and test_an_episode_with_no_result_otherwise_fails_the_activation (three cases); all four fail without the change. The README's limits row says it.

async def collect() -> dict[str, Any]:
return json.loads(await read_text(session.sandbox, path=result_path))

async with self._episodes:

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: Give the standalone BIRD run a finite sandbox-admission bound.

The documentation now correctly says this semaphore limits activation, not live sandboxes. However, the supplied preset and runnable example set neither collection admission limit. Both default to None, and the driver uses no semaphore when unset. Each queued row has already started its sandbox and Postgres before waiting here.

The public seed/close probe in /workspace/review-probes/app-lifecycle-1/probe.py set the episode limit to 1 and started four sandboxes/catalogs before activation. My merged-config probe also confirmed that the standalone preset has no run-side bound. The full 1,534-row example can therefore overwhelm its local Docker host despite executing only eight loops at once. I did not run a full-scale exhaustion experiment.

Could you either hold sandbox capacity from seed through confirmed close, or configure a finite run-side bound in this preset and its example? Preserve identical-seed replay and cleanup retries. Acceptance: seed N+1 creates no sandbox until capacity is released, or the documented standalone run resolves an explicit finite collection limit. This is the remaining part of prior comment 4670636367, narrowed after the documentation clarification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 21861c9, with a run-side bound. benchmarks/birdbench/auto_ontology_agent.yaml sets num_samples_in_parallel: 8, the agent's max_concurrent_episodes, so the run seeds no more sandboxes than the agent runs episodes; --concurrency still overrides it. test_the_pairing_bounds_its_live_sandboxes keeps the two equal. I kept the semaphore around execution, for the reason in my earlier reply: holding it from seed to close would block c-Interact's sessions across their user turns.

Comment thread benchmarks/birdbench/prepare.py Outdated
}
if agent_context:
# The agent writes its own prompts from the task, with the evidence apart; it ignores the input.
task = {

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: Enforce the prepared agent-context contract against the runtime model.

This dictionary independently declares fields required by AutoOntologyTask. BIRD's grading schema intentionally does not validate this framework-owned context. The new preparation tests compare against a literal dictionary, the agent tests seed another literal, and the new core test checks YAML placement only. None detects drift between producer and runtime.

probe_producer_drift.py prepared an entry with an empty raw question and nonempty evidence: the evidence-prefixed grading question passed preparation and BIRD validation, but the generated agent context failed AutoOntologyTask. The contract probe also showed malformed or missing context passing error-mode collation and failing at seed. I am not claiming the current BIRD dataset contains these rows.

Could you share a dependency-light context declaration between preparation and runtime, or add explicit drift enforcement that exercises both? Validate generated context before writing it and test prepare → collate → runtime parsing, including empty question with evidence and unknown/mistyped context fields. Preserve separate question/evidence, include_evidence=False, the separate output file and existing gt_sql validation. This closes the remaining acceptance gap from prior comment 4670636393; its original missing-grading-schema defect is fixed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 46a05a9. prepare.agent_task() builds the agent context and refuses an entry with no question of its own (evidence alone is no task), before anything is written. A core test parses its output with the agent's AutoOntologyTask for evidence present, empty and missing, with and without include_evidence, so a field the two disagree on fails the core suite. Separate question and evidence, include_evidence=False, the separate output file and gt_sql validation are unchanged.

)
files = {SANDBOX_RUNNER: RUNNER_SOURCE.read_text()}
spec = restrict_sandbox_network(
SandboxSpec(**sandbox_config, files=files),

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.

NOTE, suggestion: Merge the provider's default metadata into this spec.

resolve_provider_config() deliberately excludes default_metadata, so passing its result to create_provider() does not apply those defaults. This path never calls resolve_provider_metadata(). My leader/probe_provider_metadata.py supplied defaults team=expected-team and sandbox-api=docker-cli, plus explicit run=explicit; the sandbox received only {'run': 'explicit'}. Deployment labels used for attribution or lookup are silently lost.

Could you merge provider defaults first, then sandbox_config.metadata, preserving explicit override precedence? Keep any per-task labels bounded as the sandbox convention requires. Acceptance: a seed probe checks the actual spec passed to start(), showing default labels present and explicit values winning. Provider-generated attribution should continue to work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in d92bb27. The spec's metadata is now resolve_provider_metadata(...), then sandbox_config.metadata over it. The seed test gives the provider block default_metadata and the agent an explicit label, and checks the spec passed to start(): {"team": "gym", "run": "explicit"}.

datasets:
- name: birdbench
type: benchmark
# The task rides in each row's agent context; the agent writes its own prompts from it.

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.

NOTE, suggestion: Give this prompt/tools variant its own manifest.

This arm removes the standard schema prompt and supplies Auto Ontology's catalog retrieval/SQL loop, so it is more than a harness-only preset. The manifest guidance distinguishes prompt/tools variants from that exemption. Discovery currently returns birdbench/auto_ontology_agent with manifest_path=None, so the catalog has no authored requirements or prompting metadata for this arm.

Could you add auto_ontology_agent/manifest.yaml with config_path: ../auto_ontology_agent.yaml, prompt_source: agent, the BIRD dataset/verifier/metric, and the catalog-sandbox and embedding-network requirements? Keep the original BIRD manifest unchanged. Acceptance: discovery returns a manifest-backed entry and manifest validation resolves this configuration with metadata describing the Auto Ontology arm.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in 21c8645: benchmarks/birdbench/auto_ontology_agent/manifest.yaml, config_path: ../auto_ontology_agent.yaml, prompt_source: agent, BIRD's dataset, verifier and metric, canonical_split: dev, and network: allowlist for the embedding endpoint. The original BIRD manifest is unchanged. It loads against the manifest schema, and the repository's manifest and catalog tests pass with it.

[spec] = sandbox.start.await_args.args
assert isinstance(spec, SandboxSpec)
assert spec.image == "nemo-gym/bird-catalog:dev"
assert "def run_episode" not in spec.files[SANDBOX_RUNNER] and "run_episode(" in spec.files[SANDBOX_RUNNER]

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.

NOTE, suggestion: Replace this source-substring assertion with executable runner coverage.

The activation tests supply _FakeSession with an already-built result, and the runner tests exercise only environment construction and error serialization. This assertion still passes if connector selection, the retry hook or submission conversion breaks in episode_runner.run().

A small fake-Auto-Ontology test can execute that function without Docker or external dependencies. /workspace/review-probes/episode-bridge-1/probe_runner_bridge.py demonstrated this on the CPU workstation. Could you cover the selected database, a submitted query with db_response=[], and a loop that catches an exhausted model call and returns model_error? Keep the existing app reply assertions. Acceptance: the test fails if the runner chooses the wrong connector, drops an empty successful result or loses the status/transport failure. This is missing regression protection, not a reproduced runtime defect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not adding it here. #6323 adds the Auto Ontology stub that runs episode_runner.run() without Docker (_auto_ontology_stub), and its tests execute run() through it; copying the stub into this PR would leave two to keep in sync. The model-error path is covered by test_the_runner_reports_the_model_server_s_status_or_no_reply and the activation tests, and #6450 now covers model failures in the interactive pipeline the same way.

@ffrujeri
ffrujeri force-pushed the ffrujeri/birdbench-auto-ontology-agent branch from aba8c46 to 21c8645 Compare December 2, 2026 02:43
ffrujeri added a commit that referenced this pull request Dec 2, 2026
…ort, and record a turn whose model call failed

A 200 from ask_user whose body did not arrive whole raised http.client.IncompleteRead while reading it. That is not a
URLError, so call_tool let it through, Auto Ontology's loop turned it into tool feedback, and the call was never
recorded: the turn could go on to a scored submission although the server may have counted the question. call_tool now
treats any failure to read the reply (IncompleteRead, a reset connection) as a call that got no reply, which run()
raises once the loop returns, so the activation fails without asking again.

A c-Interact turn whose model call the loop gave up on now answers `failed`, by the model failure fix in #6289, and its
invocation record says `failed` too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@ffrujeri

ffrujeri commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 21c8645

@adil-a adil-a 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.

Notes from a pass over the stack at this head. Each inline comment says how it was established, and anything not confirmed from the code is put as a question.

"reason": result.reason,
"tool_calls": result.tool_calls,
"trajectory": result.trajectory,
"model_failure": model_failure(failures[-1]) if result.reason == "model_error" else 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.

RISK: A failed catalog search is graded as the model's answer.
Each retrieve embeds the query against the endpoint in the image's .env, from inside the sandbox. From the pinned Auto Ontology source, not run: _dispatch in react/loop.py turns any tool exception into the text retrieve failed: ..., and the loop carries on. The runner records only a model call the loop gave up on. So with the embedding endpoint down, rate limited or the key wrong, the model writes SQL blind or submits nothing, and the episode is graded 0 with nothing marking it as an infrastructure failure. Reproduced with a stubbed loop whose searches all fail: the reply is a normal completed answer. Could the runner record tool exceptions the same way it wraps invoke_with_retry, and fail the activation (or at least flag it in metadata) when catalog searches raised?

name: policy_model
sandbox_provider: auto_ontology_sandbox
sandbox_config:
image: ${auto_ontology_image}

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.

NOTE: The sandboxes run with no CPU, memory or PID limits.
sandbox_config names only the image, and the Docker provider adds --cpus/--memory only from SandboxSpec.resources, so apply_resource_limits: true has nothing to apply. Each sandbox runs Postgres plus Auto Ontology, which fetches whole result sets, and eight run at once on BIRD dev. One runaway query could starve the other episodes or the host. Could you set resources (and possibly pids_limit) here, as other sandboxed agents' benchmark configs do, for example benchmarks/deepsearchqa/configs/deepsearchqa_codex.yaml?

# with it: at least the catalog image.
sandbox_provider: str
sandbox_config: dict[str, Any] = Field(default_factory=dict)
network_access: SandboxNetworkAccess = "inherit"

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.

NOTE: No restricted network_access value can work for this agent.
On the shipped Docker provider, model_only and model_and_tools are refused at every seed, since Docker has no network-policy provider. On a provider that has one, the policy opens only the Model Server (tool_urls=[]), but every retrieve calls the embedding endpoint from the image's .env. Each search would then fail, and since the loop turns tool errors into text, the episode would still be graded. The new manifest declares an allowlist for that endpoint, but the agent cannot express it. Could the agent either refuse non-inherit values with that reason, or take the embedding host as an extra allowed URL? Either way, a line in the README would help.

version = "0.0.0"
requires-python = ">=3.13.14"
dependencies = [
"nemo-gym[dev]",

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.

NOTE: The agent's environment lacks the sandbox extra.
The agent depends on nemo-gym[dev] only, and its uv.lock has opensandbox, daytona and tenacity only under the sandbox extra. The local Docker provider works without them, but the README's remote-provider path ("On a remote sandbox provider ...") would fail at the first seed when the provider imports its SDK. The other sandboxed agents depend on nemo-gym[dev,sandbox], for example responses_api_agents/terminus_2_agent/pyproject.toml. Could this one do the same?

if state.activation is None:
# No await before the activation is installed: a retry joins it.
state.activation_request = body.model_copy(deep=True)
state.activation = asyncio.create_task(self._run_episode(state, body))

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.

NOTE: A failed episode whose caller left logs "Task exception was never retrieved".
The activation task is created by hand and shielded. If every waiter disconnects and the episode then fails, nothing reads the task's exception, so asyncio logs it when the state is dropped. Reproduced with a fake session. Core's OrderedOperationLedger (nemo_gym/agents/utils/ordered_operations.py) handles the same join-and-replay case and consumes the exception with a done callback. Could this either use the ledger or add the one-line add_done_callback it uses?

await agent.responses(_request(), NeMoGymResponseCreateParamsNonStreaming(input="question"))


def test_the_runner_reports_the_model_server_s_status_or_no_reply() -> 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.

NOTE: Some runner and session behaviour is still untested at the stack's tip.
This builds on the earlier thread about runner coverage: the stub in the c-Interact PR (#6323) does not yet cover these. With the tip's tests, each of these one-line changes still passes: run() returning "model_failure": None (this test checks model_failure() alone, and the activation tests feed a ready-made result); returning SQL whose db_response is None; awaiting the activation without asyncio.shield; always reporting cleanup_confirmed=True; and dropping the required-grant refusal at seed. The first two decide what gets graded. Could a few small tests pin them, for example one run() case through the c-Interact stub where the loop ends with model_error?

- **The episode is Auto Ontology's.** `episode_runner.py` calls `run_episode` as Auto Ontology's `ReactSQLAgent`
does for a SQL answer, with Auto Ontology's reasoning client pointed at the policy's Model Server.
- **One sandbox per episode**, from the image `benchmarks/birdbench/auto_ontology/build_image.sh` builds. That image
holds the Auto Ontology version Gym pins, the databases and their catalog. The agent's process imports only Gym.

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.

NOTE: Could the README name the pinned Auto Ontology version and the capability level?
The README says the image holds "the Auto Ontology version Gym pins" but not which one, and does not state the harness's capability level. The add-harness exit checks ask the adapter README for both, and readers comparing results against Auto Ontology's own runs will need the commit. Something like "Auto Ontology a00a3906, Evaluation level" next to the supported pairing would cover it.

ffrujeri and others added 14 commits December 4, 2026 00:18
…e sandbox per episode

The Auto Ontology Agent Server runs Auto Ontology's own ReAct loop, prompts and
tools on the policy model. At the seed it starts a sandbox from the catalog image
with the episode runner, and starts the catalog's Postgres on a port of its own;
at the activation it runs Auto Ontology's run_episode there, with every model call
through the policy's Model Server on the rollout's route, and answers with the
submitted query in a fenced sql block; at the close it stops the sandbox.

auto_ontology_agent.yaml pairs it with BIRD dev on single_agent_turn, and bird_sql
grades its query as it grades simple_agent's. prepare.py's agent_context option
writes the rows: the task in the agent context, and no schema.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
main bounded e2b below 2.51.0 and ray[default] below 2.60, which the lock records in nemo-gym's requires-dist.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
The base class reads the seed's agent context before it calls _seed_agent_session_state, so a seed with a lent
sandbox and no task got the context's refusal, not the sandbox one. The Environment Server compliance probe
(rule A4) seeds exactly that and reads the reply for 'does not support sandbox access'. The refusal now runs in
parse_agent_context, ahead of the context.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…se, and refuse controls the loop ignores

A catalog that did not start closed the session, and a close that also failed left no state behind, so a later
close could not stop the sandbox again. The seed now raises AgentSessionSetupError with the session, as codex_agent
does, and close retries the stop.

Auto Ontology's loop sets its own sampling, limits and instructions, and the activation dropped any the caller set.
An activation that sets a field the episode does not honor now gets a 422, as pi_agent's does; the input, the
configured model, metadata and the stream flags off are accepted.

max_concurrent_episodes bounds the episodes this server runs at once, not the sandboxes: each session holds its
sandbox from seed to close. The comment and README say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…ql's schema

The Auto Ontology agent's instance declared the dataset. The agent references no Resources Server and ships no
task_data.py, and single_agent_turn has none, so collation checked the rows against no schema: a row without gt_sql
reached the episodes. bird_sql's instance now declares the dataset, as the typed Terminal-Bench 2.1 pairings declare
theirs, and collation rejects that row (task_data_validation=error).

The prepare example passes the embedding key: the agent's config requires it, though prepare does not call the
endpoint.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…harnesses

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…p gave up on, and keep a sandbox start() left running

Auto Ontology's ReAct loop ends with "model_error" and no submission when a model call fails after its retries. The
agent answered that like an episode that chose not to submit, so the task was graded zero and not masked. The runner
now keeps the exception the loop gave up on and reports its HTTP status, or that the call got no reply. The agent then
answers `failed`, with failure kind model_request_error (and the status) or model_transport_error, so the Environment
Server's outcome policy grades, retries or fails the episode. An episode with no submission for another reason is
still graded.

start() can create the sandbox, fail to deliver the runner, and fail to stop it. The seed then closed the provider's
client and dropped the sandbox, so nothing could stop it before its ttl. The seed now closes such a sandbox through
the session, as it does one whose catalog did not start, and keeps it for close when that stop fails too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…main does

On Auto Ontology's main, the ReAct tools open the catalog's retrievers themselves, and ToolContext no longer takes
them: Auto Ontology's own ReactSQLAgent passes only the connectors and the question. The runner does the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
The runner writes result.json only when the episode ends, so one the supervisor stopped at
episode_timeout_seconds had no result: the read failed and the activation became a route failure, which
single_agent_turn retries and can leave the evaluation incomplete. When the supervisor confirms it stopped
the episode at its limit, the agent now answers with no query, as an incomplete response, which the outcome
policy grades. A missing result after a crash, or with an unconfirmed stop, still fails the activation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
resolve_provider_config leaves out the block's default_metadata, so the agent's sandboxes lost the provider's
labels. The spec now takes them, then the agent's own sandbox_config.metadata over them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Each episode holds a sandbox and its Postgres from seed to close, and with no run-side bound every queued row
seeded one while waiting for the agent's eight episode slots. auto_ontology_agent.yaml now sets
num_samples_in_parallel to 8, the agent's max_concurrent_episodes; --concurrency still overrides it. A test
keeps the two equal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…nt's task

prepare.py wrote the agent context and the agent declared it as AutoOntologyTask, with no check that the two
agree: a question that was only evidence passed preparation and BIRD's TaskData, then failed at the seed.
agent_task() now builds the context and refuses a task with no question of its own, and a core test parses
what it writes with the agent's AutoOntologyTask.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
auto_ontology_agent.yaml changes BIRD dev's prompt and tools, not only the harness: the agent searches its own
catalog and writes its own prompts. The manifest guidance gives such a config its own manifest, so the catalog
lists birdbench/auto_ontology_agent with prompt_source: agent and the embedding endpoint's network
requirement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…ent_turn lends

Sandbox Everything has the Environment Server own each attempt's sandbox and the
agent borrow it. BIRD dev's Auto Ontology pairing now sets single_agent_turn's
sandbox_provider and sandbox_config, with the catalog image, so single_agent_turn
starts the sandbox, lends it at seed and stops it after the agent closes.

The agent borrows a lent sandbox: it uploads the episode runner, starts the
catalog there and releases the client at close. With no lent sandbox it starts
its own, as before, which BIRD-Interact still needs, and its seed reply now
names that sandbox (calls_model_from_sandbox), as single_agent_turn requires of
an agent that runs tools in a sandbox it owns. A lent sandbox with a
network_access other than inherit, or no sandbox and no sandbox_provider, is
refused at seed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@ffrujeri
ffrujeri force-pushed the ffrujeri/birdbench-auto-ontology-agent branch from 21c8645 to 6f960ac Compare December 4, 2026 00:35
ffrujeri added a commit that referenced this pull request Dec 4, 2026
…ort, and record a turn whose model call failed

A 200 from ask_user whose body did not arrive whole raised http.client.IncompleteRead while reading it. That is not a
URLError, so call_tool let it through, Auto Ontology's loop turned it into tool feedback, and the call was never
recorded: the turn could go on to a scored submission although the server may have counted the question. call_tool now
treats any failure to read the reply (IncompleteRead, a reset connection) as a call that got no reply, which run()
raises once the loop returns, so the activation fails without asking again.

A c-Interact turn whose model call the loop gave up on now answers `failed`, by the model failure fix in #6289, and its
invocation record says `failed` too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@ffrujeri

ffrujeri commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 6f960ac

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer risk:high Autobot PR risk: high sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants