From df873b8b27071be3e6dc166726ae77a8c37f5cfb Mon Sep 17 00:00:00 2001 From: Eric Huang Date: Wed, 3 Sep 2025 21:54:45 -0700 Subject: [PATCH] chore: handle missing finish_reason # What does this PR do? Sometimes the stream don't have chunks with finish_reason, e.g. canceled stream, which throws a pydantic error as OpenAIChoice.finish_reason: str ## Test Plan observe no more such error when benchmarking --- llama_stack/core/routers/inference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama_stack/core/routers/inference.py b/llama_stack/core/routers/inference.py index 4b66601bb..8dcad85e3 100644 --- a/llama_stack/core/routers/inference.py +++ b/llama_stack/core/routers/inference.py @@ -755,7 +755,7 @@ class InferenceRouter(Inference): choices_data[idx] = { "content_parts": [], "tool_calls_builder": {}, - "finish_reason": None, + "finish_reason": "stop", "logprobs_content_parts": [], } current_choice_data = choices_data[idx]