Skip to content

fix(stirrup_agent): don't load the agent when importing its helper modules - #4581

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/stirrup-lazy-package-import
Oct 14, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/stirrup-lazy-package-import

Conversation

@ananthsub

Copy link
Copy Markdown
Contributor

What changed

responses_api_agents/stirrup_agent/__init__.py now loads the agent module (app.py) only when one of the agent classes (StirrupAgentWrapper, StirrupAgentWrapperConfig, StirrupRunRequest) is accessed. Before, it imported app.py eagerly, so importing any stirrup_agent helper module loaded the whole agent. TaskStrategy is still imported directly, since it's lightweight.

Why

gdpval doesn't use Ray, but it imports two stirrup_agent helper modules:

  • file_reader, in app.py, to read deliverables during verify;
  • task_distribution, in multistage_elo.py.

Because the package __init__.py imported the agent, and the agent imports Ray at module level, those imports needed Ray. Every server venv used to have Ray, so this went unnoticed. With #4350, which makes Ray an optional dependency, gdpval's venv no longer has Ray. gdpval's tests then fail with No module named 'ray', and so would verify for any task with a deliverables directory. This unblocks #4350.

Nothing in the repository imports the agent classes through the package; callers import submodules directly. Accessing responses_api_agents.stirrup_agent.StirrupAgentWrapper still works.

Validation

All of the following ran on #4350's head with this change applied:

  • gdpval's tests, without Ray: in a venv built from resources_servers/gdpval/requirements.txt, the pytest tests run passes. With the previous __init__.py in the same venv, the gdpval failures from build(deps): make Ray an optional dependency #4350's CI reproduce.
  • stirrup_agent's tests, with Ray: in a venv built from responses_api_agents/stirrup_agent/requirements.txt and its overrides.txt, the pytest tests run passes.
  • Imports in an environment without Ray:
    • responses_api_agents.stirrup_agent.file_reader and responses_api_agents.stirrup_agent.task_distribution import cleanly, where they previously failed;
    • with Ray installed, from responses_api_agents.stirrup_agent import StirrupAgentWrapper, StirrupRunRequest, TaskStrategy still works.
  • pre-commit run on the changed file.

Rollout evidence

N/A. This only changes when the agent module is imported. The agent's behavior, prompts, trajectories, verification and rewards are unchanged.

Compatibility

None. Package-level access to the agent classes behaves as before. The agent module now loads on first access instead of at package import.

…dules

The package __init__ imported the agent (app.py), which imports Ray at
module level. gdpval imports stirrup_agent helper modules such as
file_reader and task_distribution, so it failed with "No module named
'ray'" once Ray became an optional dependency, even though gdpval
doesn't use Ray.

Load the agent classes lazily from the package instead. Importing a
helper module no longer needs Ray, and the agent classes are still
available through the package.

Signed-off-by: Ananth Subramaniam <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 14, 2026 00:02
@ananthsub
ananthsub requested a review from marta-sd October 14, 2026 00:03
@yaoyu-33 yaoyu-33 added area:agent Agent harnesses and Responses API agent behavior bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer labels Oct 14, 2026
@ananthsub
ananthsub added this pull request to the merge queue Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38516445112

Merged via the queue into main with commit 3d2e970 Oct 14, 2026
49 checks passed
@ananthsub
ananthsub deleted the ananthsub/stirrup-lazy-package-import branch October 14, 2026 05:42

This branch was previously deployed

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

Labels

area:agent Agent harnesses and Responses API agent behavior bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants