@@ -470,7 +470,7 @@ def __init__(
470470 allows_image : bool ,
471471 ):
472472 super ().__init__ (
473- processor = PromptedOutputProcessor ( processor ) ,
473+ processor = processor ,
474474 allows_deferred_tools = allows_deferred_tools ,
475475 allows_image = allows_image ,
476476 )
@@ -494,13 +494,6 @@ def build_instructions(cls, template: str, object_def: OutputObjectDefinition) -
494494
495495 return template .format (schema = json .dumps (schema ))
496496
497- def instructions (self , default_template : str ) -> str : # pragma: no cover
498- """Get instructions to tell model to output JSON matching the schema."""
499- template = self .template or default_template
500- object_def = self .object_def
501- assert object_def is not None
502- return self .build_instructions (template , object_def )
503-
504497
505498@dataclass (init = False )
506499class ToolOutputSchema (OutputSchema [OutputDataT ]):
@@ -542,28 +535,6 @@ class BaseObjectOutputProcessor(BaseOutputProcessor[OutputDataT]):
542535 object_def : OutputObjectDefinition
543536
544537
545- @dataclass (init = False )
546- class PromptedOutputProcessor (BaseObjectOutputProcessor [OutputDataT ]):
547- wrapped : BaseObjectOutputProcessor [OutputDataT ]
548-
549- def __init__ (self , wrapped : BaseObjectOutputProcessor [OutputDataT ]):
550- self .wrapped = wrapped
551- super ().__init__ (object_def = wrapped .object_def )
552-
553- async def process (
554- self ,
555- data : str ,
556- run_context : RunContext [AgentDepsT ],
557- allow_partial : bool = False ,
558- wrap_validation_errors : bool = True ,
559- ) -> OutputDataT :
560- text = _utils .strip_markdown_fences (data )
561-
562- return await self .wrapped .process (
563- text , run_context , allow_partial = allow_partial , wrap_validation_errors = wrap_validation_errors
564- )
565-
566-
567538@dataclass (init = False )
568539class ObjectOutputProcessor (BaseObjectOutputProcessor [OutputDataT ]):
569540 outer_typed_dict_key : str | None = None
@@ -653,6 +624,9 @@ async def process(
653624 Returns:
654625 Either the validated output data (left) or a retry message (right).
655626 """
627+ if isinstance (data , str ):
628+ data = _utils .strip_markdown_fences (data )
629+
656630 try :
657631 output = self .validate (data , allow_partial )
658632 except ValidationError as e :
0 commit comments