From 941e3b59d4ced3a413bce159d5783910510e8bd8 Mon Sep 17 00:00:00 2001 From: Charlie Doern Date: Wed, 1 Apr 2026 12:52:09 -0400 Subject: [PATCH 1/3] fix: move reasoning wrapper types to llama-stack-api and fix mypy errors PR #5206 merged with `openai_chat_completions_with_reasoning` returning `-> object` which hid type errors. The wrapper types OpenAIChatCompletionWithReasoning and OpenAIChatCompletionChunkWithReasoning were incorrectly placed in providers/inline/responses/builtin/responses/types.py instead of being in llama-stack-api where API types belong. This change: - Moves the wrapper types to src/llama_stack_api/inference/models.py - Converts them from @dataclass to BaseModel with Field() descriptors to match the rest of the API model definitions - Updates all imports across providers (bedrock, ollama, vllm) and routers - Adds explicit type annotation for completion_result variable that can hold either regular or reasoning-aware completion types - Fixes mypy errors that were previously hidden by the `-> object` return type Signed-off-by: Charlie Doern --- client-sdks/stainless/openapi.yml | 38 +++++++++++++++++++ docs/static/deprecated-llama-stack-spec.yaml | 38 +++++++++++++++++++ .../static/experimental-llama-stack-spec.yaml | 38 +++++++++++++++++++ docs/static/llama-stack-spec.yaml | 38 +++++++++++++++++++ docs/static/stainless-llama-stack-spec.yaml | 38 +++++++++++++++++++ src/llama_stack/core/routers/inference.py | 6 +-- .../responses/builtin/responses/streaming.py | 9 ++++- .../responses/builtin/responses/types.py | 26 ------------- .../remote/inference/bedrock/bedrock.py | 4 +- .../remote/inference/ollama/ollama.py | 4 +- .../providers/remote/inference/vllm/vllm.py | 4 +- src/llama_stack_api/__init__.py | 4 ++ src/llama_stack_api/inference/__init__.py | 4 ++ src/llama_stack_api/inference/api.py | 4 +- src/llama_stack_api/inference/models.py | 30 +++++++++++++++ 15 files changed, 247 insertions(+), 38 deletions(-) diff --git a/client-sdks/stainless/openapi.yml b/client-sdks/stainless/openapi.yml index 803097906a5..3a57ccc16c1 100644 --- a/client-sdks/stainless/openapi.yml +++ b/client-sdks/stainless/openapi.yml @@ -14122,6 +14122,44 @@ components: required: - completion_id title: GetChatCompletionRequest + OpenAIChatCompletionWithReasoning: + description: |- + Internal wrapper: a CC response with extracted reasoning content. + + Returned by openai_chat_completions_with_reasoning for non-streaming. + The Responses layer unwraps .completion and reads .reasoning_content. + properties: + completion: + $ref: '#/components/schemas/OpenAIChatCompletion' + description: The chat completion response. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - completion + title: OpenAIChatCompletionWithReasoning + OpenAIChatCompletionChunkWithReasoning: + description: |- + Internal wrapper: a CC streaming chunk with extracted reasoning content. + + Yielded by openai_chat_completions_with_reasoning for streaming. + The Responses layer unwraps .chunk and reads .reasoning_content. + properties: + chunk: + $ref: '#/components/schemas/OpenAIChatCompletionChunk' + description: The chat completion chunk. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - chunk + title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/docs/static/deprecated-llama-stack-spec.yaml b/docs/static/deprecated-llama-stack-spec.yaml index 633c76bd0dc..3d1f11f2852 100644 --- a/docs/static/deprecated-llama-stack-spec.yaml +++ b/docs/static/deprecated-llama-stack-spec.yaml @@ -10480,6 +10480,44 @@ components: required: - completion_id title: GetChatCompletionRequest + OpenAIChatCompletionWithReasoning: + description: |- + Internal wrapper: a CC response with extracted reasoning content. + + Returned by openai_chat_completions_with_reasoning for non-streaming. + The Responses layer unwraps .completion and reads .reasoning_content. + properties: + completion: + $ref: '#/components/schemas/OpenAIChatCompletion' + description: The chat completion response. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - completion + title: OpenAIChatCompletionWithReasoning + OpenAIChatCompletionChunkWithReasoning: + description: |- + Internal wrapper: a CC streaming chunk with extracted reasoning content. + + Yielded by openai_chat_completions_with_reasoning for streaming. + The Responses layer unwraps .chunk and reads .reasoning_content. + properties: + chunk: + $ref: '#/components/schemas/OpenAIChatCompletionChunk' + description: The chat completion chunk. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - chunk + title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/docs/static/experimental-llama-stack-spec.yaml b/docs/static/experimental-llama-stack-spec.yaml index 08fcd484f66..650156aad8a 100644 --- a/docs/static/experimental-llama-stack-spec.yaml +++ b/docs/static/experimental-llama-stack-spec.yaml @@ -10685,6 +10685,44 @@ components: required: - completion_id title: GetChatCompletionRequest + OpenAIChatCompletionWithReasoning: + description: |- + Internal wrapper: a CC response with extracted reasoning content. + + Returned by openai_chat_completions_with_reasoning for non-streaming. + The Responses layer unwraps .completion and reads .reasoning_content. + properties: + completion: + $ref: '#/components/schemas/OpenAIChatCompletion' + description: The chat completion response. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - completion + title: OpenAIChatCompletionWithReasoning + OpenAIChatCompletionChunkWithReasoning: + description: |- + Internal wrapper: a CC streaming chunk with extracted reasoning content. + + Yielded by openai_chat_completions_with_reasoning for streaming. + The Responses layer unwraps .chunk and reads .reasoning_content. + properties: + chunk: + $ref: '#/components/schemas/OpenAIChatCompletionChunk' + description: The chat completion chunk. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - chunk + title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/docs/static/llama-stack-spec.yaml b/docs/static/llama-stack-spec.yaml index 92d0d22b46b..216429ed72d 100644 --- a/docs/static/llama-stack-spec.yaml +++ b/docs/static/llama-stack-spec.yaml @@ -13047,6 +13047,44 @@ components: required: - completion_id title: GetChatCompletionRequest + OpenAIChatCompletionWithReasoning: + description: |- + Internal wrapper: a CC response with extracted reasoning content. + + Returned by openai_chat_completions_with_reasoning for non-streaming. + The Responses layer unwraps .completion and reads .reasoning_content. + properties: + completion: + $ref: '#/components/schemas/OpenAIChatCompletion' + description: The chat completion response. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - completion + title: OpenAIChatCompletionWithReasoning + OpenAIChatCompletionChunkWithReasoning: + description: |- + Internal wrapper: a CC streaming chunk with extracted reasoning content. + + Yielded by openai_chat_completions_with_reasoning for streaming. + The Responses layer unwraps .chunk and reads .reasoning_content. + properties: + chunk: + $ref: '#/components/schemas/OpenAIChatCompletionChunk' + description: The chat completion chunk. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - chunk + title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/docs/static/stainless-llama-stack-spec.yaml b/docs/static/stainless-llama-stack-spec.yaml index 803097906a5..3a57ccc16c1 100644 --- a/docs/static/stainless-llama-stack-spec.yaml +++ b/docs/static/stainless-llama-stack-spec.yaml @@ -14122,6 +14122,44 @@ components: required: - completion_id title: GetChatCompletionRequest + OpenAIChatCompletionWithReasoning: + description: |- + Internal wrapper: a CC response with extracted reasoning content. + + Returned by openai_chat_completions_with_reasoning for non-streaming. + The Responses layer unwraps .completion and reads .reasoning_content. + properties: + completion: + $ref: '#/components/schemas/OpenAIChatCompletion' + description: The chat completion response. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - completion + title: OpenAIChatCompletionWithReasoning + OpenAIChatCompletionChunkWithReasoning: + description: |- + Internal wrapper: a CC streaming chunk with extracted reasoning content. + + Yielded by openai_chat_completions_with_reasoning for streaming. + The Responses layer unwraps .chunk and reads .reasoning_content. + properties: + chunk: + $ref: '#/components/schemas/OpenAIChatCompletionChunk' + description: The chat completion chunk. + reasoning_content: + anyOf: + - type: string + - type: 'null' + description: Extracted reasoning content, if any. + nullable: true + required: + - chunk + title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/src/llama_stack/core/routers/inference.py b/src/llama_stack/core/routers/inference.py index c6afebf41ba..4259c558bed 100644 --- a/src/llama_stack/core/routers/inference.py +++ b/src/llama_stack/core/routers/inference.py @@ -18,10 +18,6 @@ from llama_stack.core.datatypes import ModelWithOwner from llama_stack.core.request_headers import get_authenticated_user from llama_stack.log import get_logger -from llama_stack.providers.inline.responses.builtin.responses.types import ( - OpenAIChatCompletionChunkWithReasoning, - OpenAIChatCompletionWithReasoning, -) from llama_stack.providers.utils.inference.inference_store import InferenceStore from llama_stack.telemetry.inference_metrics import ( create_inference_metric_attributes, @@ -41,10 +37,12 @@ ModelTypeError, OpenAIChatCompletion, OpenAIChatCompletionChunk, + OpenAIChatCompletionChunkWithReasoning, OpenAIChatCompletionRequestWithExtraBody, OpenAIChatCompletionResponseMessage, OpenAIChatCompletionToolCall, OpenAIChatCompletionToolCallFunction, + OpenAIChatCompletionWithReasoning, OpenAIChoice, OpenAIChoiceLogprobs, OpenAICompletion, diff --git a/src/llama_stack/providers/inline/responses/builtin/responses/streaming.py b/src/llama_stack/providers/inline/responses/builtin/responses/streaming.py index 9a599ade205..e2c80d5f746 100644 --- a/src/llama_stack/providers/inline/responses/builtin/responses/streaming.py +++ b/src/llama_stack/providers/inline/responses/builtin/responses/streaming.py @@ -28,6 +28,7 @@ OpenAIAssistantMessageParam, OpenAIChatCompletion, OpenAIChatCompletionChunk, + OpenAIChatCompletionChunkWithReasoning, OpenAIChatCompletionCustomToolCall, OpenAIChatCompletionRequestWithExtraBody, OpenAIChatCompletionResponseMessage, @@ -36,6 +37,7 @@ OpenAIChatCompletionToolChoiceAllowedTools, OpenAIChatCompletionToolChoiceCustomTool, OpenAIChatCompletionToolChoiceFunctionTool, + OpenAIChatCompletionWithReasoning, OpenAIChoice, OpenAIChoiceLogprobs, OpenAIFinishReason, @@ -108,7 +110,6 @@ AssistantMessageWithReasoning, ChatCompletionContext, ChatCompletionResult, - OpenAIChatCompletionChunkWithReasoning, ) from .utils import ( convert_chat_choice_to_response_message, @@ -543,6 +544,12 @@ async def create_response(self) -> AsyncIterator[OpenAIResponseObjectStream]: **(self.extra_body or {}), ) # Use reasoning-aware method when reasoning is explicitly requested + completion_result: ( + OpenAIChatCompletion + | AsyncIterator[OpenAIChatCompletionChunk] + | OpenAIChatCompletionWithReasoning + | AsyncIterator[OpenAIChatCompletionChunkWithReasoning] + ) if self.reasoning and self.reasoning.effort and self.reasoning.effort != "none": try: # Pass a copy — the router mutates params.model (strips provider prefix). diff --git a/src/llama_stack/providers/inline/responses/builtin/responses/types.py b/src/llama_stack/providers/inline/responses/builtin/responses/types.py index 4b4e7fc00b2..3eb563d8c65 100644 --- a/src/llama_stack/providers/inline/responses/builtin/responses/types.py +++ b/src/llama_stack/providers/inline/responses/builtin/responses/types.py @@ -13,8 +13,6 @@ from llama_stack_api import ( OpenAIAssistantMessageParam, - OpenAIChatCompletion, - OpenAIChatCompletionChunk, OpenAIChatCompletionToolCall, OpenAIFinishReason, OpenAIMessageParam, @@ -50,30 +48,6 @@ class AssistantMessageWithReasoning(OpenAIAssistantMessageParam): reasoning_content: str | None = None -@dataclass -class OpenAIChatCompletionWithReasoning: - """Internal wrapper: a CC response with extracted reasoning content. - - Returned by openai_chat_completions_with_reasoning for non-streaming. - The Responses layer unwraps .completion and reads .reasoning_content. - """ - - completion: OpenAIChatCompletion - reasoning_content: str | None = None - - -@dataclass -class OpenAIChatCompletionChunkWithReasoning: - """Internal wrapper: a CC streaming chunk with extracted reasoning content. - - Yielded by openai_chat_completions_with_reasoning for streaming. - The Responses layer unwraps .chunk and reads .reasoning_content. - """ - - chunk: OpenAIChatCompletionChunk - reasoning_content: str | None = None - - def _json_equal(a: str, b: str) -> bool: """Compare two JSON strings by value, falling back to string comparison.""" try: diff --git a/src/llama_stack/providers/remote/inference/bedrock/bedrock.py b/src/llama_stack/providers/remote/inference/bedrock/bedrock.py index 300ef9dd0ef..02800d21ed2 100644 --- a/src/llama_stack/providers/remote/inference/bedrock/bedrock.py +++ b/src/llama_stack/providers/remote/inference/bedrock/bedrock.py @@ -11,14 +11,14 @@ from llama_stack.log import get_logger from llama_stack.providers.inline.responses.builtin.responses.types import ( AssistantMessageWithReasoning, - OpenAIChatCompletionChunkWithReasoning, - OpenAIChatCompletionWithReasoning, ) from llama_stack.providers.utils.inference.openai_mixin import OpenAIMixin from llama_stack_api import ( OpenAIChatCompletion, OpenAIChatCompletionChunk, + OpenAIChatCompletionChunkWithReasoning, OpenAIChatCompletionRequestWithExtraBody, + OpenAIChatCompletionWithReasoning, OpenAICompletion, OpenAICompletionRequestWithExtraBody, OpenAIEmbeddingsRequestWithExtraBody, diff --git a/src/llama_stack/providers/remote/inference/ollama/ollama.py b/src/llama_stack/providers/remote/inference/ollama/ollama.py index 6f95a621c7e..45b41f7b3e0 100644 --- a/src/llama_stack/providers/remote/inference/ollama/ollama.py +++ b/src/llama_stack/providers/remote/inference/ollama/ollama.py @@ -13,8 +13,6 @@ from llama_stack.log import get_logger from llama_stack.providers.inline.responses.builtin.responses.types import ( AssistantMessageWithReasoning, - OpenAIChatCompletionChunkWithReasoning, - OpenAIChatCompletionWithReasoning, ) from llama_stack.providers.remote.inference.ollama.config import OllamaImplConfig from llama_stack.providers.utils.inference.openai_mixin import OpenAIMixin @@ -22,7 +20,9 @@ HealthResponse, HealthStatus, Model, + OpenAIChatCompletionChunkWithReasoning, OpenAIChatCompletionRequestWithExtraBody, + OpenAIChatCompletionWithReasoning, UnsupportedModelError, ) diff --git a/src/llama_stack/providers/remote/inference/vllm/vllm.py b/src/llama_stack/providers/remote/inference/vllm/vllm.py index 6c491fc8236..045dfb83b36 100644 --- a/src/llama_stack/providers/remote/inference/vllm/vllm.py +++ b/src/llama_stack/providers/remote/inference/vllm/vllm.py @@ -12,8 +12,6 @@ from llama_stack.log import get_logger from llama_stack.providers.inline.responses.builtin.responses.types import ( AssistantMessageWithReasoning, - OpenAIChatCompletionChunkWithReasoning, - OpenAIChatCompletionWithReasoning, ) from llama_stack.providers.utils.inference.http_client import _build_network_client_kwargs from llama_stack.providers.utils.inference.openai_mixin import OpenAIMixin @@ -24,9 +22,11 @@ ModelType, OpenAIChatCompletion, OpenAIChatCompletionChunk, + OpenAIChatCompletionChunkWithReasoning, OpenAIChatCompletionContentPartImageParam, OpenAIChatCompletionContentPartTextParam, OpenAIChatCompletionRequestWithExtraBody, + OpenAIChatCompletionWithReasoning, RerankData, RerankResponse, ) diff --git a/src/llama_stack_api/__init__.py b/src/llama_stack_api/__init__.py index 9054f19b527..90c209598fa 100644 --- a/src/llama_stack_api/__init__.py +++ b/src/llama_stack_api/__init__.py @@ -256,6 +256,8 @@ ModelStore, OpenAIAssistantMessageParam, OpenAIChatCompletion, + OpenAIChatCompletionChunkWithReasoning, + OpenAIChatCompletionWithReasoning, OpenAIChatCompletionChunk, OpenAIChatCompletionContentPartImageParam, OpenAIChatCompletionContentPartParam, @@ -803,6 +805,8 @@ "OpenAIAssistantMessageParam", "OpenAIChatCompletion", "OpenAIChatCompletionChunk", + "OpenAIChatCompletionChunkWithReasoning", + "OpenAIChatCompletionWithReasoning", "OpenAIChatCompletionContentPartImageParam", "OpenAIChatCompletionContentPartParam", "OpenAIChatCompletionContentPartTextParam", diff --git a/src/llama_stack_api/inference/__init__.py b/src/llama_stack_api/inference/__init__.py index f14f62c7c8d..18431f6a52c 100644 --- a/src/llama_stack_api/inference/__init__.py +++ b/src/llama_stack_api/inference/__init__.py @@ -43,6 +43,7 @@ OpenAIAssistantMessageParam, OpenAIChatCompletion, OpenAIChatCompletionChunk, + OpenAIChatCompletionChunkWithReasoning, OpenAIChatCompletionContentPartImageParam, OpenAIChatCompletionContentPartParam, OpenAIChatCompletionContentPartTextParam, @@ -61,6 +62,7 @@ OpenAIChatCompletionUsage, OpenAIChatCompletionUsageCompletionTokensDetails, OpenAIChatCompletionUsagePromptTokensDetails, + OpenAIChatCompletionWithReasoning, OpenAIChoice, OpenAIChoiceDelta, OpenAIChoiceLogprobs, @@ -191,6 +193,8 @@ "OpenAIChatCompletionUsage", "OpenAIChatCompletion", "OpenAIChatCompletionChunk", + "OpenAIChatCompletionChunkWithReasoning", + "OpenAIChatCompletionWithReasoning", "OpenAICompletionLogprobs", "OpenAICompletionChoice", "OpenAICompletion", diff --git a/src/llama_stack_api/inference/api.py b/src/llama_stack_api/inference/api.py index 7c68c1fb19d..a78cc3d356c 100644 --- a/src/llama_stack_api/inference/api.py +++ b/src/llama_stack_api/inference/api.py @@ -15,7 +15,9 @@ ListOpenAIChatCompletionResponse, OpenAIChatCompletion, OpenAIChatCompletionChunk, + OpenAIChatCompletionChunkWithReasoning, OpenAIChatCompletionRequestWithExtraBody, + OpenAIChatCompletionWithReasoning, OpenAICompletion, OpenAICompletionRequestWithExtraBody, OpenAICompletionWithInputMessages, @@ -67,7 +69,7 @@ async def openai_chat_completion( async def openai_chat_completions_with_reasoning( self, params: OpenAIChatCompletionRequestWithExtraBody, - ) -> object: + ) -> OpenAIChatCompletionWithReasoning | AsyncIterator[OpenAIChatCompletionChunkWithReasoning]: """Chat completion with reasoning token extraction. Internal method used by the Responses implementation when reasoning diff --git a/src/llama_stack_api/inference/models.py b/src/llama_stack_api/inference/models.py index 616cf7c4dc4..15700d64c2d 100644 --- a/src/llama_stack_api/inference/models.py +++ b/src/llama_stack_api/inference/models.py @@ -1038,6 +1038,34 @@ class RerankRequest(BaseModel): ) +@json_schema_type +class OpenAIChatCompletionWithReasoning(BaseModel): + """Internal wrapper: a CC response with extracted reasoning content. + + Returned by openai_chat_completions_with_reasoning for non-streaming. + The Responses layer unwraps .completion and reads .reasoning_content. + """ + + model_config = ConfigDict(arbitrary_types_allowed=True) + + completion: Any = Field(..., description="The chat completion response.") + reasoning_content: str | None = Field(None, description="Extracted reasoning content, if any.") + + +@json_schema_type +class OpenAIChatCompletionChunkWithReasoning(BaseModel): + """Internal wrapper: a CC streaming chunk with extracted reasoning content. + + Yielded by openai_chat_completions_with_reasoning for streaming. + The Responses layer unwraps .chunk and reads .reasoning_content. + """ + + model_config = ConfigDict(arbitrary_types_allowed=True) + + chunk: Any = Field(..., description="The chat completion chunk.") + reasoning_content: str | None = Field(None, description="Extracted reasoning content, if any.") + + __all__ = [ # Sampling "GreedySamplingStrategy", @@ -1071,6 +1099,8 @@ class RerankRequest(BaseModel): "RerankResponse", # OpenAI Compatibility "OpenAIChatCompletionContentPartTextParam", + "OpenAIChatCompletionWithReasoning", + "OpenAIChatCompletionChunkWithReasoning", "OpenAIImageURL", "OpenAIChatCompletionContentPartImageParam", "OpenAIFileFile", From 4b2b07ad300acfa5bcb2369eb4af8e7fec1ed03c Mon Sep 17 00:00:00 2001 From: Charlie Doern Date: Wed, 1 Apr 2026 15:12:38 -0400 Subject: [PATCH 2/3] fix: remove from spec remove json_schema_type to remove this from the spec Signed-off-by: Charlie Doern --- client-sdks/stainless/openapi.yml | 38 ------------------- docs/static/deprecated-llama-stack-spec.yaml | 38 ------------------- .../static/experimental-llama-stack-spec.yaml | 38 ------------------- docs/static/llama-stack-spec.yaml | 38 ------------------- docs/static/stainless-llama-stack-spec.yaml | 38 ------------------- src/llama_stack_api/inference/models.py | 2 - 6 files changed, 192 deletions(-) diff --git a/client-sdks/stainless/openapi.yml b/client-sdks/stainless/openapi.yml index 3a57ccc16c1..803097906a5 100644 --- a/client-sdks/stainless/openapi.yml +++ b/client-sdks/stainless/openapi.yml @@ -14122,44 +14122,6 @@ components: required: - completion_id title: GetChatCompletionRequest - OpenAIChatCompletionWithReasoning: - description: |- - Internal wrapper: a CC response with extracted reasoning content. - - Returned by openai_chat_completions_with_reasoning for non-streaming. - The Responses layer unwraps .completion and reads .reasoning_content. - properties: - completion: - $ref: '#/components/schemas/OpenAIChatCompletion' - description: The chat completion response. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - completion - title: OpenAIChatCompletionWithReasoning - OpenAIChatCompletionChunkWithReasoning: - description: |- - Internal wrapper: a CC streaming chunk with extracted reasoning content. - - Yielded by openai_chat_completions_with_reasoning for streaming. - The Responses layer unwraps .chunk and reads .reasoning_content. - properties: - chunk: - $ref: '#/components/schemas/OpenAIChatCompletionChunk' - description: The chat completion chunk. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - chunk - title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/docs/static/deprecated-llama-stack-spec.yaml b/docs/static/deprecated-llama-stack-spec.yaml index 3d1f11f2852..633c76bd0dc 100644 --- a/docs/static/deprecated-llama-stack-spec.yaml +++ b/docs/static/deprecated-llama-stack-spec.yaml @@ -10480,44 +10480,6 @@ components: required: - completion_id title: GetChatCompletionRequest - OpenAIChatCompletionWithReasoning: - description: |- - Internal wrapper: a CC response with extracted reasoning content. - - Returned by openai_chat_completions_with_reasoning for non-streaming. - The Responses layer unwraps .completion and reads .reasoning_content. - properties: - completion: - $ref: '#/components/schemas/OpenAIChatCompletion' - description: The chat completion response. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - completion - title: OpenAIChatCompletionWithReasoning - OpenAIChatCompletionChunkWithReasoning: - description: |- - Internal wrapper: a CC streaming chunk with extracted reasoning content. - - Yielded by openai_chat_completions_with_reasoning for streaming. - The Responses layer unwraps .chunk and reads .reasoning_content. - properties: - chunk: - $ref: '#/components/schemas/OpenAIChatCompletionChunk' - description: The chat completion chunk. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - chunk - title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/docs/static/experimental-llama-stack-spec.yaml b/docs/static/experimental-llama-stack-spec.yaml index 650156aad8a..08fcd484f66 100644 --- a/docs/static/experimental-llama-stack-spec.yaml +++ b/docs/static/experimental-llama-stack-spec.yaml @@ -10685,44 +10685,6 @@ components: required: - completion_id title: GetChatCompletionRequest - OpenAIChatCompletionWithReasoning: - description: |- - Internal wrapper: a CC response with extracted reasoning content. - - Returned by openai_chat_completions_with_reasoning for non-streaming. - The Responses layer unwraps .completion and reads .reasoning_content. - properties: - completion: - $ref: '#/components/schemas/OpenAIChatCompletion' - description: The chat completion response. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - completion - title: OpenAIChatCompletionWithReasoning - OpenAIChatCompletionChunkWithReasoning: - description: |- - Internal wrapper: a CC streaming chunk with extracted reasoning content. - - Yielded by openai_chat_completions_with_reasoning for streaming. - The Responses layer unwraps .chunk and reads .reasoning_content. - properties: - chunk: - $ref: '#/components/schemas/OpenAIChatCompletionChunk' - description: The chat completion chunk. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - chunk - title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/docs/static/llama-stack-spec.yaml b/docs/static/llama-stack-spec.yaml index 216429ed72d..92d0d22b46b 100644 --- a/docs/static/llama-stack-spec.yaml +++ b/docs/static/llama-stack-spec.yaml @@ -13047,44 +13047,6 @@ components: required: - completion_id title: GetChatCompletionRequest - OpenAIChatCompletionWithReasoning: - description: |- - Internal wrapper: a CC response with extracted reasoning content. - - Returned by openai_chat_completions_with_reasoning for non-streaming. - The Responses layer unwraps .completion and reads .reasoning_content. - properties: - completion: - $ref: '#/components/schemas/OpenAIChatCompletion' - description: The chat completion response. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - completion - title: OpenAIChatCompletionWithReasoning - OpenAIChatCompletionChunkWithReasoning: - description: |- - Internal wrapper: a CC streaming chunk with extracted reasoning content. - - Yielded by openai_chat_completions_with_reasoning for streaming. - The Responses layer unwraps .chunk and reads .reasoning_content. - properties: - chunk: - $ref: '#/components/schemas/OpenAIChatCompletionChunk' - description: The chat completion chunk. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - chunk - title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/docs/static/stainless-llama-stack-spec.yaml b/docs/static/stainless-llama-stack-spec.yaml index 3a57ccc16c1..803097906a5 100644 --- a/docs/static/stainless-llama-stack-spec.yaml +++ b/docs/static/stainless-llama-stack-spec.yaml @@ -14122,44 +14122,6 @@ components: required: - completion_id title: GetChatCompletionRequest - OpenAIChatCompletionWithReasoning: - description: |- - Internal wrapper: a CC response with extracted reasoning content. - - Returned by openai_chat_completions_with_reasoning for non-streaming. - The Responses layer unwraps .completion and reads .reasoning_content. - properties: - completion: - $ref: '#/components/schemas/OpenAIChatCompletion' - description: The chat completion response. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - completion - title: OpenAIChatCompletionWithReasoning - OpenAIChatCompletionChunkWithReasoning: - description: |- - Internal wrapper: a CC streaming chunk with extracted reasoning content. - - Yielded by openai_chat_completions_with_reasoning for streaming. - The Responses layer unwraps .chunk and reads .reasoning_content. - properties: - chunk: - $ref: '#/components/schemas/OpenAIChatCompletionChunk' - description: The chat completion chunk. - reasoning_content: - anyOf: - - type: string - - type: 'null' - description: Extracted reasoning content, if any. - nullable: true - required: - - chunk - title: OpenAIChatCompletionChunkWithReasoning EmbeddedChunk: description: |- A chunk of content with its embedding vector for vector database operations. diff --git a/src/llama_stack_api/inference/models.py b/src/llama_stack_api/inference/models.py index 15700d64c2d..1b5b8d9da95 100644 --- a/src/llama_stack_api/inference/models.py +++ b/src/llama_stack_api/inference/models.py @@ -1038,7 +1038,6 @@ class RerankRequest(BaseModel): ) -@json_schema_type class OpenAIChatCompletionWithReasoning(BaseModel): """Internal wrapper: a CC response with extracted reasoning content. @@ -1052,7 +1051,6 @@ class OpenAIChatCompletionWithReasoning(BaseModel): reasoning_content: str | None = Field(None, description="Extracted reasoning content, if any.") -@json_schema_type class OpenAIChatCompletionChunkWithReasoning(BaseModel): """Internal wrapper: a CC streaming chunk with extracted reasoning content. From fedd99ffc76333ccb814dd10de8b3612c4d2e0f2 Mon Sep 17 00:00:00 2001 From: Charlie Doern Date: Wed, 1 Apr 2026 15:17:00 -0400 Subject: [PATCH 3/3] fix: doc string Signed-off-by: Charlie Doern --- src/llama_stack_api/inference/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llama_stack_api/inference/api.py b/src/llama_stack_api/inference/api.py index a78cc3d356c..b15009f6a91 100644 --- a/src/llama_stack_api/inference/api.py +++ b/src/llama_stack_api/inference/api.py @@ -77,7 +77,7 @@ async def openai_chat_completions_with_reasoning( alongside the CC response: - OpenAIChatCompletionWithReasoning (non-streaming) - AsyncIterator[OpenAIChatCompletionChunkWithReasoning] (streaming) - These are defined in llama_stack.providers.inline.responses.builtin.responses.types. + These are defined in llama_stack_api.inference.models. Default raises NotImplementedError so unsupported providers fail loudly instead of silently returning no reasoning.