Skip to content

Agent renames should update routing, rows, and dataset pins like agent swaps #4158

Open

Description

@ananthsub

Problem

Gym renames agents in two ways, and they do not follow the rename the same way.

  • Agent swap: compose_unbound_agent renames each target instance, then runs three steps on the old-to-new names.
    • _retarget_environment_servers points environment servers at the new name.
    • _raise_on_outdated_routing raises an error when agent_name, an agent_map value, or a fan_out entry still names the old instance.
    • _route_rows_stamped_before_the_swap adds an agent_map entry from the old name to the new one, so rows whose agent_ref uses the old name still reach the agent.
  • Rename with _inherit_from: after fix(config): preserve environment server references when agents are renamed #4141, _recursively_swap_keys runs only _retarget_environment_servers.

Neither path updates dataset agent: pins, which dataset_agent_pins reads.

The gaps show up late. A rename that leaves agent_name: <old name> in the config loads, then fails during rollout collection. A dataset pin that names a renamed or swapped agent loads, then fails in resolve_dataset_agent during benchmark discovery, gym eval prepare, collation, or dispatch.

Proposed change

flowchart TD
    R["Rename with _inherit_from<br/>found in parse()"]
    W["Agent swap<br/>compose_unbound_agent()"]
    S["_follow_renamed_agents(renames)<br/>one step, called by both"]
    E["Environment server references<br/>point at the new name"]
    T["agent_name, agent_map values, fan_out<br/>naming the old name raise an error"]
    M["Rows stamped with the old name<br/>reach the new agent through agent_map"]
    P["Dataset agent: pins<br/>rewritten to the new name"]
    R --> S
    W --> S
    S --> E
    S --> T
    S --> M
    S --> P
    classDef done fill:#E1F5EE,stroke:#0F6E56,color:#085041
    classDef todo fill:#FAECE7,stroke:#993C1D,color:#712B13
    class E done
    class S,T,M,P todo
Loading

Green already runs for both paths after #4141.

  • Move the three swap steps into one method, for example _follow_renamed_agents(global_config_dict, renames), and call it for swaps and renames.
  • Add a step that rewrites dataset agent: pins naming the old agent, for both swaps and renames.
  • Reword the _raise_on_outdated_routing message, which says "once the agent is swapped", so it also fits a rename.
  • Move rename detection out of _recursively_swap_keys, which is the generic pass for _inherit_from, _copy, and _delete_key, into a named step that parse() calls.
  • Use one helper for the rule that decides which environment server fields reference an agent. After fix(config): preserve environment server references when agents are renamed #4141 the rule is written out in environment_server_agent_refs and again in _raise_on_ambiguous_environment_agent_renames. The migration script keeps its own copy, checked by a test.

Compatibility

144 config files under benchmarks/ rename an agent with _inherit_from and declare their own environment server for the new name. The shared step will run for them. Every benchmark should resolve to the same agent and environment servers as before, and gym eval list --json output should not change. The expected difference in resolved configs is the added agent_map entries.

Tests

  • A rename where agent_name, an agent_map value, or a fan_out entry names the old agent raises the same error a swap does.
  • A row whose agent_ref names the old agent is dispatched to the renamed agent.
  • A dataset agent: pin naming the old agent resolves to the new agent through resolve_dataset_agent, after a rename and after a swap.
  • A chained rename, a to b to c, either loads with the server on c or fails with a clear error.
  • A rename and an agent swap in the same config.
  • A rename whose new entry adds a second agent type is not followed, and fails with a clear error.

Follows #4141 and #4053.

Activity

  1. added
    area:config
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platformarea:config

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions