Skip to content

Conversation

@Ratish1
Copy link
Contributor

@Ratish1 Ratish1 commented Jan 14, 2026

Description

This PR refactors the experimental swe-agent example to make environment setup significantly simpler and fix model reasoning collapse / infinite loops. #423

Key Changes

  • Removed the nemo-gym dependency. The generate function now instantiates DockerEnvironment and DefaultAgent directly from minisweagent, eliminating the need for an external HTTP server and
    reducing setup complexity.
  • Integrated asyncio.to_thread in the rollout process. This allows Miles to run multiple agent tasks in parallel across all allocated GPUs while maintaining Ray cluster responsiveness and heartbeats.
  • Chat Template Fix: Updated the mini-swe-agent model logic to use /v1/chat/completions instead of /generate. Models now correctly apply their internal chat templates

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Ratish1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the experimental SWE-agent integration, aiming to simplify its environment setup and enhance its operational stability. It achieves this by eliminating the nemo-gym dependency, directly integrating mini-swe-agent components, and leveraging asyncio.to_thread for parallel task execution. Additionally, it addresses a critical model reasoning issue by correcting the chat template to use the appropriate API endpoint.

Highlights

  • Dependency Removal: The nemo-gym dependency has been removed, simplifying the environment setup by directly instantiating DockerEnvironment and DefaultAgent from minisweagent.
  • Parallel Task Execution: Integrated asyncio.to_thread into the rollout process, enabling parallel execution of agent tasks across allocated GPUs while maintaining Ray cluster responsiveness.
  • Chat Template Fix: The mini-swe-agent model logic has been updated to correctly use the /v1/chat/completions endpoint instead of /generate, resolving model reasoning collapse and infinite loops.
  • Simplified Setup: The overall environment setup for SWE-agent has been significantly simplified, reducing complexity and the need for an external HTTP server.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly refactors the SWE-agent example, simplifying the environment setup by removing the nemo-gym dependency and the need for a separate agent server. The introduction of asyncio.to_thread to run agent logic in a background thread is a great improvement for Ray cluster stability. The code changes are well-structured and the updated documentation is much clearer. I have a few minor suggestions to improve configurability and dependency management.

cd miles/examples/swe-agent
python download_and_process_data.py --input SWE-Gym/SWE-Gym --output /root/swe_train.jsonl
# Install SWE-Gym harness
pip install "swegym @ git+https://github.com/sdevare-nv/nv-SWE-Bench-Package.git@31e1cb8f0241da1707d00faa633c3d6ce1a8ba3b"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pinning to a specific commit hash is great for reproducibility. However, installing directly from a git URL in a command can be fragile. For better dependency management, consider adding this dependency to a requirements.txt file or managing it as a git submodule, similar to mini-swe-agent.

Comment on lines +77 to +78
step_limit=250,
collapse_limit=3,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The step_limit and collapse_limit for the DefaultAgent are hardcoded. It would be more flexible to make these configurable, for instance by passing them down from the args namespace. This would allow for easier experimentation with different agent behaviors without changing the code.


# Environment configuration
image_name = get_swegym_docker_image_name(sample.metadata, subset)
output_dir = Path("results") / subset / model_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The base output directory 'results' is hardcoded. Consider making this configurable via args to allow users to specify a different location for agent outputs, which can be useful for organizing experiments. For example: Path(args.swe_agent_output_dir).

@Ratish1
Copy link
Contributor Author

Ratish1 commented Jan 21, 2026

Hey @yueming-yuan , I wanted to follow up on this in case you missed it. Thanks.

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.

1 participant