@@ -519,7 +519,7 @@ def _prepare_hyperparams(
519519 return
520520 # Disable reasoning if requested
521521 if (
522- reasoning_effort in ("disable" , "minimal" )
522+ reasoning_effort in ("disable" , "minimal" , "none" )
523523 or thinking_budget == 0
524524 or (reasoning_effort is None and thinking_budget is None )
525525 ):
@@ -540,7 +540,14 @@ def _prepare_hyperparams(
540540 hyperparams ["thinking" ] = {"type" : "disabled" }
541541 return
542542 elif ctx .inference_provider == CloudProvider .OPENAI :
543- if "gpt-5" in ctx .routing_id :
543+ if "gpt-5.1" in ctx .routing_id :
544+ # gpt-5.1: Supported values are: 'none', 'low', 'medium', and 'high'.
545+ hyperparams ["reasoning" ] = {
546+ "effort" : "none" ,
547+ "summary" : reasoning_summary ,
548+ }
549+ return
550+ elif "gpt-5" in ctx .routing_id :
544551 hyperparams ["reasoning" ] = {
545552 "effort" : "minimal" ,
546553 "summary" : reasoning_summary ,
@@ -668,20 +675,22 @@ async def _openai_responses_stream(
668675 and hasattr (chunk .item .action , "query" )
669676 and chunk .item .action .query
670677 ):
678+ yield self ._stream_delta (Delta (role = "assistant" , reasoning_content = "\n \n " ))
671679 yield self ._stream_delta (
672680 Delta (
673681 role = "assistant" ,
674- reasoning_content = f'\n \n Searched the web for "{ chunk .item .action .query } ".' ,
682+ reasoning_content = f'Searched the web for "{ chunk .item .action .query } ".' ,
675683 )
676684 )
677685 yield self ._stream_delta (Delta (role = "assistant" , reasoning_content = "\n \n " ))
678686 elif isinstance (chunk .item , ResponseCodeInterpreterToolCall ):
679687 usage_stats ["code_interpreter_calls" ] += 1
680688 code_snippet = chunk .item .code
689+ yield self ._stream_delta (Delta (role = "assistant" , reasoning_content = "\n \n " ))
681690 yield self ._stream_delta (
682691 Delta (
683692 role = "assistant" ,
684- reasoning_content = f"\n \n Ran Python code:\n \n ```python\n { code_snippet } \n ```" ,
693+ reasoning_content = f"Ran Python code:\n \n ```python\n { code_snippet } \n ```" ,
685694 )
686695 )
687696 yield self ._stream_delta (Delta (role = "assistant" , reasoning_content = "\n \n " ))
@@ -744,11 +753,13 @@ async def _openai_responses(
744753 elif isinstance (item , ResponseFunctionWebSearch ) and item .status == "completed" :
745754 usage_stats ["web_search_calls" ] += 1
746755 if item .action and hasattr (item .action , "query" ) and item .action .query :
747- reasoning_parts .append (f'Searched the web for "{ item .action .query } ".' )
756+ reasoning_parts .append (f'\n \n Searched the web for "{ item .action .query } ".\n \n ' )
748757 elif isinstance (item , ResponseCodeInterpreterToolCall ) and item .status == "completed" :
749758 usage_stats ["code_interpreter_calls" ] += 1
750759 code_snippet = item .code
751- reasoning_parts .append (f"Ran Python code:\n \n ```python\n { code_snippet } \n ```" )
760+ reasoning_parts .append (
761+ f"\n \n Ran Python code:\n \n ```python\n { code_snippet } \n ```\n \n "
762+ )
752763 elif isinstance (item , ResponseOutputMessage ) and item .status == "completed" :
753764 text_content = item .content [0 ].text if item .content else ""
754765 result_parts .append (text_content )
0 commit comments