@@ -211,28 +211,21 @@ async def validate(
211211
212212
213213@dataclass (kw_only = True )
214- class BaseOutputSchema (ABC , Generic [OutputDataT ]):
214+ class OutputSchema (ABC , Generic [OutputDataT ]):
215215 text_processor : BaseOutputProcessor [OutputDataT ] | None = None
216216 toolset : OutputToolset [Any ] | None = None
217217 object_def : OutputObjectDefinition | None = None
218218 allows_deferred_tools : bool = False
219219 allows_image : bool = False
220220
221221 @property
222- def mode (self ) -> OutputMode | None :
222+ def mode (self ) -> OutputMode :
223223 raise NotImplementedError ()
224224
225225 @property
226226 def allows_text (self ) -> bool :
227227 return self .text_processor is not None
228228
229-
230- @dataclass (init = False )
231- class OutputSchema (BaseOutputSchema [OutputDataT ], ABC ):
232- """Model the final output from an agent run."""
233-
234- # TODO (DouweM): Rename/merge this, BaseOutputSchema, and OutputSchemaWithoutMode
235-
236229 @classmethod
237230 def build ( # noqa: C901
238231 cls ,
@@ -241,7 +234,7 @@ def build( # noqa: C901
241234 name : str | None = None ,
242235 description : str | None = None ,
243236 strict : bool | None = None ,
244- ) -> BaseOutputSchema [OutputDataT ]:
237+ ) -> OutputSchema [OutputDataT ]:
245238 """Build an OutputSchema dataclass from an output type."""
246239 outputs = _flatten_output_spec (output_spec )
247240
@@ -359,7 +352,7 @@ def build( # noqa: C901
359352 )
360353
361354 if len (other_outputs ) > 0 :
362- return OutputSchemaWithoutMode (
355+ return AutoOutputSchema (
363356 processor = cls ._build_processor (other_outputs , name = name , description = description , strict = strict ),
364357 toolset = toolset ,
365358 allows_deferred_tools = allows_deferred_tools ,
@@ -386,7 +379,7 @@ def _build_processor(
386379
387380
388381@dataclass (init = False )
389- class OutputSchemaWithoutMode ( BaseOutputSchema [OutputDataT ]):
382+ class AutoOutputSchema ( OutputSchema [OutputDataT ]):
390383 processor : BaseObjectOutputProcessor [OutputDataT ]
391384
392385 def __init__ (
@@ -400,18 +393,17 @@ def __init__(
400393 # At that point we may not know yet what output mode we're going to use if no model was provided or it was deferred until agent.run time,
401394 # but we cover ourselves just in case we end up using the tool output mode.
402395 super ().__init__ (
403- allows_deferred_tools = allows_deferred_tools ,
404396 toolset = toolset ,
405397 object_def = processor .object_def ,
406398 text_processor = processor ,
399+ allows_deferred_tools = allows_deferred_tools ,
407400 allows_image = allows_image ,
408401 )
409402 self .processor = processor
410403
411404 @property
412- def mode (self ) -> OutputMode | None :
413- # TODO (DouweM): Could this be a field?
414- return None
405+ def mode (self ) -> OutputMode :
406+ return 'auto'
415407
416408
417409@dataclass (init = False )
@@ -430,7 +422,7 @@ def __init__(
430422 )
431423
432424 @property
433- def mode (self ) -> OutputMode | None :
425+ def mode (self ) -> OutputMode :
434426 return 'text'
435427
436428
@@ -439,7 +431,7 @@ def __init__(self, *, allows_deferred_tools: bool):
439431 super ().__init__ (allows_deferred_tools = allows_deferred_tools , allows_image = True )
440432
441433 @property
442- def mode (self ) -> OutputMode | None :
434+ def mode (self ) -> OutputMode :
443435 return 'image'
444436
445437
@@ -461,7 +453,7 @@ def __init__(
461453
462454class NativeOutputSchema (StructuredTextOutputSchema [OutputDataT ]):
463455 @property
464- def mode (self ) -> OutputMode | None :
456+ def mode (self ) -> OutputMode :
465457 return 'native'
466458
467459
@@ -485,7 +477,7 @@ def __init__(
485477 self .template = template
486478
487479 @property
488- def mode (self ) -> OutputMode | None :
480+ def mode (self ) -> OutputMode :
489481 return 'prompted'
490482
491483 @classmethod
@@ -528,7 +520,7 @@ def __init__(
528520 )
529521
530522 @property
531- def mode (self ) -> OutputMode | None :
523+ def mode (self ) -> OutputMode :
532524 return 'tool'
533525
534526
0 commit comments