From 5d52e0d2c5c4550eceeabed5115cf552295819db Mon Sep 17 00:00:00 2001 From: ehhuang Date: Thu, 4 Sep 2025 04:23:18 -0700 Subject: [PATCH] chore: handle missing finish_reason (#3328) # 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]