5454"""
5555
5656OutputValidatorFunc = (
57- Callable [[RunContext [AgentDepsT ], OutputDataT_inv , bool ], OutputDataT_inv ]
58- | Callable [[RunContext [AgentDepsT ], OutputDataT_inv , bool ], Awaitable [OutputDataT_inv ]]
59- | Callable [[RunContext [AgentDepsT ], OutputDataT_inv ], OutputDataT_inv ]
57+ Callable [[RunContext [AgentDepsT ], OutputDataT_inv ], OutputDataT_inv ]
6058 | Callable [[RunContext [AgentDepsT ], OutputDataT_inv ], Awaitable [OutputDataT_inv ]]
6159 | Callable [[OutputDataT_inv ], OutputDataT_inv ]
6260 | Callable [[OutputDataT_inv ], Awaitable [OutputDataT_inv ]]
6361)
6462"""
65- A function that always takes and returns the same type of data (which is the result type of an agent run). In addition :
63+ A function that always takes and returns the same type of data (which is the result type of an agent run), and :
6664
67- * it can optionally take [`RunContext`][pydantic_ai.tools.RunContext] as a first argument
68- * if it takes [`RunContext`][pydantic_ai.tools.RunContext] as a first argument, it can also optionally take `partial: bool` as a last argument
69- * it can be async
65+ * may or may not take [`RunContext`][pydantic_ai.tools.RunContext] as a first argument
66+ * may or may not be async
7067
7168Usage `OutputValidatorFunc[AgentDepsT, T]`.
7269"""
@@ -165,29 +162,24 @@ async def execute_traced_output_function(
165162class OutputValidator (Generic [AgentDepsT , OutputDataT_inv ]):
166163 function : OutputValidatorFunc [AgentDepsT , OutputDataT_inv ]
167164 _takes_ctx : bool = field (init = False )
168- _takes_partial : bool = field (init = False )
169165 _is_async : bool = field (init = False )
170166
171167 def __post_init__ (self ):
172- sig = inspect .signature (self .function )
173- self ._takes_ctx = len (sig .parameters ) > 1
174- self ._takes_partial = len (sig .parameters ) > 2
168+ self ._takes_ctx = len (inspect .signature (self .function ).parameters ) > 1
175169 self ._is_async = _utils .is_async_callable (self .function )
176170
177171 async def validate (
178172 self ,
179173 result : T ,
180174 run_context : RunContext [AgentDepsT ],
181175 wrap_validation_errors : bool = True ,
182- partial : bool = False ,
183176 ) -> T :
184177 """Validate a result but calling the function.
185178
186179 Args:
187180 result: The result data after Pydantic validation the message content.
188181 run_context: The current run context.
189182 wrap_validation_errors: If true, wrap the validation errors in a retry message.
190- partial: Whether the output to validate is partial.
191183
192184 Returns:
193185 Result of either the validated result data (ok) or a retry message (Err).
@@ -197,9 +189,6 @@ async def validate(
197189 else :
198190 args = (result ,)
199191
200- if self ._takes_partial :
201- args = (* args , partial )
202-
203192 try :
204193 if self ._is_async :
205194 function = cast (Callable [[Any ], Awaitable [T ]], self .function )
@@ -1079,7 +1068,7 @@ async def call_tool(
10791068 ) -> Any :
10801069 output = await self .processors [name ].call (tool_args , ctx , wrap_validation_errors = False )
10811070 for validator in self .output_validators :
1082- output = await validator .validate (output , ctx , wrap_validation_errors = False , partial = ctx . tool_args_partial )
1071+ output = await validator .validate (output , ctx , wrap_validation_errors = False )
10831072 return output
10841073
10851074
0 commit comments