Repository navigation
feat(data): collate stamps task_source; datasets declarable on resources servers - #2717
Conversation
2950bd8 to
82f45bb
Compare
9b7a24e to
cb11a33
Compare
cb11a33 to
3e1bea1
Compare
ae823b6 to
87daca3
Compare
87daca3 to
a2aa069
Compare
a2aa069 to
b5b4c6e
Compare
|
/ok to test b5b4c6e |
|
/ok to test 2ffcbf0 |
b5b4c6e to
2ffcbf0
Compare
2ffcbf0 to
accee16
Compare
…paths Review feedback on #2717: 1. /verify routed rows with _rs_for_row (task_source authoritative), but reverified results retained only agent_ref, and aggregation grouped by agent and posted to the agent's configured resources server - so a remapped row could be verified by one server and aggregated by another. Reverified results now retain task_source, the aggregation projection carries it, and aggregation routes each group with the SAME _rs_for_row resolver (grouped per (agent, resources server)). 2. The per-declaration prepared-file fallback ({stem}_prepare.{instance}) collided when ONE instance declared the same jsonl_fpath repeatedly: every declaration after the first picked the same name and overwrote its predecessor. Candidates are now tried until unused - bare stem, instance-qualified, instance+dataset-qualified, then numbered - so the existing names stay byte-identical and repeats within an instance get distinct files. Tests cover 3x same path in one instance and 4x with identical dataset names. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
350ed9c to
4f649fa
Compare
|
/ok to test 4f649fa |
…paths Review feedback on #2717: 1. /verify routed rows with _rs_for_row (task_source authoritative), but reverified results retained only agent_ref, and aggregation grouped by agent and posted to the agent's configured resources server - so a remapped row could be verified by one server and aggregated by another. Reverified results now retain task_source, the aggregation projection carries it, and aggregation routes each group with the SAME _rs_for_row resolver (grouped per (agent, resources server)). 2. The per-declaration prepared-file fallback ({stem}_prepare.{instance}) collided when ONE instance declared the same jsonl_fpath repeatedly: every declaration after the first picked the same name and overwrote its predecessor. Candidates are now tried until unused - bare stem, instance-qualified, instance+dataset-qualified, then numbered - so the existing names stay byte-identical and repeats within an instance get distinct files. Tests cover 3x same path in one instance and 4x with identical dataset names. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
4f649fa to
4d23c17
Compare
|
/ok to test 4d23c17 |
|
/ok to test e5ca6fc |
|
/ok to test 8b5cf38 |
|
/ok to test 0fd5971 |
…ces servers Producer side of the dataset-agent decoupling (consumers shipped in the previous PR): - Datasets may be declared on resources server blocks (the decoupled home: the RS owns the task schema and verifier). Data prep now reads datasets from any declaring instance — RS or agent. Model servers with datasets are a hard error. Agent-block declarations where the agent has a resources_server edge get a deprecation warning; self-contained agents (no RS edge) are exempt, they are the legitimate declaring instance. - Collate stamps task_source = the declaring instance name onto every prepared row, per declaration. The legacy agent_ref is dual-stamped for one deprecation cycle: the declaring instance itself when it is an agent (byte-identical to today), else the unique agent referencing the declaring RS; ambiguous cases stamp task_source only and resolve at dispatch. - Per-declaration prepared files: two instances declaring the same jsonl_fpath previously had the second silently truncate the first, leaving all rows with the last declarer's stamp. Each declaration now writes its own file (collision-suffixed with the instance name). - Reverify routes by task_source when a row carries one (the declaring RS is authoritative; no agent indirection); the resources-only single-RS fallback now warns loudly instead of silently absorbing stale agent names, and unmapped rows fail with a clear error instead of a bare KeyError. - agents_by_resources_server() extracted to global_config and shared by the dispatch resolver and collate. Replay verification over all 225 runnable config closures: zero routing or materialized-input changes; zero prepared-row content changes (stamp-only diffs on all 323 prepared/collated files); the only new files are the four swe_agents alias declarations that were previously silently truncated. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
…gration PR Warning about agent-block dataset declarations before the in-repo configs are migrated would make every collate run warn about a move the migration PR performs anyway. Both declaration homes are equally supported until then; the warning ships together with the migrated configs, where its only remaining audience is out-of-repo configs. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
…ed with warning Processed datasets carry no agent identity: the dual-stamped legacy agent_ref is removed from collate output (the agent is a run-time choice, resolved from config at dispatch). Rows arriving with a legacy agent_ref get it stripped, with one DeprecationWarning per file. Consequences for consumers: old collated files keep working via the resolver's legacy path (deprecated separately); new collated files require a Gym version with the resolver at training time — trainer integrations coordinate their embedded-Gym bump with this release. Adds the processed-format contract test: every collated row has task_source and responses_create_params, and never agent_ref, so format drift cannot land silently. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
…paths Review feedback on #2717: 1. /verify routed rows with _rs_for_row (task_source authoritative), but reverified results retained only agent_ref, and aggregation grouped by agent and posted to the agent's configured resources server - so a remapped row could be verified by one server and aggregated by another. Reverified results now retain task_source, the aggregation projection carries it, and aggregation routes each group with the SAME _rs_for_row resolver (grouped per (agent, resources server)). 2. The per-declaration prepared-file fallback ({stem}_prepare.{instance}) collided when ONE instance declared the same jsonl_fpath repeatedly: every declaration after the first picked the same name and overwrote its predecessor. Candidates are now tried until unused - bare stem, instance-qualified, instance+dataset-qualified, then numbered - so the existing names stay byte-identical and repeats within an instance get distinct files. Tests cover 3x same path in one instance and 4x with identical dataset names. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
|
/ok to test 5f75693 |
| # for /verify (_rs_for_row: task_source authoritative, agent_ref via config edges as the | ||
| # fallback). Routing aggregation independently by the agent's configured server allowed a | ||
| # remapped row to be verified by one server and aggregated by another. | ||
| agent_results: Dict[Tuple[str, str], List[Dict]] = {} |
There was a problem hiding this comment.
The rows are now split by (agent_name, rs_name), but _fetch_agent_metrics() returns only agent_ref, and the export loop still keys metrics as {agent_name}/{metric}.
If one runtime agent handles tasks from two resources servers, both groups produce the same keys. The second dict.update() overwrites the first, and the JSON entries cannot identify which verifier produced either result.
this topology isn't explicitly disallowed, so we should support this edge case by carrying the rs_name into agent_entry and including it in the exported results
| if ts is not None: | ||
| block = global_config_dict.get(ts) | ||
| if isinstance(block, (dict, DictConfig)) and "resources_servers" in block: | ||
| return str(ts) |
There was a problem hiding this comment.
_guard_reverify_mode() still checks only the servers reached through the agent-to-resources-server mapping.
For example, a row can carry task_source=rs_x and be routed through an agent whose configured edge points to rs_y; verification calls rs_x, while preflight checks only rs_y. An unsupported rs_x can then run without --force or the unsafe_ output prefix.
Please derive the preflight server set from the actual rows with this same resolver. we should test where the task source and the selected agent's configured server disagree
Problem
Today a dataset can only be declared inside an agent's config block, and
gym dataset collatewrites that agent's name into every prepared row. Three concrete failures:datasets:list sits in, and then frozen into every row of the output.jsonl_fpath, the second one's prepared file overwrites the first's. All rows end up labeled with the second declarer. This happens silently. Real case in this repo: theswe_agents_val/swe_agents_trainalias configs.Change
1. Datasets can now be declared inside a resources server's block.
Where a
datasets:list is allowed to live, enforced when the config loads:datasets:declared inside…resources_server:line (tau2, osworld, the SWE harnesses — these agents score their own results in-process; there is no separate resources server)resources_server: {name: X}line2. Collate labels every prepared row with
task_source= the name of the block that declared its dataset.A prepared row, before:
After — the agent name is gone; the declaring block's name is the only label:
At run time, #2713's resolver turns
task_sourceback into an agent by reading the current config. Collated output carries noagent_refat all — the agent is a run-time choice, never part of the data. Two compatibility rules make this safe:agent_ref, notask_source) is fed to a runDeprecationWarningper run counting themagent_refThe version rule that follows: new collated files require a Gym with the resolver (this release) at training time. Old files work everywhere, forever (until the separately-gated cleanup PR). A CI contract test pins the processed format — every collated row has
task_source+responses_create_paramsand neveragent_ref— so format drift cannot land silently.3. Fix: declaring the same source file twice no longer corrupts the output.
Background: collate works in two steps. For each
datasets:entry it first writes an intermediate "prepared" file next to the source data (example.jsonl→example_prepare.jsonl), containing that dataset's rows with the routing label added. Then it concatenates all the prepared files into the final output.The prepared file's name came only from the source filename. So when two config blocks declare the same source file — real configs do this:
swe_agents_valandswe_agents_trainboth declare oneexample.jsonl, and jailbreak's five policy agents share one too — both declarations wrote to the same prepared file, and the second write deleted the first. The final output then contained the rows twice, both copies labeled with the second declarer. The first declarer's correctly-labeled rows were silently gone.4.
gym eval reverifyusestask_sourceto find the verifier. When a row carriestask_sourcenaming a resources server, reverify sends the row straight there — it no longer needs to look the agent name up first. Two silent behaviors also become loud: (a) when the config has no agent blocks and exactly one resources server, reverify sends every row there no matter what agent name the row carries — it still does, but now prints a warning saying so, because this mode also hides typos and stale names; (b) a row whose agent name is unknown used to crash with a bareKeyError— it now gets an error stating the row's agent name, its task_source, and the list of known agents.What does NOT change
We re-ran the full pipeline (load configs → collate → build the run's input rows → send each row to its agent, with the network call stubbed out) on every runnable config in this repo — 225 of them — on the code before and after this PR, and compared the outputs:
task_sourcelabel.)Tests
284 passed across the collate/rollout/reverify suites. New tests pin every rule above: each row of both tables, the per-declaration file separation, and reverify's
task_sourcerouting and loud fallback.Where
agent_refis headedTo be explicit:
agent_refin data files ends with this stack. This PR stops writing it into prepared/collated files entirely:agent_refin data files--agent's routing meaning retires in favor of #1583's asset selectorIt survives permanently in exactly one place: run outputs (rollout results, materialized inputs), where Gym computes and records which agent actually ran each row — provenance, not routing.
Stack
PR 3 of the dataset↔agent decoupling stack (RFC: gym-dataset-preparation, Open Question 1). Base: #2713.
🤖 Generated with Claude Code