From 6542d48964be70dad281ce5e2675e287d394938f Mon Sep 17 00:00:00 2001 From: XuZhou <17717803682@163.com> Date: Fri, 5 Jun 2026 15:36:20 +0800 Subject: [PATCH] [Bugfix] Fix test_invocations flaky failure with newer openai SDK (#44618) Signed-off-by: Xu Zhou Co-authored-by: Xu Zhou --- tests/entrypoints/openai/chat_completion/test_chat.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/entrypoints/openai/chat_completion/test_chat.py b/tests/entrypoints/openai/chat_completion/test_chat.py index 6703095aec..16a3cd857c 100644 --- a/tests/entrypoints/openai/chat_completion/test_chat.py +++ b/tests/entrypoints/openai/chat_completion/test_chat.py @@ -808,14 +808,20 @@ async def test_invocations(server: RemoteOpenAIServer, client: openai.AsyncOpenA "logprobs": False, } - chat_completion = await client.chat.completions.create(**request_args) + # Use raw HTTP for both endpoints so we compare server responses + # directly, without the openai SDK injecting extra fields + # (e.g. `moderation` added in newer SDK versions). + chat_response = requests.post( + server.url_for("v1/chat/completions"), json=request_args + ) + chat_response.raise_for_status() invocation_response = requests.post( server.url_for("invocations"), json=request_args ) invocation_response.raise_for_status() - chat_output = chat_completion.model_dump() + chat_output = chat_response.json() invocation_output = invocation_response.json() assert chat_output.keys() == invocation_output.keys()