@@ -497,12 +497,32 @@ async def get_response(
497497 include_list .append ("message.output_text.logprobs" )
498498 # Build response format for verbosity and structured output
499499 response_format = NOT_GIVEN
500+
500501 if output_schema is not None :
501- # Handle structured output schema
502- # This would need conversion logic similar to Converter.get_response_format
503- pass # TODO: Implement output_schema conversion
504- elif model_settings .verbosity is not None :
505- response_format = {"verbosity" : model_settings .verbosity }
502+ # Handle structured output schema for Responses API
503+ # The Responses API expects the schema in the 'text' parameter with a 'format' key
504+ logger .debug (f"[TemporalStreamingModel] Converting output_schema to Responses API format" )
505+ try :
506+ # Get the JSON schema from the output schema
507+ schema_dict = output_schema .json_schema ()
508+ response_format = {
509+ "format" : {
510+ "type" : "json_schema" ,
511+ "name" : "final_output" ,
512+ "schema" : schema_dict ,
513+ "strict" : output_schema .is_strict_json_schema () if hasattr (output_schema , 'is_strict_json_schema' ) else True ,
514+ }
515+ }
516+ logger .debug (f"[TemporalStreamingModel] Built response_format with json_schema: { response_format } " )
517+ except Exception as e :
518+ logger .warning (f"Failed to convert output_schema: { e } " )
519+ response_format = NOT_GIVEN
520+
521+ if model_settings .verbosity is not None :
522+ if response_format is not NOT_GIVEN and isinstance (response_format , dict ):
523+ response_format ["verbosity" ] = model_settings .verbosity
524+ else :
525+ response_format = {"verbosity" : model_settings .verbosity }
506526
507527 # Build extra_args dict for additional parameters
508528 extra_args = dict (model_settings .extra_args or {})
@@ -529,7 +549,7 @@ async def get_response(
529549 parallel_tool_calls = self ._non_null_or_not_given (model_settings .parallel_tool_calls ),
530550 # Context and truncation
531551 truncation = self ._non_null_or_not_given (model_settings .truncation ),
532- # Response configuration
552+ # Response configuration (includes structured output schema)
533553 text = response_format ,
534554 include = include_list if include_list else NOT_GIVEN ,
535555 # Metadata and storage
0 commit comments