[Responses] Fix empty-prompt routing for token-first chat encoders (kimi_k3, inkling) (#35486)

Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
Co-authored-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
hhy-seven
2026-09-11 01:06:20 +00:00
committed by GitHub
co-authored by Xinyuan Tong Xinyuan Tong
parent 9df72e8f5a
commit ad7f57c9ea
4 changed files with 62 additions and 26 deletions
@@ -622,6 +622,36 @@ class MultimodalRequestTestCase(CustomTestCase):
)
self.assertEqual(captured["adapted_request"].modalities, ["image"])
def test_multimodal_token_first_specs_route_through_prompt_ids(self):
"""Bug regression: token-first encoders leave prompt == "" with
non-empty prompt_ids; forwarding the empty text 400s in
_tokenize_texts, so the multimodal branch must forward prompt_ids."""
for spec in ("inkling", "kimi_k3"):
with self.subTest(spec=spec):
serving = make_serving(is_multimodal=True)
serving.chat_encoding_spec = spec
serving._process_messages = Mock(
return_value=MessageProcessingResult(
prompt="",
prompt_ids=[4, 5, 6],
image_data=None,
audio_data=None,
video_data=None,
modalities=[],
stop=[],
)
)
request = ResponsesRequest(model="x", input="hi", store=False)
_, request_prompts, engine_prompts, _ = asyncio.run(
serving._make_request(
request, None, serving.tokenizer_manager.tokenizer
)
)
self.assertEqual(engine_prompts, [[4, 5, 6]])
self.assertEqual(request_prompts, [[4, 5, 6]])
class OutputItemsTestCase(CustomTestCase):
def setUp(self):