From 6405cf288103304f399074ede8529af37cfdd51c Mon Sep 17 00:00:00 2001 From: Ke Bao Date: Mon, 28 Sep 2026 15:17:09 +0800 Subject: [PATCH] Fix chat template cache key order (#41517) --- python/sglang/srt/entrypoints/openai/serving_chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/sglang/srt/entrypoints/openai/serving_chat.py b/python/sglang/srt/entrypoints/openai/serving_chat.py index d5e6bf5f3e..cd1ba3c8d3 100644 --- a/python/sglang/srt/entrypoints/openai/serving_chat.py +++ b/python/sglang/srt/entrypoints/openai/serving_chat.py @@ -1748,6 +1748,7 @@ class OpenAIServingChat(OpenAIServingBase): cache_key = None if use_cache: try: + # Key order is part of the key: templates render dicts in their given order. cache_key = orjson.dumps( ( getattr( @@ -1760,7 +1761,6 @@ class OpenAIServingChat(OpenAIServingBase): template_kwargs, encode_kwargs, ), - option=orjson.OPT_SORT_KEYS, ) except TypeError: pass