Skip to content

fix: restore legacy X-Ray-Serve-Request-Id header for sticky routing#224

Merged
Yunnglin merged 2 commits into
mainfrom
fix/sticky-session-header
Jun 13, 2026
Merged

fix: restore legacy X-Ray-Serve-Request-Id header for sticky routing#224
Yunnglin merged 2 commits into
mainfrom
fix/sticky-session-header

Conversation

@Yunnglin

Copy link
Copy Markdown
Collaborator

Summary

  • Add H_REQUEST_ID_LEGACY = 'X-Ray-Serve-Request-Id' to routing headers
  • ModelScope gateway (www.modelscope.cn/twinkle) requires this legacy header name for sticky session routing; the newer x-request-id (Ray Serve 2.55+) is not forwarded correctly
  • Fixes BadRequestError: Missing X-Ray-Serve-Request-Id header, required for sticky session when connecting tinker client through the gateway

Test plan

  • Verified ServiceClient creates successfully against www.modelscope.cn/twinkle
  • GRPO training cookbook (short_math_grpo.py) runs end-to-end without the 400 error

The ModelScope gateway (www.modelscope.cn/twinkle) requires the
`X-Ray-Serve-Request-Id` header name for sticky session routing.
Commit dff3143 replaced it with `x-request-id`, which Ray Serve 2.55+
reads natively but the gateway does not forward correctly.

Add `H_REQUEST_ID_LEGACY` alongside `H_REQUEST_ID` so both header names
are emitted, fixing `BadRequestError: Missing X-Ray-Serve-Request-Id
header` when connecting through the ModelScope gateway.
Copilot AI review requested due to automatic review settings June 13, 2026 16:13

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

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.

Code Review

This pull request adds a legacy request ID header (X-Ray-Serve-Request-Id) to the client routing headers. The feedback suggests ensuring server-side compatibility by updating ray_serve_patch.py to recognize this legacy header and modifying the gateway proxy to fall back to it if the primary request ID is missing.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/twinkle_client/http/headers.py
Comment thread src/twinkle_client/http/headers.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR restores compatibility with the ModelScope Twinkle gateway’s sticky-session routing by sending Ray Serve’s legacy request-id header name (X-Ray-Serve-Request-Id) alongside the newer x-request-id.

Changes:

  • Add H_REQUEST_ID_LEGACY = 'X-Ray-Serve-Request-Id' header constant.
  • Include the legacy request-id header in _ROUTING_HEADERS so it is emitted by build_routing_headers().

- `gateway/proxy.py`: fallback to `H_REQUEST_ID_LEGACY` when extracting
  request_id from incoming headers, so sticky routing works even if the
  gateway only forwards `X-Ray-Serve-Request-Id`.
- `ray_serve_patch.py`: also match lowercased `x-ray-serve-request-id`
  when populating Ray Serve's request context, mirroring the client-side
  dual-header approach.
@Yunnglin Yunnglin merged commit 27b5aa4 into main Jun 13, 2026
2 of 4 checks passed
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.

3 participants