Skip to content

Minor fixes in swe-agent-v2/run.py#933

Open
Shi-Dong wants to merge 3 commits intomainfrom
fix/swe-agent-v2-run-py-env
Open

Minor fixes in swe-agent-v2/run.py#933
Shi-Dong wants to merge 3 commits intomainfrom
fix/swe-agent-v2-run-py-env

Conversation

@Shi-Dong
Copy link
Copy Markdown
Contributor

@Shi-Dong Shi-Dong commented Apr 7, 2026

Make MILES_HOST_IP default to MASTER_ADDR when the latter is set. In a multi-node environment, this ensures that the workers can resolve the correct address of the head node.

…cate session port

Prefer MILES_HOST_IP, then MASTER_ADDR when set, then hostname so multi-node
Ray workers can resolve the Miles router address. Remove redundant
--session-server-port from sglang args (kept with --use-session-server).
Copy link
Copy Markdown
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 updates the initialization of miles_host_ip in examples/experimental/swe-agent-v2/run.py to prioritize MILES_HOST_IP, then MASTER_ADDR, and finally the system hostname to prevent unresolvable pod hostnames. A review comment suggests improving the robustness of this logic by consistently stripping whitespace from both environment variables and simplifying the expression.

Comment on lines +52 to +56
miles_host_ip: str = (
os.environ.get("MILES_HOST_IP")
or (os.environ.get("MASTER_ADDR") or "").strip()
or socket.gethostname()
)
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.

medium

The logic for determining miles_host_ip can be simplified and made more robust. Currently, it doesn't handle potential whitespace in the MILES_HOST_IP environment variable, and the nested or with strip() for MASTER_ADDR is slightly redundant. Using os.environ.get(key, "").strip() is a cleaner and more idiomatic way to handle missing or whitespace-only environment variables in Python.

Suggested change
miles_host_ip: str = (
os.environ.get("MILES_HOST_IP")
or (os.environ.get("MASTER_ADDR") or "").strip()
or socket.gethostname()
)
miles_host_ip: str = (
os.environ.get("MILES_HOST_IP", "").strip()
or os.environ.get("MASTER_ADDR", "").strip()
or socket.gethostname()
)

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.

2 participants