|
12 | 12 |
|
13 | 13 | This module provides ``LlamaStackResponsesModel`` which wraps the event stream to |
14 | 14 | buffer those early delta events and replay them correctly once the item is announced. |
| 15 | +
|
| 16 | +Additionally overrides ``_responses_create`` to filter out ``reasoning.encrypted_content`` |
| 17 | +from the include parameter, which llama-stack v0.7.1 doesn't support. |
15 | 18 | """ |
16 | 19 |
|
17 | 20 | from __future__ import annotations as _annotations |
@@ -226,8 +229,50 @@ class LlamaStackResponsesModel(OpenAIResponsesModel): |
226 | 229 | Overrides the streaming response processing to buffer and replay |
227 | 230 | ``ResponseFunctionCallArgumentsDeltaEvent`` events that Llama Stack emits |
228 | 231 | before the corresponding ``McpCall`` or ``ResponseFunctionToolCall`` item. |
| 232 | +
|
| 233 | + Also filters ``reasoning.encrypted_content`` from the include parameter since |
| 234 | + llama-stack v0.7.1 doesn't support it. |
229 | 235 | """ |
230 | 236 |
|
| 237 | + async def _responses_create( |
| 238 | + self, |
| 239 | + messages: list[ModelMessage], |
| 240 | + stream: bool, |
| 241 | + model_settings: OpenAIResponsesModelSettings, |
| 242 | + model_request_parameters: ModelRequestParameters, |
| 243 | + ) -> Any: |
| 244 | + """Call parent's _responses_create, then filter reasoning.encrypted_content from include. |
| 245 | +
|
| 246 | + Llama Stack v0.7.1 doesn't support reasoning.encrypted_content in the include |
| 247 | + parameter. pydantic-ai adds it automatically based on the model profile, so we |
| 248 | + intercept the prepared request parameters and remove it before sending. |
| 249 | +
|
| 250 | + Args: |
| 251 | + messages: Model messages for the request. |
| 252 | + stream: Whether this is a streaming request. |
| 253 | + model_settings: Model-specific settings. |
| 254 | + model_request_parameters: Request parameters for the model. |
| 255 | +
|
| 256 | + Returns: |
| 257 | + Response from the Responses API. |
| 258 | + """ |
| 259 | + # Parent gates include on this profile flag; disable it for Llama Stack. |
| 260 | + self.profile["openai_supports_encrypted_reasoning_content"] = False |
| 261 | + # Branch on stream so mypy matches OpenAIResponsesModel overloads |
| 262 | + if stream: |
| 263 | + return await super()._responses_create( |
| 264 | + messages, |
| 265 | + True, |
| 266 | + model_settings, |
| 267 | + model_request_parameters, |
| 268 | + ) |
| 269 | + return await super()._responses_create( |
| 270 | + messages, |
| 271 | + False, |
| 272 | + model_settings, |
| 273 | + model_request_parameters, |
| 274 | + ) |
| 275 | + |
231 | 276 | async def request( # pylint: disable=unused-argument |
232 | 277 | self, |
233 | 278 | messages: list[ModelMessage], |
|
0 commit comments