Repository navigation
fix(stirrup_agent): don't load the agent when importing its helper modules - #4581
Merged
Merged
Conversation
…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]>
marta-sd
approved these changes
Oct 14, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38516445112 |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
responses_api_agents/stirrup_agent/__init__.pynow loads the agent module (app.py) only when one of the agent classes (StirrupAgentWrapper,StirrupAgentWrapperConfig,StirrupRunRequest) is accessed. Before, it importedapp.pyeagerly, so importing any stirrup_agent helper module loaded the whole agent.TaskStrategyis still imported directly, since it's lightweight.Why
gdpval doesn't use Ray, but it imports two stirrup_agent helper modules:
file_reader, inapp.py, to read deliverables duringverify;task_distribution, inmultistage_elo.py.Because the package
__init__.pyimported 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 withNo module named 'ray', and so wouldverifyfor 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.StirrupAgentWrapperstill works.Validation
All of the following ran on #4350's head with this change applied:
resources_servers/gdpval/requirements.txt, thepytest testsrun passes. With the previous__init__.pyin the same venv, the gdpval failures from build(deps): make Ray an optional dependency #4350's CI reproduce.responses_api_agents/stirrup_agent/requirements.txtand itsoverrides.txt, thepytest testsrun passes.responses_api_agents.stirrup_agent.file_readerandresponses_api_agents.stirrup_agent.task_distributionimport cleanly, where they previously failed;from responses_api_agents.stirrup_agent import StirrupAgentWrapper, StirrupRunRequest, TaskStrategystill works.pre-commit runon 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.