From 5d52e0d2c5c4550eceeabed5115cf552295819db Mon Sep 17 00:00:00 2001 From: ehhuang Date: Thu, 4 Sep 2025 04:23:18 -0700 Subject: [PATCH 1/3] 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] From 64d2306dd5481be3fdfaa11c415efe3f2788358e Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Thu, 4 Sep 2025 16:56:32 +0100 Subject: [PATCH 2/3] fix: distro-codegen pre-commit hook file pattern (#3337) Update the file pattern from 'llama_stack/templates' to 'llama_stack/distributions' to properly trigger the Distribution Template Codegen hook when distribution files change. Signed-off-by: Derek Higgins --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 514fe6d2e..b7880a9fc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -86,7 +86,7 @@ repos: language: python pass_filenames: false require_serial: true - files: ^llama_stack/templates/.*$|^llama_stack/providers/.*/inference/.*/models\.py$ + files: ^llama_stack/distributions/.*$|^llama_stack/providers/.*/inference/.*/models\.py$ - id: provider-codegen name: Provider Codegen additional_dependencies: From 85f33762d7cb7495b9aa5946284e4b6c85f5ad96 Mon Sep 17 00:00:00 2001 From: IAN MILLER <75687988+r3v5@users.noreply.github.com> Date: Thu, 4 Sep 2025 17:15:13 +0100 Subject: [PATCH 3/3] refactor(server): remove hardcoded 409 and 404 status codes in server.py using httpx constants (#3333) # What does this PR do? This PR is eliminating hardcoded status codes: `409` CONFLICT and `404` NOT_FOUND in `server.py` using `httpx` built-in constants. This implementation will follow the existing structure to improve readability, extensibility and developer experience. This is already was implemented in #3131 ## Test Plan `./scripts/unit-tests.sh` --- llama_stack/core/server/server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llama_stack/core/server/server.py b/llama_stack/core/server/server.py index d6dfc3435..b247a610d 100644 --- a/llama_stack/core/server/server.py +++ b/llama_stack/core/server/server.py @@ -132,9 +132,9 @@ def translate_exception(exc: Exception) -> HTTPException | RequestValidationErro }, ) elif isinstance(exc, ConflictError): - return HTTPException(status_code=409, detail=str(exc)) + return HTTPException(status_code=httpx.codes.CONFLICT, detail=str(exc)) elif isinstance(exc, ResourceNotFoundError): - return HTTPException(status_code=404, detail=str(exc)) + return HTTPException(status_code=httpx.codes.NOT_FOUND, detail=str(exc)) elif isinstance(exc, ValueError): return HTTPException(status_code=httpx.codes.BAD_REQUEST, detail=f"Invalid value: {str(exc)}") elif isinstance(exc, BadRequestError):