Skip to content

feat: add safeguard for agent - resources server compatibility - #2661

Merged
marta-sd merged 10 commits into
mainfrom
martas/agent-compat-guard
Aug 28, 2026
Merged

marta-sd merged 10 commits into
mainfrom
martas/agent-compat-guard

Conversation

@marta-sd

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

Copy link
Copy Markdown
Contributor

This PR introduces a safeguard preventing users from accidentally swapping agent with an unsupported one.

The entire PR stack will introduce the following changes:

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

@copy-pr-bot

copy-pr-bot Bot commented Aug 21, 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 marked this pull request as ready for review August 21, 2026 21:14
@marta-sd
marta-sd force-pushed the martas/agent-compat-guard branch from 477d167 to d364509 Compare August 21, 2026 21:25
@marta-sd
marta-sd force-pushed the martas/agent-compat-guard branch from d364509 to 8fd8465 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
Comment thread benchmarks/browsecomp/config.yaml Outdated
browsecomp_benchmark_resources_server:
resources_servers:
browsecomp_advanced_harness:
requires_agent: [browsecomp_agent]

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.

Should there be an unallowed_agents list ?

For example, gymnasium_agent wont work with anyswe_agent, afaik

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.

maybe this should also be allowed_agents (plural?)

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.

allowed_agents works 👍 regarding unallowed agents: I think it's redundant, unallowed == everything minus allowed ones (tho the list can get big)

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.

renamed in 1f99426

cmunley1
cmunley1 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 27, 2026
bxyu-nvidia
bxyu-nvidia previously approved these changes Aug 27, 2026
ananthsub
ananthsub previously approved these changes Aug 27, 2026
Comment thread nemo_gym/global_config.py
self, global_config_dict: DictConfig, source: _AgentInstance, targets: List[_AgentInstance]
) -> None:
"""Reject swapping `source` onto any target whose resources server does not declare support for 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.

Consider this routed row and configuration:

source_rs:
  resources_servers:
    source:
      requires_agent: [source_impl]

runtime_agent:
  responses_api_agents:
    other_impl:
      resources_server:
        name: other_rs

agent_map:
  source_rs: runtime_agent

The row starts with task_source: source_rs. Runtime preprocessing changes its destination to runtime_agent, but this compatibility check is not called because no unbound implementation is being composed. Name validation succeeds and /run is dispatched.

The reproduced request sequence was:

live rollout /verify -> other_rs
reverify /verify     -> source_rs

The live agent follows its configured other_rs binding, while reverification treats the row’s task_source as authoritative. agent_map, _default/no-serve routing, and fan_out all bypassed requires_agent; the fan-out case dispatched both the compatible and incompatible agents

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 totally flew under my radar because agent_map wasn't there when I implemented this logic. I added a validation check on the data side in 80e98fc
cc @adil-a

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.

I also had to introduce related changes in #2757 - this is done in b346bfc

Comment thread nemo_gym/global_config.py Outdated
if not isinstance(servers, DictConfig) or len(servers) != 1:
return None
implementation = next(iter(servers))
declared = servers[implementation].get(REQUIRES_AGENT_KEY_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.

for a scalar command-line override instead of a YAML list:

++server.resources_servers.impl.requires_agent=hermes_agent

the configuration model does not declare a type for requires_agent, and composition runs before server-model validation. This code therefore iterates the string and interprets it as:

[h, e, r, m, e, s, _, a, g, e, n, t]

The valid hermes_agent pairing is then rejected

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.

I added support for strings (I think it's very common use-case) and better errors for incorrect inputs in 606ba1f

Comment thread nemo_gym/global_config.py Outdated
f"and accepts {', '.join(required)}"
for target, required in rejected
)
supported = sorted(set.intersection(*(set(required) for _, required in rejected)))

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 these two valid target instances:

target_a:
  requires_agent: [hermes_agent]

target_b:
  requires_agent: [simple_agent]

When Hermes is selected, only target_b is added to rejected. The intersection below therefore contains simple_agent, and the error says:

Select one of: simple_agent.

Selecting simple_agent does not solve the configuration; target_a then rejects it.

should we get the recommendation from every restrictive target, not just the targets that reject the current selection?

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.

yes, you're right. fixed in ae94ce8

@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, bxyu-nvidia, and cmunley1 August 27, 2026 13:01

The merge-base changed after approval.

@marta-sd
marta-sd force-pushed the martas/agent-compat-guard branch from 8fd8465 to ae94ce8 Compare August 28, 2026 08:16
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]>
Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
…lout collection

Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
@marta-sd
marta-sd force-pushed the martas/agent-compat-guard branch from 9e0026b to 9170da1 Compare August 28, 2026 12:46
@marta-sd
marta-sd merged commit 0b0f25e into main Aug 28, 2026
32 checks passed
@marta-sd
marta-sd deleted the martas/agent-compat-guard branch August 28, 2026 12:54
marta-sd added a commit that referenced this pull request Sep 2, 2026
While working on #2661 Several configs that require `allowed_agents` to
be specified were added later on. This PR updates them as well as agent
configs associated with them.

---------

Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
jkyi-nvidia pushed a commit that referenced this pull request Sep 11, 2026
While working on #2661 Several configs that require `allowed_agents` to
be specified were added later on. This PR updates them as well as agent
configs associated with them.

---------

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

This branch was previously deployed

1 inactive deployment
public — 9170da1a Deployed Aug 28, 2026 by copy-pr-bot[bot] via release / finalize / notify #2228
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.

Add safeguards preventing unsupported agent <> resources server paring

5 participants