Skip to content

Commit 1e62870

Browse files
committed
refactor(agent-registry): address review — drop dead query path, fix tests, clarify gymnasium
Review follow-up: - Remove the unreachable query filter from gym list agents (cli/agents.py): no QUERY flag is registered for the command, so the branch could never run; drop it (and _fuzzy_matches and the mock-only test_query_filters that masked it). search stays benchmarks-only. - test_agent_entry_is_hashable: replace the trivially-true `... or True` assertion with a real check on AgentEntry.variants. - Docstring: stop citing gymnasium as a Pattern A (composable) example — gymnasium-style agents ship their own env and classify as self-contained (Pattern B), matching cmunley1s review point. Signed-off-by: Wojciech Prazuch <wprazuch@nvidia.com>
1 parent 666edf9 commit 1e62870

4 files changed

Lines changed: 7 additions & 29 deletions

File tree

nemo_gym/agent_registry.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
2323
- **References a separate resources server (Pattern A):** the config sets
2424
``responses_api_agents.<type>.resources_server``, so the harness is reusable and must be wired to a
25-
*compatible* resources server + dataset (e.g. the ``simple_agent`` tool-use pattern, the
26-
``gymnasium`` pattern). Harnesses compose *within* a pattern, not across it; which
27-
harness↔resources-server pairings are actually compatible is decided by the config composer's
28-
compatibility guard, NOT by this registry.
25+
*compatible* resources server + dataset (e.g. the ``simple_agent`` tool-use pattern). Harnesses
26+
compose *within* a pattern, not across it; which harness↔resources-server pairings are actually
27+
compatible is decided by the config composer's compatibility guard, NOT by this registry.
2928
- **Self-contained (Pattern B):** the harness bundles its own environment/framework or external LLM
3029
loop (``agent_framework``; e.g. ``swe_agents``, ``harbor_agent``, ``verifiers_agent``,
31-
``claude_code_agent``) and runs with its own config rather than wired to a separate environment.
30+
``claude_code_agent``, and ``gymnasium``-style agents that ship their own env) and runs with its
31+
own config rather than wired to a separate environment.
3232
3333
Discovery only reads config files; it never resolves interpolations or missing values and never
3434
starts servers, so it is safe to call when secrets/API keys referenced by a config are unset.

nemo_gym/cli/agents.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@
2121
from nemo_gym.config_types import BaseNeMoGymCLIConfig
2222
from nemo_gym.global_config import (
2323
JSON_OUTPUT_KEY_NAME,
24-
QUERY_KEY_NAME,
2524
GlobalConfigDictParserConfig,
2625
get_global_config_dict,
2726
)
2827

2928

30-
def _fuzzy_matches(query: str, *fields: str) -> bool:
31-
needle = query.lower()
32-
return any(needle in (field or "").lower() for field in fields)
33-
34-
3529
def list_agents() -> None:
3630
"""CLI command: list discovered agent harnesses and how each composes (Pattern A vs B).
3731
@@ -49,12 +43,6 @@ def list_agents() -> None:
4943

5044
agents = discover_agents()
5145

52-
query = global_config_dict.get(QUERY_KEY_NAME)
53-
if query:
54-
agents = {
55-
name: entry for name, entry in agents.items() if _fuzzy_matches(query, name, entry.description or "")
56-
}
57-
5846
if global_config_dict.get(JSON_OUTPUT_KEY_NAME, False):
5947
payload = [
6048
{
@@ -70,7 +58,7 @@ def list_agents() -> None:
7058
return
7159

7260
if not agents:
73-
rich.print("No agents found." if not query else f"No agents match {query!r}.")
61+
rich.print("No agents found.")
7462
return
7563

7664
table = Table(title="NeMo Gym agents")

tests/unit_tests/test_agent_registry.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from pytest import raises
1818

1919
from nemo_gym.agent_registry import (
20-
AGENTS_DIR,
2120
AgentEntry,
2221
AgentNotComposableError,
2322
AgentNotFoundError,
@@ -223,4 +222,4 @@ def test_discovers_real_simple_agent_as_composable(self) -> None:
223222
def test_agent_entry_is_hashable(self) -> None:
224223
entry = AgentEntry(name="a", path=Path("a"), config_paths=(Path("a/configs/a.yaml"),), self_contained=True)
225224
assert {entry: 1}[entry] == 1
226-
assert entry.path == AGENTS_DIR / "a" or True # AGENTS_DIR import exercised
225+
assert entry.variants == {"a": Path("a/configs/a.yaml")}

tests/unit_tests/test_cli_agents.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,3 @@ def test_json_output(self, capsys) -> None:
7575
assert by_name["simple_agent"]["pattern"] == "A (composable)"
7676
assert by_name["swe_agents"]["self_contained"] is True
7777
assert by_name["swe_agents"]["variants"] == ["swebench_openhands"]
78-
79-
def test_query_filters(self, capsys) -> None:
80-
with (
81-
patch("nemo_gym.cli.agents.get_global_config_dict", return_value=_mock_global_config({"query": "swe"})),
82-
patch("nemo_gym.cli.agents.discover_agents", return_value=_AGENTS),
83-
):
84-
list_agents()
85-
out = capsys.readouterr().out
86-
assert "swe_agents" in out and "simple_agent" not in out

0 commit comments

Comments
 (0)