@@ -526,16 +526,20 @@ def _process_response(self, response: chat.ChatCompletion | str) -> ModelRespons
526
526
527
527
choice = response .choices [0 ]
528
528
items : list [ModelResponsePart ] = []
529
+
529
530
# The `reasoning_content` field is only present in DeepSeek models.
530
531
# https://api-docs.deepseek.com/guides/reasoning_model
531
532
if reasoning_content := getattr (choice .message , 'reasoning_content' , None ):
532
533
items .append (ThinkingPart (id = 'reasoning_content' , content = reasoning_content , provider_name = self .system ))
533
534
534
- # NOTE: We don't currently handle OpenRouter `reasoning_details`:
535
- # - https://openrouter.ai/docs/use-cases/reasoning-tokens#preserving-reasoning-blocks
536
- # NOTE: We don't currently handle OpenRouter/gpt-oss `reasoning`:
535
+ # The `reasoning` field is only present in gpt-oss via Ollama and OpenRouter.
537
536
# - https://cookbook.openai.com/articles/gpt-oss/handle-raw-cot#chat-completions-api
538
537
# - https://openrouter.ai/docs/use-cases/reasoning-tokens#basic-usage-with-reasoning-tokens
538
+ if reasoning := getattr (choice .message , 'reasoning' , None ):
539
+ items .append (ThinkingPart (id = 'reasoning' , content = reasoning , provider_name = self .system ))
540
+
541
+ # NOTE: We don't currently handle OpenRouter `reasoning_details`:
542
+ # - https://openrouter.ai/docs/use-cases/reasoning-tokens#preserving-reasoning-blocks
539
543
# If you need this, please file an issue.
540
544
541
545
vendor_details : dict [str , Any ] = {}
@@ -1492,6 +1496,17 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
1492
1496
provider_name = self .provider_name ,
1493
1497
)
1494
1498
1499
+ # The `reasoning` field is only present in gpt-oss via Ollama and OpenRouter.
1500
+ # - https://cookbook.openai.com/articles/gpt-oss/handle-raw-cot#chat-completions-api
1501
+ # - https://openrouter.ai/docs/use-cases/reasoning-tokens#basic-usage-with-reasoning-tokens
1502
+ if reasoning := getattr (choice .delta , 'reasoning' , None ): # pragma: no cover
1503
+ yield self ._parts_manager .handle_thinking_delta (
1504
+ vendor_part_id = 'reasoning' ,
1505
+ id = 'reasoning' ,
1506
+ content = reasoning ,
1507
+ provider_name = self .provider_name ,
1508
+ )
1509
+
1495
1510
for dtc in choice .delta .tool_calls or []:
1496
1511
maybe_event = self ._parts_manager .handle_tool_call_delta (
1497
1512
vendor_part_id = dtc .index ,
0 commit comments