Skip to content

Commit acb014a

Browse files
fix(router): forward extra /sleep query params (level, mode) to upstream (#969)
Fixes #953. `route_sleep_wakeup_request` consumed only the router-internal `id` query parameter and dropped everything else, so `POST /sleep?id=X&level=2` silently degraded to `level=1` because vLLM never saw `level=2`. Same defect for `mode` on `/sleep` and `tags` on `/wake_up`. Build a dict of all query params minus `id` and pass it as the aiohttp `params=` argument to each upstream request. `id` is router-only (used above to pick the target engine), so excluding it is correct. Signed-off-by: HumphreySun98 <humphreysun98@gmail.com> Co-authored-by: Rui Zhang <51696593+ruizhang0101@users.noreply.github.com>
1 parent c92350d commit acb014a

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

  • src/vllm_router/services/request_service

src/vllm_router/services/request_service/request.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,11 @@ async def route_general_request(
517517
else:
518518
endpoints = list(
519519
filter(
520-
lambda x: requested_model in x.model_names
521-
and x.Id == request_endpoint
522-
and not x.sleep,
520+
lambda x: (
521+
requested_model in x.model_names
522+
and x.Id == request_endpoint
523+
and not x.sleep
524+
),
523525
endpoints,
524526
)
525527
)
@@ -1064,21 +1066,32 @@ async def route_sleep_wakeup_request(
10641066

10651067
url = server_url + endpoint
10661068

1069+
# Forward any additional query parameters (e.g. /sleep `level` and `mode`,
1070+
# /wake_up `tags`) to the upstream engine. `id` is router-only and is
1071+
# consumed above to pick the target engine.
1072+
upstream_params = {k: v for k, v in request.query_params.items() if k != "id"}
1073+
10671074
async with aiohttp.ClientSession() as client:
10681075
if endpoint == "/is_sleeping":
1069-
async with client.get(url, headers=headers) as response:
1076+
async with client.get(
1077+
url, headers=headers, params=upstream_params
1078+
) as response:
10701079
response.raise_for_status()
10711080
return await response.json()
10721081
else:
10731082
request_body = await request.body()
10741083
response_status = None
10751084
if request_body:
10761085
req_data = json.loads(request_body)
1077-
async with client.post(url, json=req_data, headers=headers) as response:
1086+
async with client.post(
1087+
url, json=req_data, headers=headers, params=upstream_params
1088+
) as response:
10781089
response.raise_for_status()
10791090
response_status = response.status
10801091
else:
1081-
async with client.post(url, headers=headers) as response:
1092+
async with client.post(
1093+
url, headers=headers, params=upstream_params
1094+
) as response:
10821095
response.raise_for_status()
10831096
response_status = response.status
10841097

0 commit comments

Comments
 (0)