Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/v1/kv_connector/nixl_integration/toy_proxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ async def send_request_to_service(
req_data["max_completion_tokens"] = 1
if "stream_options" in req_data:
del req_data["stream_options"]
# These args are not supported for P
min_tokens = req_data.pop("min_tokens", None)
min_completion_tokens = req_data.pop("min_completion_tokens", None)
Comment on lines +177 to +178
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.

high

Since req_data is a local copy (created at line 161), popping these keys only affects the request sent to the prefiller (P). The original req_data object in the caller (_handle_completions) remains untouched and will still contain these keys when later sent to the decoder (D). You can simply pop them without assigning to variables to avoid unused variable warnings and unnecessary state tracking.

Suggested change
min_tokens = req_data.pop("min_tokens", None)
min_completion_tokens = req_data.pop("min_completion_tokens", None)
req_data.pop("min_tokens", None)
req_data.pop("min_completion_tokens", None)

headers = {
"Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}",
"X-Request-Id": request_id,
Expand All @@ -187,6 +190,10 @@ async def send_request_to_service(
# otherwise, it would http.ReadError
await response.aread()

# Add back the min_tokens and min_completion_tokens so D can use them
req_data["min_tokens"] = min_tokens
req_data["min_completion_tokens"] = min_completion_tokens

Comment on lines +193 to +196
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.

high

These lines are redundant and potentially problematic.

  1. Redundancy: Modifying the local req_data copy here has no effect on the caller, and the caller's original req_data already contains these values.
  2. Logic Error: If the keys were originally absent, this code explicitly adds them with a value of null (None), which may cause validation issues in the decoder if it expects the keys to be missing rather than present with a null value.

Since the goal is to forward the original parameters to the decoder, the existing copy mechanism at line 161 already ensures this behavior without needing to "add back" anything.

return response


Expand Down
Loading