Repository navigation
feat(bird_interact): grade BIRD-Interact's management tasks by their test cases - #5534
Merged
Merged
Conversation
Contributor
Author
|
/ok to test 8af4574 |
ffrujeri
force-pushed
the
ffrujeri/bird-interact-management-tasks
branch
from
November 4, 2026 21:33
8af4574 to
badefcb
Compare
Contributor
Author
|
/ok to test badefcb |
ffrujeri
force-pushed
the
ffrujeri/bird-interact-management-tasks
branch
from
November 6, 2026 17:23
badefcb to
183156e
Compare
Contributor
Author
|
/ok to test 183156e |
ffrujeri
force-pushed
the
ffrujeri/bird-interact-management-tasks
branch
from
November 9, 2026 19:11
183156e to
7d5fd8d
Compare
Contributor
Author
|
/ok to test 7d5fd8d |
Contributor
Contributor
Author
|
/ok to test 971dbae |
Contributor
Author
|
/ok to test 63b6bb3 |
Contributor
Author
|
/ok to test ecf859f |
Contributor
Author
|
/ok to test 34d0e06 |
ananthsub
reviewed
Nov 20, 2026
Contributor
Author
|
/ok to test a5db377 |
Contributor
Author
|
/ok to test 663f2b2 |
Contributor
Author
|
/ok to test c7a2c52 |
adil-a
approved these changes
Nov 23, 2026
…test cases The bird_interact Environment Server refused the management tasks at seed (105 of Lite's 300, 190 of Full's 600), and the recipe left them out. The benchmark is the whole task set, so they now run, in both modes (GYMINT-681). grading.py grades a management phase as the BIRD-Interact ADK does, in an independent implementation: on a copy of the episode's database, the submission runs and its writes stay, then each test case runs with the ADK's six globals (execute_queries, ex_base, the three rewrites, pred_query_result), in order, until one raises. The copy is dropped, so a failed submission leaves the database as it was; a passing phase 1 is applied for phase 2, as before. Test cases run in the episode's sandbox, never on the Gym host, on PostgreSQL only (GYMINT-683, GYMINT-684). The server sends a management phase's test cases with its grade request and gives the command time for them. prepare.py keeps every task with its ground truth. The real-PostgreSQL test fixture failed to start with psycopg2 2.9 (`with connection:` opens a transaction even in autocommit); it is fixed, because the new tests need it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…ding failures correctly From the review of the BIRD-Interact stack: - PostgreSQL: agent SQL runs only on copies of the episode's database, as the ADK resets its task database before each submission: exploratory queries on a working copy, each submission on a fresh copy. A COMMIT in agent SQL no longer changes later grades or phase 2. - PostgreSQL: one deadline for a whole query, enforced by cancelling it, so a script of many statements, or one with a COMMIT, cannot outlast it. - SQLite: agent SQL cannot ATTACH the episode's own file. - A solution that fails after the submission runs again on the episode's database: a submission that broke its state is wrong, as in the ADK, and only a solution that fails there too is bad task data. - A passing phase 1 that cannot be applied fails the command (default test case) or the phase (test cases), instead of passing without its changes. - A numeric too large to round is a failed comparison, as in the ADK, not a crash of the runner. - A sandbox command has time for every script the grader may run. - A tool call cut off by its deadline masks the sample, in both modes. - The SQLite wording changes the ADK's texts only, not the task they hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…he ADK does When a task's solution SQL fails even on the episode's own database, the server failed the whole episode, and the rollout lost the reward of the phases already passed. The ADK's ex_base returns 0 for such a solution: the submission is wrong, the agent gets its debug turn, and earlier phases keep their reward. The server now does the same, and lists each such error in the rollout's solution_errors. The benchmark README lists the 24 Lite tasks whose solution SQL fails at grading (the ADK's DISTINCT removal, invalid SQL, and phase 2 solutions that need what phase 1's solution creates), and how to run Claude Haiku 5.5 as the simulator. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…the ADK shows get_all_knowledge_definitions and get_knowledge_definition returned each knowledge-base entry whole, with its type and its children's ids, which the ADK's /knowledge endpoint leaves out (KNOWLEDGE_VISIBLE_FIELDS). They now show the entry's id, name, description and definition, as a JSON array or object as the ADK writes it, as the c-Interact instruction already did. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…and close the review's grading gaps From the team review of the stack: - Agent SQL ran as PostgreSQL's superuser, which could turn on statement logging, read the server's log or files, or run programs, and so read the solution SQL that grading runs. The image now has bird_agent (BIRD_INTERACT_AGENT_ROLE), not a superuser, which owns each template's objects (agent_role.sql). grading.py runs the task's setup, the agent's SQL and grading as it; only the copies are made by the superuser. Grading each task's own solution as its submission gives the same result as before for every Lite and Full task but three management tasks whose solution needs a superuser (session_replication_role, CREATE ROLE), which the README lists. - SQL that breaks the driver (a date past year 9999, a huge interval, a NUL, pg_terminate_backend) made the command fail, which masked the sample. It is now the query's error, as in the ADK. - A management phase's queries had only a per-statement timeout: they now have one deadline each, as default grading has. Its command budget counts up to ten queries per test case, and a passing phase that fails to apply fails the command, as default grading's does. - A solution run again alone after the submission broke it ran on the episode's database, where a COMMIT in it stayed: it runs on a copy. - SQLite reads only the last statement's rows, at most the ADK's 10,000, and a preview cuts each value at 100 characters, as the ADK does. - A sandbox replacement no longer holds a server-wide query slot. - start_postgres says why the server did not start. The real-PostgreSQL fixture always stops its server. The example config sets no image, so an unset PostgreSQL image is refused at startup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…est cases in the environment list #5475's row says the recipe grades query tasks by result comparison; this PR also grades management phases, by their test cases. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…ck and a-Interact's PostgreSQL instructions Each of these passed with the behavior reverted: a task setup that fails now fails the runner command, an episode with no configured image starts the SQLite image, and a-Interact's instructions name PostgreSQL on PostgreSQL. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…d; report a capped result's count - A `submit_sql` that an infrastructure failure keeps from being graded returns an error that ends the activation, as a graded submission does, so the policy is not called again. The sample is masked, as before. - `execute` reports a result over the 10,000-row cap as `10000+ rows`, a lower bound, from a `truncated` flag on the runner's result. - Tests for rules that had none: a failing submission is not applied; phase 2 sees phase 1's changes on the same sandbox; comments are removed before the ROUND rewrite; a submission over the SQL timeout gets the ADK's timeout message; the row cap's count. Each fails with its rule removed. - The README drops an internal tracker key. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Environment Servers ship `task_input.py`, exporting the `TaskInput` their episode request validates, so data tooling can check rows against it without the server's dependencies (#6447 → #6449, which also requires every Environment Server to ship one). Such a module may import only the standard library, pydantic and resources servers' `task_data` modules, so the task models move from `task_data.py` into it; `task_data.py` keeps its `TaskData` export for the task-data tooling, and the server, the simulator and the recipe import from `task_input.py`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…s error, not a runner crash Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
ambiguity_count, needs_custom_test_cases and custom_test_cases decide the episode's budget and grading, and only app.py uses them, so they move there. task_input.py keeps the models that rows validate against. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…QL, and apply the review's other fixes From the review of the management tasks: - Agent SQL could read the solution SQL, or break later grades, through state that every copy of the episode's database shares: a database's comment and settings, which the agent role could change as the owner of <db>_template and of each copy, and the role's own settings (ALTER ROLE ... SET). The superuser now owns the databases and grants the role CREATE and TEMPORARY on them, and resets the role's settings before it makes each copy and before it writes the episode's database. A connection that a test case opens itself is the agent role's. - A command cut off by the tool call's deadline or the interaction deadline is no longer a sandbox failure: the call fails, and a submission cut off so is a failed attempt. Only a SandboxCommandError gets the not-graded reply. - The rollout keeps a failing test case's exception (test_case_errors), which the agent does not see. - c-Interact, which has no execute tool, makes no working copy. - The aggregate metrics count the samples with a solution error, and mask_solution_errors masks them. - A long preview value is cut from its text, not its repr. "The solution SQL failed". Renames: fresh_copy, episode_database, _command_query_budget. README: ten queries for each test case, and two more ADK differences. - Tests: the re-run of a broken solution is reached (DROP TABLE IF EXISTS); a test case's own connection sees the submission's writes; a management submission can create a schema in its copy. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…ig and schemas.py Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Contributor
Author
|
/ok to test 8bba79c |
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/45198979921 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #5478 (ADK parity), in the BIRD-Interact stack: #5465 → #5409 → #5473 → #5475 → #5478 → this PR. The diff against #5478 is the
bird_interactEnvironment Server (grading.py,app.py,task_data.py, README, tests) and the recipe'sprepare.py, README and tests.What changed
BIRD-Interact's management tasks now run: 105 of Lite's 300 tasks and 190 of Full's 600. Until now, the server refused them at seed and
prepare.pyleft them out, so Gym ran only the query tasks, as auto-ontology-eval does. The benchmark is the whole task set, so the decision is to run them, in both modes.The BIRD-Interact ADK (revision
451fe2c) grades a management phase by its test cases: Python functions from the ground truth,test_case(pred_sqls, sol_sqls, db_name, conn), that inspect the database after the submission ran and raise when it is wrong.grading.pynow does the same, implemented independently:CREATE DATABASE … TEMPLATE), whichgrading.pydrops afterwards. The submission runs first and its writes stay on the copy, so the test cases see them; a failed submission leaves the episode's database as it was. A passing phase 1 is then applied to the episode's database, as for a query phase, so phase 2 starts from its state and a fresh sandbox replays it.execute_queries(each query committed under the statement timeout; returns rows, error, timed out),ex_base(the default test case's comparison),remove_comments,remove_distinctandremove_roundon lists of SQL, andpred_query_result. As in the ADK, they run in order, the first that raises anything fails the phase, and the code runs with those six names as its globals and its own locals, so its functions do not see its top-level imports. What a test case prints goes to standard error, so the command's JSON result stays alone on standard output.custom_test_cases), and gives the sandbox command time for the submission and ten queries for each test case. A query phase is graded by its result, as before, even when it has test cases. With SQLite (Mini-Interact, which has no management tasks), a task with such a phase is still refused at seed.A broken solution SQL (one that fails even on the episode's own database) no longer fails the episode. The ADK's
ex_basereturns 0 for it: the submission is wrong, the agent gets its debug turn, and earlier phases keep their reward. The server now does the same and lists each such error in the rollout'ssolution_errors. Before, the rollout lost phase 1's reward when phase 2's solution was the broken one. The benchmark README lists the 24 Lite tasks this affects, by cause: the ADK'sDISTINCTremoval, which Gym copies, turnsDISTINCT ONintoONandIS DISTINCT FROMintoIS FROM(11); invalid solution SQL (5); phase 2 solutions that need what phase 1's solution creates (8). It also says how to run Claude Haiku 5.5 as the simulator.a-Interact's knowledge tools (
get_all_knowledge_definitions,get_knowledge_definition) returned each knowledge-base entry whole, with itstypeand its children's ids, which the ADK's/knowledgeendpoint leaves out (KNOWLEDGE_VISIBLE_FIELDS). They now show each entry's id, name, description and definition, as a JSON array or object as the ADK writes it, as the c-Interact instruction already did.The real-PostgreSQL test fixture failed to start: since psycopg2 2.9,
with connection:opens a transaction even in autocommit, whereCREATE DATABASEcannot run. It is fixed here, because the new tests need it; the four tests it serves ran for the first time.No public issue: the PRs of the BIRD-Interact stack track the work. A follow-up checks the grading against the ADK with the real management test cases, which come with the ground truth.
Validation
pytest environment_servers/bird_interact/tests(server venv, host)initdbpsycopg2-binary)pytest benchmarks/bird_interact/testspytest environment_servers/bird_interact/tests(server venv, host) andpytest benchmarks/bird_interact/tests555bc053d6:pytest environment_servers/bird_interact/tests(server venv),pytest benchmarks/bird_interact/tests,pytest responses_api_agents/simple_agent/tests(its venv),pre-commit run --fileson the stack's filestest_the_knowledge_tools_show_the_fields_the_adk_shows_and_not_the_hidden_entryfails without the changedb_environment/server.py) and helpers (shared/db_utils.py) againstgrading.py's commandex_base,pred_query_result,execute_querieswithout a connection, the rewrites, several test cases, code withouttest_case, and one task across both phases). After each grade, the episode's database was unchanged and the copy was gone.test_a_top_level_import_is_not_visible_to_the_test_case; grading on the episode's database instead of a copy failstest_test_cases_see_the_submission_s_writes_on_a_copy_that_is_droppedpre-commit run --fileson the changed filesNot validated yet: the real management test cases. The ADK's original evaluation (
evaluation/src) gives a test case more names than the ADK does, such ascheck_sql_function_usage; Gym gives the ADK's six, so a real test case that calls another would fail in both. That follow-up will show whether any does.Rollout evidence
On Docker sandboxes, with
simple_agent; policyazure/openai/eccn-gpt-6.1-sol, simulatoropenai/openai/eccn-gpt-6-luna; Lite through the recipe and its image. The real ground truth is not in hand, so two management tasks got a stand-in, written from their questions, the knowledge base and the schema; its reference SQL passes both phases' test cases in the image, and a wrong submission fails. Its rewards are not results.alien_M_2: a PL/pgSQL function, then the same function with an optional threshold parameteralien_M_3: a view of computed factors, then a filtered view over itcrypto_2(stand-in from #5478)Phase 2 of each management task built on phase 1's applied state:
alien_M_2dropped phase 1's function by its signature, andalien_M_3's second view selects from the first. No rollout was masked, and the failures file is empty. One a-Interact simulator reply was the action itself (labeled("some recent executions")), the quirk that #5478 notes; the ADK reads it the same way.Compatibility
Within the unmerged stack: the recipe's task counts change from 195 to 300 (Lite) and 410 to 600 (Full), so a run's mean reward now covers management tasks too; compare auto-ontology-eval's numbers with the query tasks alone. No config change; no new dependency.
Team review fixes (2026-11-19)
From a team review of the stack, placed here, where the runner is final (76b3a6d97a, 82023bb):
bird_agent(BIRD_INTERACT_AGENT_ROLE), not a superuser, which owns each template's objects (agent_role.sql);grading.pyruns the task's setup, the agent's SQL and grading as it, and only makes the copies as the superuser. Grading every task's own solution as its submission, before and after, gives the same result for all 300 Lite and 600 Full tasks but three management tasks whose solution needs a superuser (session_replication_rolein Lite'sgaming_M_4andvirtual_M_4,CREATE ROLEin Full'svirtual_idol_M_2), which the README lists (andarcheology_scan_M_1, whose statistics check is timing-dependent either way).pg_terminate_backend) is the query's error, not a failed command that masked the sample.COMMITin it cannot reach the episode's database (Fullvirtual_idol_M_3).start_postgressays why the server did not start; the real-PostgreSQL fixture always stops its server; the example config sets no image.insider_M_4/insider_M_6fail only phase 2;solution_errorscovers query phases; management phases, not tasks, are graded by test cases.Validation at 82023bb: server tests 92 passed, 14 skipped on the host; 106 passed in the Lite image, the real-PostgreSQL tests among them; prepare and validation tests 135 passed; pre-commit passed; each lower branch's tests pass on its own.
Not changed (follow-ups): per-category metrics in
aggregate_metrics; psycopg2 holds a whole PostgreSQL result in memory before the 10,000-row cut; a PL/pgSQL block that catchesquery_canceledoutlasts the deadline.Review fixes (2026-11-19, second round)
The second review of #5473 listed lines that no running test caught. Those whose code is final here have tests in 971dbae: a task setup that fails fails the runner command; an episode with no configured image starts the SQLite image; a-Interact's instructions name PostgreSQL on PostgreSQL. Each fails with its change reverted. #5473 (9509a7b) and #5475 (169374b) carry the other fixes, rebased into this branch.
Validation at 971dbae: server tests 96 passed, 14 skipped on the host; 110 passed in a Debian container with PostgreSQL 15 and the server's venv, the real-PostgreSQL tests among them; prepare tests passed; pre-commit passed; #5475's and #5478's heads pass their server and prepare tests.
Review fixes (2026-11-20)
From the reviews of #5409 and #5478, fixed here where the code is final:
submit_sqlthat an infrastructure failure keeps from being graded ends the activation, so the policy is not called again;executereports a result over the 10,000-row cap as10000+ rows; tests for rules that had none (a failing submission is not applied, phase 2 sees phase 1 on the same sandbox, comments removed before the ROUND rewrite, the timeout message), each failing with its rule removed.task_input.py, the module that feat(environment): add task input modules for environment servers #6447 → fix(data): check collated rows against the server that receives them #6449 load to check rows against the server that receives them, and that feat(environment): add task input modules for environment servers #6447 requires of every Environment Server.task_data.pykeeps itsTaskDataexport.Validation at 34d0e06:
bird_interact107 passed, 14 skipped on the host, 121 passed with PostgreSQL 15; core suite 26,017 passed at ecf859f; pre-commit passed.a5db377 moves
ambiguity_count,needs_custom_test_casesandcustom_test_casesfromtask_input.pytoapp.py, the only module that uses them, sotask_input.pyholds only the row schema.bird_interacttests: 107 passed, 14 skipped on the host; 121 passed with real PostgreSQL.Review fixes, third round (2026-11-21)
bbc14f7 applies ananthsub's third round:
bird_agentgets onlyCREATEandTEMPORARY. The superuser resetsbird_agent's role settings before each copy and before each write to the episode's database. New real-PostgreSQL tests cover the comment,application_nameandsearch_pathchannels. The rebuilt Lite image was checked as well.SandboxCommandErrorfromsubmit_sqlends the turn as not graded.PGUSER=bird_agent.test_case_errors), never to the agent.explore).solution_errorsmetric andmask_solution_errorsswitch.repr.fresh_copy,episode_database,_command_query_budget,failed_test_case.663f2b2 names
task_input.pyin the config andschemas.py.bird_interacttests: 113 passed, 21 skipped on the host; 134 passed with real PostgreSQL. Core suite: coverage 95.09%.