From 10d34f74e2460013f11b158499f4675a475fc35e Mon Sep 17 00:00:00 2001 From: gongwei-130 <56567052+gongwei-130@users.noreply.github.com> Date: Thu, 21 Aug 2025 14:06:50 -0700 Subject: [PATCH] fix: should return a invalid request response when schema missing (#9461) --- python/sglang/srt/entrypoints/openai/serving_chat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/sglang/srt/entrypoints/openai/serving_chat.py b/python/sglang/srt/entrypoints/openai/serving_chat.py index 042911f63..6179ab5c4 100644 --- a/python/sglang/srt/entrypoints/openai/serving_chat.py +++ b/python/sglang/srt/entrypoints/openai/serving_chat.py @@ -81,6 +81,11 @@ class OpenAIServingChat(OpenAIServingBase): f"This model supports at most {server_context_length} completion tokens." ) + if request.response_format and request.response_format.type == "json_schema": + schema = getattr(request.response_format.json_schema, "schema_", None) + if schema is None: + return "schema_ is required for json_schema response format request." + return None def _convert_to_internal_request(