Skip to content

feat: allow to swap agents when parsing the config - #2640

Merged
marta-sd merged 6 commits into
mainfrom
martas/agent-composition-transform
Aug 28, 2026
Merged

marta-sd merged 6 commits into
mainfrom
martas/agent-composition-transform

Conversation

@marta-sd

@marta-sd marta-sd commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

This PR introduces possibility to compose a new config at runtime by combining a benchmark / env config with an agent config template.

The mechanism is based on finding an agent config with undefined resources server:

codex_agent:
  responses_api_agents:
    codex_agent:
      resources_server:
        type: resources_servers
        name: ???

and filling the missing part with information from resources server configuration available in the global config.

The entire PR stack will introduce the following changes:

  1. config composition (this PR)
  2. --agent-type flag in the CLI for selecting the agent
  3. safeguard preventing unsupported env <> agent pairings
  4. aligning with dataset changes introduced in epic epic: dataset preparation #1338
  5. docs update

@copy-pr-bot

copy-pr-bot Bot commented Aug 20, 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.

@marta-sd
marta-sd force-pushed the martas/agent-composition-transform branch from a4d2620 to 6f6b3bb Compare August 20, 2026 22:02
@copy-pr-bot

copy-pr-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@marta-sd
marta-sd force-pushed the martas/agent-composition-transform branch 2 times, most recently from 4986829 to c382d80 Compare August 21, 2026 16:17
@marta-sd marta-sd linked an issue Aug 21, 2026 that may be closed by this pull request
@marta-sd
marta-sd marked this pull request as ready for review August 21, 2026 21:11
@marta-sd
marta-sd force-pushed the martas/agent-composition-transform branch 2 times, most recently from fb1d0ce to 48dd5c5 Compare August 24, 2026 07:57
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Aug 24, 2026
@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Aug 25, 2026
bxyu-nvidia
bxyu-nvidia previously approved these changes Aug 26, 2026
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Aug 26, 2026
cmunley1
cmunley1 previously approved these changes Aug 26, 2026
Comment thread nemo_gym/global_config.py
self._carry_over_agent_bindings(target.server_config, composed)
# Instance names are kept: `agent_ref` is baked into prepared data, so renaming breaks collection.
agents = global_config_dict[target.name][AGENT_SERVER_TYPE_KEY_NAME]
agents.pop(target.agent_type)

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.

does this silently discard every key outside the three carry-over keys, including CLI overrides, so ++...simple_agent.max_turns=99 still composes to max_turns: 30, inverting the precedence get_global_config_dict's docstring documents?

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.

to fix, this PR needs to apply CLI overrides to the final composed configuration

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.

oh right, this was not intended. good catch, thank you!

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.

It turned out to be a nightmare to handle before re-naming is done, so I added it to #2757 in d1729cf

ananthsub
ananthsub previously approved these changes Aug 27, 2026
Comment thread nemo_gym/global_config.py Outdated
_AgentInstance(
name=str(name),
agent_type=agent_type,
server_config=agents[agent_type],

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.

for a config with an unset inner agent block:

broken:
  responses_api_agents:
    simple_agent: ???

Before this pass, the normal missing-value check raises ConfigMissingValuesError.

_agent_instances() now evaluates agents[agent_type] first, so OmegaConf raises MissingMandatoryValue here instead. The CLI catches ConfigError, not that OmegaConf exception, and exposes a traceback

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 e6f0ea1

Comment thread nemo_gym/global_config.py
def _carry_over_agent_bindings(original: DictConfig, composed: DictConfig) -> None:
"""Move the environment's bindings onto the composed agent config, in place."""
for key in _COMPOSED_AGENT_CARRY_OVER_KEYS:
if key in original:

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.

for a config that leaves its model binding unset:

target:
  responses_api_agents:
    simple_agent:
      model_server: ???

OmegaConf reports a whole-value ??? as absent, so this loop does not carry the missing value into the composed agent.

If the standalone source has model_server: policy_model, parsing silently succeeds with policy_model.

otherwise if the source has no model binding, the target’s model_server field disappears.

we need to distinguish between an absent key from an explicitly missing value

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 fb31d1e

Comment thread nemo_gym/global_config.py Outdated
)

source = sources[0]
targets = [instance for instance in instances if instance.name != source.name]

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.

in this example:

config_paths:
  - benchmarks/nemotron_3.5_super/eval_container_config.yaml
  - responses_api_agents/hermes_agent/configs/hermes_agent.yaml

the config contains ordinary agents with resources servers bound and two self-contained Tau2 agents.

The Tau2 agents intentionally have no resources_server; after they are replaced with Hermes, there is no target binding to copy over, so parsing fails:

ConfigMissingValuesError:
- tau2_banking_knowledge_bm25_grep_artificial_analysis_agent.responses_api_agents.hermes_agent.resources_server.name
- tau2_benchmark_agent.responses_api_agents.hermes_agent.resources_server.name

self-contained agents should be unchanged. only agents with concrete resources server bindings should compose

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 94c43bb

@github-actions github-actions Bot removed the sla:review-overdue Review response is over the one-business-day SLA label Aug 27, 2026
@marta-sd
marta-sd dismissed stale reviews from ananthsub, cmunley1, and bxyu-nvidia via 94c43bb August 27, 2026 12:11
@marta-sd
marta-sd force-pushed the martas/agent-composition-transform branch 2 times, most recently from 0a8fa57 to af4ac6e Compare August 28, 2026 08:16
@marta-sd
marta-sd disabled stacked auto-merge August 28, 2026 12:15
Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
@marta-sd
marta-sd force-pushed the martas/agent-composition-transform branch from af4ac6e to fdbdc14 Compare August 28, 2026 12:15
@marta-sd
marta-sd merged commit c02c6f9 into main Aug 28, 2026
33 checks passed
@marta-sd
marta-sd deleted the martas/agent-composition-transform branch August 28, 2026 12:20
marta-sd added a commit that referenced this pull request Aug 28, 2026
This PR introduces possibility to swap agents in your experiment during
runtime, without a need to create a dedicated config. It builds on top
of #2640 and passes a selected agent's config to the config composition
machinery.

The entire PR stack will introduce the following changes:

1. config composition
2. `--agent-type` flag in the CLI for selecting the agent  (**this PR**)
3. safeguard preventing unsupported env <> agent pairings
4. aligning with dataset changes introduced in epic #1338
5. docs update

---------

Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>

This branch was previously deployed

1 inactive deployment
public — fdbdc14c Deployed Aug 28, 2026 by copy-pr-bot[bot] via release / finalize / notify #2218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to swap agents when constructing global config

6 participants