pydantic-ai-slim 0.5.0__py3-none-any.whl → 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pydantic-ai-slim might be problematic. Click here for more details.

@@ -620,7 +620,7 @@ async def process_function_tools( # noqa: C901
620
620
  result_data = await tool_manager.handle_call(call)
621
621
  except exceptions.UnexpectedModelBehavior as e:
622
622
  ctx.state.increment_retries(ctx.deps.max_result_retries, e)
623
- raise e # pragma: no cover
623
+ raise e # pragma: lax no cover
624
624
  except ToolRetryError as e:
625
625
  ctx.state.increment_retries(ctx.deps.max_result_retries, e)
626
626
  yield _messages.FunctionToolCallEvent(call)
pydantic_ai/agent.py CHANGED
@@ -151,8 +151,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
151
151
  _instrument_default: ClassVar[InstrumentationSettings | bool] = False
152
152
 
153
153
  _deps_type: type[AgentDepsT] = dataclasses.field(repr=False)
154
- _deprecated_result_tool_name: str | None = dataclasses.field(repr=False)
155
- _deprecated_result_tool_description: str | None = dataclasses.field(repr=False)
156
154
  _output_schema: _output.BaseOutputSchema[OutputDataT] = dataclasses.field(repr=False)
157
155
  _output_validators: list[_output.OutputValidator[AgentDepsT, OutputDataT]] = dataclasses.field(repr=False)
158
156
  _instructions: str | None = dataclasses.field(repr=False)
@@ -199,44 +197,13 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
199
197
  history_processors: Sequence[HistoryProcessor[AgentDepsT]] | None = None,
200
198
  ) -> None: ...
201
199
 
202
- @overload
203
- @deprecated(
204
- '`result_type`, `result_tool_name` & `result_tool_description` are deprecated, use `output_type` instead. `result_retries` is deprecated, use `output_retries` instead.'
205
- )
206
- def __init__(
207
- self,
208
- model: models.Model | models.KnownModelName | str | None = None,
209
- *,
210
- result_type: type[OutputDataT] = str,
211
- instructions: str
212
- | _system_prompt.SystemPromptFunc[AgentDepsT]
213
- | Sequence[str | _system_prompt.SystemPromptFunc[AgentDepsT]]
214
- | None = None,
215
- system_prompt: str | Sequence[str] = (),
216
- deps_type: type[AgentDepsT] = NoneType,
217
- name: str | None = None,
218
- model_settings: ModelSettings | None = None,
219
- retries: int = 1,
220
- result_tool_name: str = _output.DEFAULT_OUTPUT_TOOL_NAME,
221
- result_tool_description: str | None = None,
222
- result_retries: int | None = None,
223
- tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] = (),
224
- prepare_tools: ToolsPrepareFunc[AgentDepsT] | None = None,
225
- prepare_output_tools: ToolsPrepareFunc[AgentDepsT] | None = None,
226
- toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
227
- defer_model_check: bool = False,
228
- end_strategy: EndStrategy = 'early',
229
- instrument: InstrumentationSettings | bool | None = None,
230
- history_processors: Sequence[HistoryProcessor[AgentDepsT]] | None = None,
231
- ) -> None: ...
232
-
233
200
  @overload
234
201
  @deprecated('`mcp_servers` is deprecated, use `toolsets` instead.')
235
202
  def __init__(
236
203
  self,
237
204
  model: models.Model | models.KnownModelName | str | None = None,
238
205
  *,
239
- result_type: type[OutputDataT] = str,
206
+ output_type: OutputSpec[OutputDataT] = str,
240
207
  instructions: str
241
208
  | _system_prompt.SystemPromptFunc[AgentDepsT]
242
209
  | Sequence[str | _system_prompt.SystemPromptFunc[AgentDepsT]]
@@ -246,9 +213,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
246
213
  name: str | None = None,
247
214
  model_settings: ModelSettings | None = None,
248
215
  retries: int = 1,
249
- result_tool_name: str = _output.DEFAULT_OUTPUT_TOOL_NAME,
250
- result_tool_description: str | None = None,
251
- result_retries: int | None = None,
216
+ output_retries: int | None = None,
252
217
  tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] = (),
253
218
  prepare_tools: ToolsPrepareFunc[AgentDepsT] | None = None,
254
219
  prepare_output_tools: ToolsPrepareFunc[AgentDepsT] | None = None,
@@ -263,8 +228,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
263
228
  self,
264
229
  model: models.Model | models.KnownModelName | str | None = None,
265
230
  *,
266
- # TODO change this back to `output_type: _output.OutputType[OutputDataT] = str,` when we remove the overloads
267
- output_type: Any = str,
231
+ output_type: OutputSpec[OutputDataT] = str,
268
232
  instructions: str
269
233
  | _system_prompt.SystemPromptFunc[AgentDepsT]
270
234
  | Sequence[str | _system_prompt.SystemPromptFunc[AgentDepsT]]
@@ -341,42 +305,10 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
341
305
  self.name = name
342
306
  self.model_settings = model_settings
343
307
 
344
- if 'result_type' in _deprecated_kwargs:
345
- if output_type is not str: # pragma: no cover
346
- raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
347
- warnings.warn('`result_type` is deprecated, use `output_type` instead', DeprecationWarning, stacklevel=2)
348
- output_type = _deprecated_kwargs.pop('result_type')
349
-
350
308
  self.output_type = output_type
351
-
352
309
  self.instrument = instrument
353
-
354
310
  self._deps_type = deps_type
355
311
 
356
- self._deprecated_result_tool_name = _deprecated_kwargs.pop('result_tool_name', None)
357
- if self._deprecated_result_tool_name is not None:
358
- warnings.warn(
359
- '`result_tool_name` is deprecated, use `output_type` with `ToolOutput` instead',
360
- DeprecationWarning,
361
- stacklevel=2,
362
- )
363
-
364
- self._deprecated_result_tool_description = _deprecated_kwargs.pop('result_tool_description', None)
365
- if self._deprecated_result_tool_description is not None:
366
- warnings.warn(
367
- '`result_tool_description` is deprecated, use `output_type` with `ToolOutput` instead',
368
- DeprecationWarning,
369
- stacklevel=2,
370
- )
371
- result_retries = _deprecated_kwargs.pop('result_retries', None)
372
- if result_retries is not None:
373
- if output_retries is not None: # pragma: no cover
374
- raise TypeError('`output_retries` and `result_retries` cannot be set at the same time.')
375
- warnings.warn(
376
- '`result_retries` is deprecated, use `max_result_retries` instead', DeprecationWarning, stacklevel=2
377
- )
378
- output_retries = result_retries
379
-
380
312
  if mcp_servers := _deprecated_kwargs.pop('mcp_servers', None):
381
313
  if toolsets is not None: # pragma: no cover
382
314
  raise TypeError('`mcp_servers` and `toolsets` cannot be set at the same time.')
@@ -389,12 +321,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
389
321
  self.model.profile.default_structured_output_mode if isinstance(self.model, models.Model) else None
390
322
  )
391
323
 
392
- self._output_schema = _output.OutputSchema[OutputDataT].build(
393
- output_type,
394
- default_mode=default_output_mode,
395
- name=self._deprecated_result_tool_name,
396
- description=self._deprecated_result_tool_description,
397
- )
324
+ self._output_schema = _output.OutputSchema[OutputDataT].build(output_type, default_mode=default_output_mode)
398
325
  self._output_validators = []
399
326
 
400
327
  self._instructions = ''
@@ -472,23 +399,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
472
399
  toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
473
400
  ) -> AgentRunResult[RunOutputDataT]: ...
474
401
 
475
- @overload
476
- @deprecated('`result_type` is deprecated, use `output_type` instead.')
477
- async def run(
478
- self,
479
- user_prompt: str | Sequence[_messages.UserContent] | None = None,
480
- *,
481
- result_type: type[RunOutputDataT],
482
- message_history: list[_messages.ModelMessage] | None = None,
483
- model: models.Model | models.KnownModelName | str | None = None,
484
- deps: AgentDepsT = None,
485
- model_settings: ModelSettings | None = None,
486
- usage_limits: _usage.UsageLimits | None = None,
487
- usage: _usage.Usage | None = None,
488
- infer_name: bool = True,
489
- toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
490
- ) -> AgentRunResult[RunOutputDataT]: ...
491
-
492
402
  async def run(
493
403
  self,
494
404
  user_prompt: str | Sequence[_messages.UserContent] | None = None,
@@ -540,12 +450,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
540
450
  if infer_name and self.name is None:
541
451
  self._infer_name(inspect.currentframe())
542
452
 
543
- if 'result_type' in _deprecated_kwargs: # pragma: no cover
544
- if output_type is not str:
545
- raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
546
- warnings.warn('`result_type` is deprecated, use `output_type` instead.', DeprecationWarning, stacklevel=2)
547
- output_type = _deprecated_kwargs.pop('result_type')
548
-
549
453
  _utils.validate_empty_kwargs(_deprecated_kwargs)
550
454
 
551
455
  async with self.iter(
@@ -599,23 +503,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
599
503
  **_deprecated_kwargs: Never,
600
504
  ) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, RunOutputDataT]]: ...
601
505
 
602
- @overload
603
- @deprecated('`result_type` is deprecated, use `output_type` instead.')
604
- def iter(
605
- self,
606
- user_prompt: str | Sequence[_messages.UserContent] | None = None,
607
- *,
608
- result_type: type[RunOutputDataT],
609
- message_history: list[_messages.ModelMessage] | None = None,
610
- model: models.Model | models.KnownModelName | str | None = None,
611
- deps: AgentDepsT = None,
612
- model_settings: ModelSettings | None = None,
613
- usage_limits: _usage.UsageLimits | None = None,
614
- usage: _usage.Usage | None = None,
615
- infer_name: bool = True,
616
- toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
617
- ) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, Any]]: ...
618
-
619
506
  @asynccontextmanager
620
507
  async def iter(
621
508
  self,
@@ -714,12 +601,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
714
601
  model_used = self._get_model(model)
715
602
  del model
716
603
 
717
- if 'result_type' in _deprecated_kwargs: # pragma: no cover
718
- if output_type is not str:
719
- raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
720
- warnings.warn('`result_type` is deprecated, use `output_type` instead.', DeprecationWarning, stacklevel=2)
721
- output_type = _deprecated_kwargs.pop('result_type')
722
-
723
604
  _utils.validate_empty_kwargs(_deprecated_kwargs)
724
605
 
725
606
  deps = self._get_deps(deps)
@@ -910,23 +791,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
910
791
  toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
911
792
  ) -> AgentRunResult[RunOutputDataT]: ...
912
793
 
913
- @overload
914
- @deprecated('`result_type` is deprecated, use `output_type` instead.')
915
- def run_sync(
916
- self,
917
- user_prompt: str | Sequence[_messages.UserContent] | None = None,
918
- *,
919
- result_type: type[RunOutputDataT],
920
- message_history: list[_messages.ModelMessage] | None = None,
921
- model: models.Model | models.KnownModelName | str | None = None,
922
- deps: AgentDepsT = None,
923
- model_settings: ModelSettings | None = None,
924
- usage_limits: _usage.UsageLimits | None = None,
925
- usage: _usage.Usage | None = None,
926
- infer_name: bool = True,
927
- toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
928
- ) -> AgentRunResult[RunOutputDataT]: ...
929
-
930
794
  def run_sync(
931
795
  self,
932
796
  user_prompt: str | Sequence[_messages.UserContent] | None = None,
@@ -977,12 +841,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
977
841
  if infer_name and self.name is None:
978
842
  self._infer_name(inspect.currentframe())
979
843
 
980
- if 'result_type' in _deprecated_kwargs: # pragma: no cover
981
- if output_type is not str:
982
- raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
983
- warnings.warn('`result_type` is deprecated, use `output_type` instead.', DeprecationWarning, stacklevel=2)
984
- output_type = _deprecated_kwargs.pop('result_type')
985
-
986
844
  _utils.validate_empty_kwargs(_deprecated_kwargs)
987
845
 
988
846
  return get_event_loop().run_until_complete(
@@ -1031,25 +889,8 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
1031
889
  toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
1032
890
  ) -> AbstractAsyncContextManager[result.StreamedRunResult[AgentDepsT, RunOutputDataT]]: ...
1033
891
 
1034
- @overload
1035
- @deprecated('`result_type` is deprecated, use `output_type` instead.')
1036
- def run_stream(
1037
- self,
1038
- user_prompt: str | Sequence[_messages.UserContent] | None = None,
1039
- *,
1040
- result_type: type[RunOutputDataT],
1041
- message_history: list[_messages.ModelMessage] | None = None,
1042
- model: models.Model | models.KnownModelName | str | None = None,
1043
- deps: AgentDepsT = None,
1044
- model_settings: ModelSettings | None = None,
1045
- usage_limits: _usage.UsageLimits | None = None,
1046
- usage: _usage.Usage | None = None,
1047
- infer_name: bool = True,
1048
- toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
1049
- ) -> AbstractAsyncContextManager[result.StreamedRunResult[AgentDepsT, RunOutputDataT]]: ...
1050
-
1051
892
  @asynccontextmanager
1052
- async def run_stream( # noqa C901
893
+ async def run_stream(
1053
894
  self,
1054
895
  user_prompt: str | Sequence[_messages.UserContent] | None = None,
1055
896
  *,
@@ -1101,12 +942,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
1101
942
  if frame := inspect.currentframe(): # pragma: no branch
1102
943
  self._infer_name(frame.f_back)
1103
944
 
1104
- if 'result_type' in _deprecated_kwargs: # pragma: no cover
1105
- if output_type is not str:
1106
- raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
1107
- warnings.warn('`result_type` is deprecated, use `output_type` instead.', DeprecationWarning, stacklevel=2)
1108
- output_type = _deprecated_kwargs.pop('result_type')
1109
-
1110
945
  _utils.validate_empty_kwargs(_deprecated_kwargs)
1111
946
 
1112
947
  yielded = False
@@ -1431,13 +1266,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
1431
1266
  self._output_validators.append(_output.OutputValidator[AgentDepsT, Any](func))
1432
1267
  return func
1433
1268
 
1434
- @deprecated('`result_validator` is deprecated, use `output_validator` instead.')
1435
- def result_validator(self, func: Any, /) -> Any:
1436
- warnings.warn(
1437
- '`result_validator` is deprecated, use `output_validator` instead.', DeprecationWarning, stacklevel=2
1438
- )
1439
- return self.output_validator(func) # type: ignore
1440
-
1441
1269
  @overload
1442
1270
  def tool(self, func: ToolFuncContext[AgentDepsT, ToolParams], /) -> ToolFuncContext[AgentDepsT, ToolParams]: ...
1443
1271
 
@@ -1718,13 +1546,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
1718
1546
  self.name = name
1719
1547
  return
1720
1548
 
1721
- @property
1722
- @deprecated(
1723
- 'The `last_run_messages` attribute has been removed, use `capture_run_messages` instead.', category=None
1724
- )
1725
- def last_run_messages(self) -> list[_messages.ModelMessage]:
1726
- raise AttributeError('The `last_run_messages` attribute has been removed, use `capture_run_messages` instead.')
1727
-
1728
1549
  def _prepare_output_schema(
1729
1550
  self, output_type: OutputSpec[RunOutputDataT] | None, model_profile: ModelProfile
1730
1551
  ) -> _output.OutputSchema[RunOutputDataT]:
@@ -1732,10 +1553,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
1732
1553
  if self._output_validators:
1733
1554
  raise exceptions.UserError('Cannot set a custom run `output_type` when the agent has output validators')
1734
1555
  schema = _output.OutputSchema[RunOutputDataT].build(
1735
- output_type,
1736
- name=self._deprecated_result_tool_name,
1737
- description=self._deprecated_result_tool_description,
1738
- default_mode=model_profile.default_structured_output_mode,
1556
+ output_type, default_mode=model_profile.default_structured_output_mode
1739
1557
  )
1740
1558
  else:
1741
1559
  schema = self._output_schema.with_default_mode(model_profile.default_structured_output_mode)
@@ -2293,11 +2111,6 @@ class AgentRunResult(Generic[OutputDataT]):
2293
2111
  raise AttributeError('No span was created for this agent run')
2294
2112
  return self._traceparent_value
2295
2113
 
2296
- @property
2297
- @deprecated('`result.data` is deprecated, use `result.output` instead.')
2298
- def data(self) -> OutputDataT:
2299
- return self.output
2300
-
2301
2114
  def _set_output_tool_return(self, return_content: str) -> list[_messages.ModelMessage]:
2302
2115
  """Set return content for the output tool.
2303
2116
 
@@ -2319,16 +2132,7 @@ class AgentRunResult(Generic[OutputDataT]):
2319
2132
 
2320
2133
  raise LookupError(f'No tool call found with tool name {self._output_tool_name!r}.')
2321
2134
 
2322
- @overload
2323
- def all_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
2324
-
2325
- @overload
2326
- @deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
2327
- def all_messages(self, *, result_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
2328
-
2329
- def all_messages(
2330
- self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
2331
- ) -> list[_messages.ModelMessage]:
2135
+ def all_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]:
2332
2136
  """Return the history of _messages.
2333
2137
 
2334
2138
  Args:
@@ -2336,27 +2140,16 @@ class AgentRunResult(Generic[OutputDataT]):
2336
2140
  This provides a convenient way to modify the content of the output tool call if you want to continue
2337
2141
  the conversation and want to set the response to the output tool call. If `None`, the last message will
2338
2142
  not be modified.
2339
- result_tool_return_content: Deprecated, use `output_tool_return_content` instead.
2340
2143
 
2341
2144
  Returns:
2342
2145
  List of messages.
2343
2146
  """
2344
- content = result.coalesce_deprecated_return_content(output_tool_return_content, result_tool_return_content)
2345
- if content is not None:
2346
- return self._set_output_tool_return(content)
2147
+ if output_tool_return_content is not None:
2148
+ return self._set_output_tool_return(output_tool_return_content)
2347
2149
  else:
2348
2150
  return self._state.message_history
2349
2151
 
2350
- @overload
2351
- def all_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes: ...
2352
-
2353
- @overload
2354
- @deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
2355
- def all_messages_json(self, *, result_tool_return_content: str | None = None) -> bytes: ...
2356
-
2357
- def all_messages_json(
2358
- self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
2359
- ) -> bytes:
2152
+ def all_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes:
2360
2153
  """Return all messages from [`all_messages`][pydantic_ai.agent.AgentRunResult.all_messages] as JSON bytes.
2361
2154
 
2362
2155
  Args:
@@ -2364,24 +2157,15 @@ class AgentRunResult(Generic[OutputDataT]):
2364
2157
  This provides a convenient way to modify the content of the output tool call if you want to continue
2365
2158
  the conversation and want to set the response to the output tool call. If `None`, the last message will
2366
2159
  not be modified.
2367
- result_tool_return_content: Deprecated, use `output_tool_return_content` instead.
2368
2160
 
2369
2161
  Returns:
2370
2162
  JSON bytes representing the messages.
2371
2163
  """
2372
- content = result.coalesce_deprecated_return_content(output_tool_return_content, result_tool_return_content)
2373
- return _messages.ModelMessagesTypeAdapter.dump_json(self.all_messages(output_tool_return_content=content))
2374
-
2375
- @overload
2376
- def new_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
2377
-
2378
- @overload
2379
- @deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
2380
- def new_messages(self, *, result_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
2164
+ return _messages.ModelMessagesTypeAdapter.dump_json(
2165
+ self.all_messages(output_tool_return_content=output_tool_return_content)
2166
+ )
2381
2167
 
2382
- def new_messages(
2383
- self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
2384
- ) -> list[_messages.ModelMessage]:
2168
+ def new_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]:
2385
2169
  """Return new messages associated with this run.
2386
2170
 
2387
2171
  Messages from older runs are excluded.
@@ -2391,24 +2175,13 @@ class AgentRunResult(Generic[OutputDataT]):
2391
2175
  This provides a convenient way to modify the content of the output tool call if you want to continue
2392
2176
  the conversation and want to set the response to the output tool call. If `None`, the last message will
2393
2177
  not be modified.
2394
- result_tool_return_content: Deprecated, use `output_tool_return_content` instead.
2395
2178
 
2396
2179
  Returns:
2397
2180
  List of new messages.
2398
2181
  """
2399
- content = result.coalesce_deprecated_return_content(output_tool_return_content, result_tool_return_content)
2400
- return self.all_messages(output_tool_return_content=content)[self._new_message_index :]
2401
-
2402
- @overload
2403
- def new_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes: ...
2182
+ return self.all_messages(output_tool_return_content=output_tool_return_content)[self._new_message_index :]
2404
2183
 
2405
- @overload
2406
- @deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
2407
- def new_messages_json(self, *, result_tool_return_content: str | None = None) -> bytes: ...
2408
-
2409
- def new_messages_json(
2410
- self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
2411
- ) -> bytes:
2184
+ def new_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes:
2412
2185
  """Return new messages from [`new_messages`][pydantic_ai.agent.AgentRunResult.new_messages] as JSON bytes.
2413
2186
 
2414
2187
  Args:
@@ -2416,13 +2189,13 @@ class AgentRunResult(Generic[OutputDataT]):
2416
2189
  This provides a convenient way to modify the content of the output tool call if you want to continue
2417
2190
  the conversation and want to set the response to the output tool call. If `None`, the last message will
2418
2191
  not be modified.
2419
- result_tool_return_content: Deprecated, use `output_tool_return_content` instead.
2420
2192
 
2421
2193
  Returns:
2422
2194
  JSON bytes representing the new messages.
2423
2195
  """
2424
- content = result.coalesce_deprecated_return_content(output_tool_return_content, result_tool_return_content)
2425
- return _messages.ModelMessagesTypeAdapter.dump_json(self.new_messages(output_tool_return_content=content))
2196
+ return _messages.ModelMessagesTypeAdapter.dump_json(
2197
+ self.new_messages(output_tool_return_content=output_tool_return_content)
2198
+ )
2426
2199
 
2427
2200
  def usage(self) -> _usage.Usage:
2428
2201
  """Return the usage of the whole run."""
pydantic_ai/exceptions.py CHANGED
@@ -5,9 +5,9 @@ import sys
5
5
  from typing import TYPE_CHECKING
6
6
 
7
7
  if sys.version_info < (3, 11):
8
- from exceptiongroup import ExceptionGroup
8
+ from exceptiongroup import ExceptionGroup as ExceptionGroup # pragma: lax no cover
9
9
  else:
10
- ExceptionGroup = ExceptionGroup
10
+ ExceptionGroup = ExceptionGroup # pragma: lax no cover
11
11
 
12
12
  if TYPE_CHECKING:
13
13
  from .messages import RetryPromptPart
@@ -34,8 +34,6 @@ from ..usage import Usage
34
34
  KnownModelName = TypeAliasType(
35
35
  'KnownModelName',
36
36
  Literal[
37
- 'anthropic:claude-2.0',
38
- 'anthropic:claude-2.1',
39
37
  'anthropic:claude-3-5-haiku-20241022',
40
38
  'anthropic:claude-3-5-haiku-latest',
41
39
  'anthropic:claude-3-5-sonnet-20240620',
@@ -46,10 +44,10 @@ KnownModelName = TypeAliasType(
46
44
  'anthropic:claude-3-haiku-20240307',
47
45
  'anthropic:claude-3-opus-20240229',
48
46
  'anthropic:claude-3-opus-latest',
49
- 'anthropic:claude-3-sonnet-20240229',
50
47
  'anthropic:claude-4-opus-20250514',
51
48
  'anthropic:claude-4-sonnet-20250514',
52
49
  'anthropic:claude-opus-4-0',
50
+ 'anthropic:claude-opus-4-1-20250805',
53
51
  'anthropic:claude-opus-4-20250514',
54
52
  'anthropic:claude-sonnet-4-0',
55
53
  'anthropic:claude-sonnet-4-20250514',
@@ -100,8 +98,6 @@ KnownModelName = TypeAliasType(
100
98
  'bedrock:mistral.mixtral-8x7b-instruct-v0:1',
101
99
  'bedrock:mistral.mistral-large-2402-v1:0',
102
100
  'bedrock:mistral.mistral-large-2407-v1:0',
103
- 'claude-2.0',
104
- 'claude-2.1',
105
101
  'claude-3-5-haiku-20241022',
106
102
  'claude-3-5-haiku-latest',
107
103
  'claude-3-5-sonnet-20240620',
@@ -112,10 +108,10 @@ KnownModelName = TypeAliasType(
112
108
  'claude-3-haiku-20240307',
113
109
  'claude-3-opus-20240229',
114
110
  'claude-3-opus-latest',
115
- 'claude-3-sonnet-20240229',
116
111
  'claude-4-opus-20250514',
117
112
  'claude-4-sonnet-20250514',
118
113
  'claude-opus-4-0',
114
+ 'claude-opus-4-1-20250805',
119
115
  'claude-opus-4-20250514',
120
116
  'claude-sonnet-4-0',
121
117
  'claude-sonnet-4-20250514',
@@ -256,7 +256,7 @@ class AnthropicModel(Model):
256
256
  except APIStatusError as e:
257
257
  if (status_code := e.status_code) >= 400:
258
258
  raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
259
- raise # pragma: no cover
259
+ raise # pragma: lax no cover
260
260
 
261
261
  def _process_response(self, response: BetaMessage) -> ModelResponse:
262
262
  """Process a non-streamed response, and prepare a message to return."""
@@ -665,4 +665,4 @@ class _AsyncIteratorWrapper(Generic[T]):
665
665
  if type(e.__cause__) is StopIteration:
666
666
  raise StopAsyncIteration
667
667
  else:
668
- raise e # pragma: no cover
668
+ raise e # pragma: lax no cover
@@ -183,7 +183,7 @@ class CohereModel(Model):
183
183
  except ApiError as e:
184
184
  if (status_code := e.status_code) and status_code >= 400:
185
185
  raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
186
- raise # pragma: no cover
186
+ raise # pragma: lax no cover
187
187
 
188
188
  def _process_response(self, response: V2ChatResponse) -> ModelResponse:
189
189
  """Process a non-streamed response, and prepare a message to return."""
@@ -11,7 +11,7 @@ from uuid import uuid4
11
11
  import httpx
12
12
  import pydantic
13
13
  from httpx import USE_CLIENT_DEFAULT, Response as HTTPResponse
14
- from typing_extensions import NotRequired, TypedDict, assert_never
14
+ from typing_extensions import NotRequired, TypedDict, assert_never, deprecated
15
15
 
16
16
  from pydantic_ai.providers import Provider, infer_provider
17
17
 
@@ -92,6 +92,7 @@ class GeminiModelSettings(ModelSettings, total=False):
92
92
  """
93
93
 
94
94
 
95
+ @deprecated('Use `GoogleModel` instead. See <https://ai.pydantic.dev/models/google/> for more details.')
95
96
  @dataclass(init=False)
96
97
  class GeminiModel(Model):
97
98
  """A model that uses Gemini via `generativelanguage.googleapis.com` API.
@@ -236,7 +237,7 @@ class GeminiModel(Model):
236
237
 
237
238
  if gemini_labels := model_settings.get('gemini_labels'):
238
239
  if self._system == 'google-vertex':
239
- request_data['labels'] = gemini_labels
240
+ request_data['labels'] = gemini_labels # pragma: lax no cover
240
241
 
241
242
  headers = {'Content-Type': 'application/json', 'User-Agent': get_user_agent()}
242
243
  url = f'/{self._model_name}:{"streamGenerateContent" if streamed else "generateContent"}'
@@ -366,11 +367,11 @@ class GeminiModel(Model):
366
367
  inline_data={'data': downloaded_item['data'], 'mime_type': downloaded_item['data_type']}
367
368
  )
368
369
  content.append(inline_data)
369
- else:
370
+ else: # pragma: lax no cover
370
371
  file_data = _GeminiFileDataPart(file_data={'file_uri': item.url, 'mime_type': item.media_type})
371
372
  content.append(file_data)
372
373
  else:
373
- assert_never(item)
374
+ assert_never(item) # pragma: lax no cover
374
375
  return content
375
376
 
376
377
  def _map_response_schema(self, o: OutputObjectDefinition) -> dict[str, Any]:
@@ -407,7 +407,7 @@ class GoogleModel(Model):
407
407
  content.append(inline_data_dict) # type: ignore
408
408
  elif isinstance(item, VideoUrl) and item.is_youtube:
409
409
  file_data_dict = {'file_data': {'file_uri': item.url, 'mime_type': item.media_type}}
410
- if item.vendor_metadata:
410
+ if item.vendor_metadata: # pragma: no branch
411
411
  file_data_dict['video_metadata'] = item.vendor_metadata
412
412
  content.append(file_data_dict) # type: ignore
413
413
  elif isinstance(item, FileUrl):
@@ -421,7 +421,9 @@ class GoogleModel(Model):
421
421
  inline_data = {'data': downloaded_item['data'], 'mime_type': downloaded_item['data_type']}
422
422
  content.append({'inline_data': inline_data}) # type: ignore
423
423
  else:
424
- content.append({'file_data': {'file_uri': item.url, 'mime_type': item.media_type}})
424
+ content.append(
425
+ {'file_data': {'file_uri': item.url, 'mime_type': item.media_type}}
426
+ ) # pragma: lax no cover
425
427
  else:
426
428
  assert_never(item)
427
429
  return content
@@ -249,7 +249,7 @@ class GroqModel(Model):
249
249
  except APIStatusError as e:
250
250
  if (status_code := e.status_code) >= 400:
251
251
  raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
252
- raise # pragma: no cover
252
+ raise # pragma: lax no cover
253
253
 
254
254
  def _process_response(self, response: chat.ChatCompletion) -> ModelResponse:
255
255
  """Process a non-streamed response, and prepare a message to return."""
@@ -18,11 +18,7 @@ from opentelemetry.trace import Span, Tracer, TracerProvider, get_tracer_provide
18
18
  from opentelemetry.util.types import AttributeValue
19
19
  from pydantic import TypeAdapter
20
20
 
21
- from ..messages import (
22
- ModelMessage,
23
- ModelRequest,
24
- ModelResponse,
25
- )
21
+ from ..messages import ModelMessage, ModelRequest, ModelResponse
26
22
  from ..settings import ModelSettings
27
23
  from . import KnownModelName, Model, ModelRequestParameters, StreamedResponse
28
24
  from .wrapper import WrapperModel
@@ -138,7 +134,7 @@ class InstrumentationSettings:
138
134
  **tokens_histogram_kwargs,
139
135
  explicit_bucket_boundaries_advisory=TOKEN_HISTOGRAM_BOUNDARIES,
140
136
  )
141
- except TypeError:
137
+ except TypeError: # pragma: lax no cover
142
138
  # Older OTel/logfire versions don't support explicit_bucket_boundaries_advisory
143
139
  self.tokens_histogram = self.meter.create_histogram(
144
140
  **tokens_histogram_kwargs, # pyright: ignore
@@ -218,7 +218,7 @@ class MistralModel(Model):
218
218
  except SDKError as e:
219
219
  if (status_code := e.status_code) >= 400:
220
220
  raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
221
- raise # pragma: no cover
221
+ raise # pragma: lax no cover
222
222
 
223
223
  assert response, 'A unexpected empty response from Mistral.'
224
224
  return response
@@ -359,7 +359,7 @@ class OpenAIModel(Model):
359
359
  except APIStatusError as e:
360
360
  if (status_code := e.status_code) >= 400:
361
361
  raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
362
- raise # pragma: no cover
362
+ raise # pragma: lax no cover
363
363
 
364
364
  def _process_response(self, response: chat.ChatCompletion | str) -> ModelResponse:
365
365
  """Process a non-streamed response, and prepare a message to return."""
@@ -814,7 +814,7 @@ class OpenAIResponsesModel(Model):
814
814
  except APIStatusError as e:
815
815
  if (status_code := e.status_code) >= 400:
816
816
  raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
817
- raise # pragma: no cover
817
+ raise # pragma: lax no cover
818
818
 
819
819
  def _get_reasoning(self, model_settings: OpenAIResponsesModelSettings) -> Reasoning | NotGiven:
820
820
  reasoning_effort = model_settings.get('openai_reasoning_effort', None)
@@ -137,8 +137,9 @@ class JsonSchemaTransformer(ABC):
137
137
  return schema
138
138
 
139
139
  def _handle_union(self, schema: JsonSchema, union_kind: Literal['anyOf', 'oneOf']) -> JsonSchema:
140
- members = schema.get(union_kind)
141
- if not members:
140
+ try:
141
+ members = schema.pop(union_kind)
142
+ except KeyError:
142
143
  return schema
143
144
 
144
145
  handled = [self._handle(member) for member in members]
@@ -149,7 +150,7 @@ class JsonSchemaTransformer(ABC):
149
150
 
150
151
  if len(handled) == 1:
151
152
  # In this case, no need to retain the union
152
- return handled[0]
153
+ return handled[0] | schema
153
154
 
154
155
  # If we have keys besides the union kind (such as title or discriminator), keep them without modifications
155
156
  schema = schema.copy()
@@ -71,13 +71,13 @@ def infer_provider_class(provider: str) -> type[Provider[Any]]: # noqa: C901
71
71
 
72
72
  return AzureProvider
73
73
  elif provider == 'google-vertex':
74
- from .google_vertex import GoogleVertexProvider
74
+ from .google_vertex import GoogleVertexProvider # type: ignore[reportDeprecated]
75
75
 
76
- return GoogleVertexProvider
76
+ return GoogleVertexProvider # type: ignore[reportDeprecated]
77
77
  elif provider == 'google-gla':
78
- from .google_gla import GoogleGLAProvider
78
+ from .google_gla import GoogleGLAProvider # type: ignore[reportDeprecated]
79
79
 
80
- return GoogleGLAProvider
80
+ return GoogleGLAProvider # type: ignore[reportDeprecated]
81
81
  # NOTE: We don't test because there are many ways the `boto3.client` can retrieve the credentials.
82
82
  elif provider == 'bedrock':
83
83
  from .bedrock import BedrockProvider
@@ -3,6 +3,8 @@ from __future__ import annotations as _annotations
3
3
  import os
4
4
  from typing import Literal, overload
5
5
 
6
+ import httpx
7
+
6
8
  from pydantic_ai.exceptions import UserError
7
9
  from pydantic_ai.models import get_user_agent
8
10
  from pydantic_ai.profiles import ModelProfile
@@ -12,6 +14,7 @@ from pydantic_ai.providers import Provider
12
14
  try:
13
15
  from google import genai
14
16
  from google.auth.credentials import Credentials
17
+ from google.genai.types import HttpOptionsDict
15
18
  except ImportError as _import_error:
16
19
  raise ImportError(
17
20
  'Please install the `google-genai` package to use the Google provider, '
@@ -89,17 +92,17 @@ class GoogleProvider(Provider[genai.Client]):
89
92
  if vertexai is None:
90
93
  vertexai = bool(location or project or credentials)
91
94
 
95
+ http_options: HttpOptionsDict = {
96
+ 'headers': {'User-Agent': get_user_agent()},
97
+ 'async_client_args': {'transport': httpx.AsyncHTTPTransport()},
98
+ }
92
99
  if not vertexai:
93
100
  if api_key is None:
94
101
  raise UserError( # pragma: no cover
95
102
  'Set the `GOOGLE_API_KEY` environment variable or pass it via `GoogleProvider(api_key=...)`'
96
103
  'to use the Google Generative Language API.'
97
104
  )
98
- self._client = genai.Client(
99
- vertexai=vertexai,
100
- api_key=api_key,
101
- http_options={'headers': {'User-Agent': get_user_agent()}},
102
- )
105
+ self._client = genai.Client(vertexai=vertexai, api_key=api_key, http_options=http_options)
103
106
  else:
104
107
  self._client = genai.Client(
105
108
  vertexai=vertexai,
@@ -111,7 +114,7 @@ class GoogleProvider(Provider[genai.Client]):
111
114
  # For more details, check: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations#available-regions
112
115
  location=location or os.environ.get('GOOGLE_CLOUD_LOCATION') or 'us-central1',
113
116
  credentials=credentials,
114
- http_options={'headers': {'User-Agent': get_user_agent()}},
117
+ http_options=http_options,
115
118
  )
116
119
  else:
117
120
  self._client = client
@@ -3,6 +3,7 @@ from __future__ import annotations as _annotations
3
3
  import os
4
4
 
5
5
  import httpx
6
+ from typing_extensions import deprecated
6
7
 
7
8
  from pydantic_ai.exceptions import UserError
8
9
  from pydantic_ai.models import cached_async_http_client
@@ -11,6 +12,7 @@ from pydantic_ai.profiles.google import google_model_profile
11
12
  from pydantic_ai.providers import Provider
12
13
 
13
14
 
15
+ @deprecated('`GoogleGLAProvider` is deprecated, use `GoogleProvider` with `GoogleModel` instead.')
14
16
  class GoogleGLAProvider(Provider[httpx.AsyncClient]):
15
17
  """Provider for Google Generative Language AI API."""
16
18
 
@@ -7,6 +7,7 @@ from typing import Literal, overload
7
7
 
8
8
  import anyio.to_thread
9
9
  import httpx
10
+ from typing_extensions import deprecated
10
11
 
11
12
  from pydantic_ai.exceptions import UserError
12
13
  from pydantic_ai.models import cached_async_http_client
@@ -29,6 +30,7 @@ except ImportError as _import_error:
29
30
  __all__ = ('GoogleVertexProvider',)
30
31
 
31
32
 
33
+ @deprecated('`GoogleVertexProvider` is deprecated, use `GoogleProvider` with `GoogleModel` instead.')
32
34
  class GoogleVertexProvider(Provider[httpx.AsyncClient]):
33
35
  """Provider for Vertex AI API."""
34
36
 
pydantic_ai/result.py CHANGED
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations as _annotations
2
2
 
3
- import warnings
4
3
  from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable
5
4
  from copy import copy
6
5
  from dataclasses import dataclass, field
@@ -8,7 +7,7 @@ from datetime import datetime
8
7
  from typing import Generic, cast
9
8
 
10
9
  from pydantic import ValidationError
11
- from typing_extensions import TypeVar, deprecated, overload
10
+ from typing_extensions import TypeVar
12
11
 
13
12
  from pydantic_ai._tool_manager import ToolManager
14
13
 
@@ -291,16 +290,7 @@ class StreamedRunResult(Generic[AgentDepsT, OutputDataT]):
291
290
  [`get_output`][pydantic_ai.result.StreamedRunResult.get_output] completes.
292
291
  """
293
292
 
294
- @overload
295
- def all_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
296
-
297
- @overload
298
- @deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
299
- def all_messages(self, *, result_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
300
-
301
- def all_messages(
302
- self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
303
- ) -> list[_messages.ModelMessage]:
293
+ def all_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]:
304
294
  """Return the history of _messages.
305
295
 
306
296
  Args:
@@ -308,27 +298,16 @@ class StreamedRunResult(Generic[AgentDepsT, OutputDataT]):
308
298
  This provides a convenient way to modify the content of the output tool call if you want to continue
309
299
  the conversation and want to set the response to the output tool call. If `None`, the last message will
310
300
  not be modified.
311
- result_tool_return_content: deprecated, use `output_tool_return_content` instead.
312
301
 
313
302
  Returns:
314
303
  List of messages.
315
304
  """
316
305
  # this is a method to be consistent with the other methods
317
- content = coalesce_deprecated_return_content(output_tool_return_content, result_tool_return_content)
318
- if content is not None:
306
+ if output_tool_return_content is not None:
319
307
  raise NotImplementedError('Setting output tool return content is not supported for this result type.')
320
308
  return self._all_messages
321
309
 
322
- @overload
323
- def all_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes: ...
324
-
325
- @overload
326
- @deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
327
- def all_messages_json(self, *, result_tool_return_content: str | None = None) -> bytes: ...
328
-
329
- def all_messages_json(
330
- self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
331
- ) -> bytes: # pragma: no cover
310
+ def all_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes: # pragma: no cover
332
311
  """Return all messages from [`all_messages`][pydantic_ai.result.StreamedRunResult.all_messages] as JSON bytes.
333
312
 
334
313
  Args:
@@ -336,23 +315,16 @@ class StreamedRunResult(Generic[AgentDepsT, OutputDataT]):
336
315
  This provides a convenient way to modify the content of the output tool call if you want to continue
337
316
  the conversation and want to set the response to the output tool call. If `None`, the last message will
338
317
  not be modified.
339
- result_tool_return_content: deprecated, use `output_tool_return_content` instead.
340
318
 
341
319
  Returns:
342
320
  JSON bytes representing the messages.
343
321
  """
344
- content = coalesce_deprecated_return_content(output_tool_return_content, result_tool_return_content)
345
- return _messages.ModelMessagesTypeAdapter.dump_json(self.all_messages(output_tool_return_content=content))
346
-
347
- @overload
348
- def new_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
349
-
350
- @overload
351
- @deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
352
- def new_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
322
+ return _messages.ModelMessagesTypeAdapter.dump_json(
323
+ self.all_messages(output_tool_return_content=output_tool_return_content)
324
+ )
353
325
 
354
326
  def new_messages(
355
- self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
327
+ self, *, output_tool_return_content: str | None = None
356
328
  ) -> list[_messages.ModelMessage]: # pragma: no cover
357
329
  """Return new messages associated with this run.
358
330
 
@@ -363,24 +335,13 @@ class StreamedRunResult(Generic[AgentDepsT, OutputDataT]):
363
335
  This provides a convenient way to modify the content of the output tool call if you want to continue
364
336
  the conversation and want to set the response to the output tool call. If `None`, the last message will
365
337
  not be modified.
366
- result_tool_return_content: deprecated, use `output_tool_return_content` instead.
367
338
 
368
339
  Returns:
369
340
  List of new messages.
370
341
  """
371
- content = coalesce_deprecated_return_content(output_tool_return_content, result_tool_return_content)
372
- return self.all_messages(output_tool_return_content=content)[self._new_message_index :]
373
-
374
- @overload
375
- def new_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes: ...
376
-
377
- @overload
378
- @deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
379
- def new_messages_json(self, *, result_tool_return_content: str | None = None) -> bytes: ...
342
+ return self.all_messages(output_tool_return_content=output_tool_return_content)[self._new_message_index :]
380
343
 
381
- def new_messages_json(
382
- self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
383
- ) -> bytes: # pragma: no cover
344
+ def new_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes: # pragma: no cover
384
345
  """Return new messages from [`new_messages`][pydantic_ai.result.StreamedRunResult.new_messages] as JSON bytes.
385
346
 
386
347
  Args:
@@ -388,13 +349,13 @@ class StreamedRunResult(Generic[AgentDepsT, OutputDataT]):
388
349
  This provides a convenient way to modify the content of the output tool call if you want to continue
389
350
  the conversation and want to set the response to the output tool call. If `None`, the last message will
390
351
  not be modified.
391
- result_tool_return_content: deprecated, use `output_tool_return_content` instead.
392
352
 
393
353
  Returns:
394
354
  JSON bytes representing the new messages.
395
355
  """
396
- content = coalesce_deprecated_return_content(output_tool_return_content, result_tool_return_content)
397
- return _messages.ModelMessagesTypeAdapter.dump_json(self.new_messages(output_tool_return_content=content))
356
+ return _messages.ModelMessagesTypeAdapter.dump_json(
357
+ self.new_messages(output_tool_return_content=output_tool_return_content)
358
+ )
398
359
 
399
360
  async def stream(self, *, debounce_by: float | None = 0.1) -> AsyncIterator[OutputDataT]:
400
361
  """Stream the response as an async iterable.
@@ -460,10 +421,6 @@ class StreamedRunResult(Generic[AgentDepsT, OutputDataT]):
460
421
  await self._marked_completed(self._stream_response.get())
461
422
  return output
462
423
 
463
- @deprecated('`get_data` is deprecated, use `get_output` instead.')
464
- async def get_data(self) -> OutputDataT:
465
- return await self.get_output()
466
-
467
424
  def usage(self) -> Usage:
468
425
  """Return the usage of the whole run.
469
426
 
@@ -476,12 +433,6 @@ class StreamedRunResult(Generic[AgentDepsT, OutputDataT]):
476
433
  """Get the timestamp of the response."""
477
434
  return self._stream_response.timestamp()
478
435
 
479
- @deprecated('`validate_structured_result` is deprecated, use `validate_structured_output` instead.')
480
- async def validate_structured_result(
481
- self, message: _messages.ModelResponse, *, allow_partial: bool = False
482
- ) -> OutputDataT:
483
- return await self.validate_structured_output(message, allow_partial=allow_partial)
484
-
485
436
  async def validate_structured_output(
486
437
  self, message: _messages.ModelResponse, *, allow_partial: bool = False
487
438
  ) -> OutputDataT:
@@ -507,11 +458,6 @@ class FinalResult(Generic[OutputDataT]):
507
458
  tool_call_id: str | None = None
508
459
  """ID of the tool call that produced the final output; `None` if the output came from unstructured text content."""
509
460
 
510
- @property
511
- @deprecated('`data` is deprecated, use `output` instead.')
512
- def data(self) -> OutputDataT:
513
- return self.output
514
-
515
461
  __repr__ = _utils.dataclasses_no_defaults_repr
516
462
 
517
463
 
@@ -530,18 +476,3 @@ def _get_usage_checking_stream_response(
530
476
  return _usage_checking_iterator()
531
477
  else:
532
478
  return stream_response
533
-
534
-
535
- def coalesce_deprecated_return_content(
536
- output_tool_return_content: T | None, result_tool_return_content: T | None
537
- ) -> T | None:
538
- """Return the first non-None value."""
539
- if output_tool_return_content is None:
540
- if result_tool_return_content is not None: # pragma: no cover
541
- warnings.warn(
542
- '`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.',
543
- DeprecationWarning,
544
- stacklevel=3,
545
- )
546
- return result_tool_return_content
547
- return output_tool_return_content
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydantic-ai-slim
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Agent Framework / shim to use Pydantic with LLMs, slim package
5
5
  Author-email: Samuel Colvin <samuel@pydantic.dev>, Marcelo Trylesinski <marcelotryle@gmail.com>, David Montague <david@pydantic.dev>, Alex Hall <alex@pydantic.dev>, Douwe Maan <douwe@pydantic.dev>
6
6
  License-Expression: MIT
@@ -30,7 +30,7 @@ Requires-Dist: exceptiongroup; python_version < '3.11'
30
30
  Requires-Dist: griffe>=1.3.2
31
31
  Requires-Dist: httpx>=0.27
32
32
  Requires-Dist: opentelemetry-api>=1.28.0
33
- Requires-Dist: pydantic-graph==0.5.0
33
+ Requires-Dist: pydantic-graph==0.6.0
34
34
  Requires-Dist: pydantic>=2.10
35
35
  Requires-Dist: typing-inspection>=0.4.0
36
36
  Provides-Extra: a2a
@@ -39,7 +39,7 @@ Provides-Extra: ag-ui
39
39
  Requires-Dist: ag-ui-protocol>=0.1.8; extra == 'ag-ui'
40
40
  Requires-Dist: starlette>=0.45.3; extra == 'ag-ui'
41
41
  Provides-Extra: anthropic
42
- Requires-Dist: anthropic>=0.52.0; extra == 'anthropic'
42
+ Requires-Dist: anthropic>=0.61.0; extra == 'anthropic'
43
43
  Provides-Extra: bedrock
44
44
  Requires-Dist: boto3>=1.37.24; extra == 'bedrock'
45
45
  Provides-Extra: cli
@@ -51,9 +51,9 @@ Requires-Dist: cohere>=5.16.0; (platform_system != 'Emscripten') and extra == 'c
51
51
  Provides-Extra: duckduckgo
52
52
  Requires-Dist: ddgs>=9.0.0; extra == 'duckduckgo'
53
53
  Provides-Extra: evals
54
- Requires-Dist: pydantic-evals==0.5.0; extra == 'evals'
54
+ Requires-Dist: pydantic-evals==0.6.0; extra == 'evals'
55
55
  Provides-Extra: google
56
- Requires-Dist: google-genai>=1.24.0; extra == 'google'
56
+ Requires-Dist: google-genai>=1.28.0; extra == 'google'
57
57
  Provides-Extra: groq
58
58
  Requires-Dist: groq>=0.19.0; extra == 'groq'
59
59
  Provides-Extra: huggingface
@@ -1,7 +1,7 @@
1
1
  pydantic_ai/__init__.py,sha256=h6Rll8pEzUUUX6SckosummoAFbq7ctfBlI6WSyaXR4I,1300
2
2
  pydantic_ai/__main__.py,sha256=Q_zJU15DUA01YtlJ2mnaLCoId2YmgmreVEERGuQT-Y0,132
3
3
  pydantic_ai/_a2a.py,sha256=Tw_j9VRud0rLEk5kRs4GhRyhWYioXnsoZaTTyISq4M4,12126
4
- pydantic_ai/_agent_graph.py,sha256=-D_X7qyg4fHRbgR9ffKM_FU4KZ3qas-YgVvSmS0eXeI,37347
4
+ pydantic_ai/_agent_graph.py,sha256=ineJtkOyBzFhu0GVBiRxsQT6yEVE6oHyp3d7xHV2XG8,37351
5
5
  pydantic_ai/_cli.py,sha256=YkiW2u9HGPd9fsgo9dpK1DZvtUPk4uXGQJcm75XgfhU,13250
6
6
  pydantic_ai/_function_schema.py,sha256=YFHxb6bKfhgeY6rNdbuYXgndGCDanveUx2258xkSNlQ,11233
7
7
  pydantic_ai/_griffe.py,sha256=Ugft16ZHw9CN_6-lW0Svn6jESK9zHXO_x4utkGBkbBI,5253
@@ -14,16 +14,15 @@ pydantic_ai/_thinking_part.py,sha256=x80-Vkon16GOyq3W6f2qzafTVPC5dCgF7QD3k8ZMmYU
14
14
  pydantic_ai/_tool_manager.py,sha256=BdjPntbSshNvYVpYZUNxb-yib5n4GPqcDinbNpzhBVo,8960
15
15
  pydantic_ai/_utils.py,sha256=0Pte4mjir4YFZJTa6i-H6Cra9NbVwSKjOKegArzUggk,16283
16
16
  pydantic_ai/ag_ui.py,sha256=snIBVMcUUm3WWZ5P5orikyAzvM-7vGunNMgIudhvK-A,26156
17
- pydantic_ai/agent.py,sha256=VJOvadfilVm60BxWqxtXrzmNTnN8tuhapvFk2r13RO4,107234
17
+ pydantic_ai/agent.py,sha256=qFxTtf98oUX59ARP5FQub-lwpClCldXJEBS6-vi_0nM,95777
18
18
  pydantic_ai/direct.py,sha256=WRfgke3zm-eeR39LTuh9XI2TrdHXAqO81eDvFwih4Ko,14803
19
- pydantic_ai/exceptions.py,sha256=o0l6fBrWI5UhosICVZ2yaT-JEJF05eqBlKlQCW8i9UM,3462
20
- pydantic_ai/format_as_xml.py,sha256=IINfh1evWDphGahqHNLBArB5dQ4NIqS3S-kru35ztGg,372
19
+ pydantic_ai/exceptions.py,sha256=vHRH_b6JpMi5p5EGhz2O4FSeKGJv3WMD291Y1FjHYFc,3528
21
20
  pydantic_ai/format_prompt.py,sha256=Or-Ytq55RQb1UJqy2HKIyPpZ-knWXfdDP3Z6tNc6Orw,4244
22
21
  pydantic_ai/mcp.py,sha256=v_f4CRzJ399uPC96aqTiEzpaYvuo6vIQyLIpXQBudsY,26271
23
22
  pydantic_ai/messages.py,sha256=OfaGM4AfMNTQJOCNJWDB1dVtMlLhPh2vzufCOPx2vjI,43767
24
23
  pydantic_ai/output.py,sha256=54Cwd1RruXlA5hucZ1h-SxFrzKHJuLvYvLtH9iyg2GI,11988
25
24
  pydantic_ai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- pydantic_ai/result.py,sha256=bFo2oQZiSw1wvpa6k3rZ3ae2KhzoiQno0F8glKWpvgg,25328
25
+ pydantic_ai/result.py,sha256=N9YJ8WshUUyLgdbDVivmhgn8e6NPqFH9JQjEoR2_J9E,21767
27
26
  pydantic_ai/retries.py,sha256=Xkj-gZAd3wc12CVsIErVYx2EIdIwD5yJOL4Ou6jDQ2s,10498
28
27
  pydantic_ai/settings.py,sha256=yuUZ7-GkdPB-Gbx71kSdh8dSr6gwM9gEwk84qNxPO_I,3552
29
28
  pydantic_ai/tools.py,sha256=4UNpllVugXaJWLlehVgjoOyM-r4jy4vJ7uSUSbsPBiQ,14765
@@ -34,24 +33,24 @@ pydantic_ai/common_tools/tavily.py,sha256=Q1xxSF5HtXAaZ10Pp-OaDOHXwJf2mco9wScGEQ
34
33
  pydantic_ai/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
34
  pydantic_ai/ext/aci.py,sha256=vUaNIj6pRM52x6RkPW_DohSYxJPm75pPUfOMw2i5Xx0,2515
36
35
  pydantic_ai/ext/langchain.py,sha256=GemxfhpyG1JPxj69PbRiSJANnY8Q5s4hSB7wqt-uTbo,2266
37
- pydantic_ai/models/__init__.py,sha256=UDi-zXjRt_Zb8kaN5OKMxGXnJtDkROpfa66tSz_wNdI,30884
38
- pydantic_ai/models/anthropic.py,sha256=dMPFqIeYCIhoeU_4uk9PmZYQWL1NbkSVmVrBKXplTiI,24167
39
- pydantic_ai/models/bedrock.py,sha256=O6wKZDu4L18L1L2Nsa-XMW4ch073FjcLKRA5t_NXcHU,29511
40
- pydantic_ai/models/cohere.py,sha256=GYhQ6jkCYDHf3ca1835aig9o59XTvsyw4ISAVThYejA,12828
36
+ pydantic_ai/models/__init__.py,sha256=Td74RbYGF7bOdG2zJGKAC4rfEQtJunf86xv-s3Ylh3A,30776
37
+ pydantic_ai/models/anthropic.py,sha256=WtugATjLkmuNMtOeitKPNDjc6iE5NO_UxBKisHL_JNY,24171
38
+ pydantic_ai/models/bedrock.py,sha256=AJqZVU5gsTCcdHx37RhDrQAODKswpTlKzl4pd3Gi5CE,29515
39
+ pydantic_ai/models/cohere.py,sha256=DnIbZuUP3LuJ7FS0KYqt3BU3blyG3Xs44XqhSshvhI4,12832
41
40
  pydantic_ai/models/fallback.py,sha256=URaV-dTQWkg99xrlkmknue5lXZWDcEt7cJ1Vsky4oB4,5130
42
41
  pydantic_ai/models/function.py,sha256=iHhG6GYN14XDo3_qbdliv_umY10B7-k11aoDoVF4xP8,13563
43
- pydantic_ai/models/gemini.py,sha256=J-05fngctXSqk3NzLaemt0h6r3S6jmr9ArvlWQE5Q0A,38124
44
- pydantic_ai/models/google.py,sha256=PNN5Z5VYPioT0-FzS4PoZ33es26AfUqwMBLfHhrElnw,24380
45
- pydantic_ai/models/groq.py,sha256=JX3Hi8tUJTsTj2A6CGoDhpW4IwNUxgOk0Ta58OCEL_A,19035
42
+ pydantic_ai/models/gemini.py,sha256=dRN50u8I0PMy-GwVrPn4M4qzfYTMO6dCKksBXaC6Fxc,38313
43
+ pydantic_ai/models/google.py,sha256=ZjU2qjdtf8jNWoeswS13g198lamzsBr5K0QuX0QcLzM,24479
44
+ pydantic_ai/models/groq.py,sha256=RQzehpgBRaY0Nit7b4LW-lOrNA3qYHpiUpodn0YjjfE,19039
46
45
  pydantic_ai/models/huggingface.py,sha256=g4Z2C_e_OddYyGKLSOtP4nCL-AbWxmOdkW4zFcFtLq0,19222
47
- pydantic_ai/models/instrumented.py,sha256=aqvzspcGexn1Molbu6Mn4EEPRBSoQCCCS_yknJvJJ-8,16205
46
+ pydantic_ai/models/instrumented.py,sha256=j6zFwfF_xxog2OrU2xaObBRkc0wyGqjIqFIMv7cxqmI,16212
48
47
  pydantic_ai/models/mcp_sampling.py,sha256=q9nnjNEAAbhrfRc_Qw5z9TtCHMG_SwlCWW9FvKWjh8k,3395
49
- pydantic_ai/models/mistral.py,sha256=bj56Meckuji8r4vowiFJMDSli-HZktocqSqtbzgpXa0,31455
50
- pydantic_ai/models/openai.py,sha256=Soqb7kZpQLBS6En7hVlhzBMlS07rjISJ9IlH96bBBBU,56122
48
+ pydantic_ai/models/mistral.py,sha256=rGhIHl2fS2LIJWzXNwYZTw2ZGJviF4Rfr36wS7mlcNc,31459
49
+ pydantic_ai/models/openai.py,sha256=d7KCXaPl0txvJ3647USvFM-8T-iF5ue1XpXlo-IwHIg,56130
51
50
  pydantic_ai/models/test.py,sha256=lGMblastixKF_f5MhP3TcvLWx7jj94H4ohmL7DMpdGo,18482
52
51
  pydantic_ai/models/wrapper.py,sha256=A5-ncYhPF8c9S_czGoXkd55s2KOQb65p3jbVpwZiFPA,2043
53
52
  pydantic_ai/profiles/__init__.py,sha256=uC1_64Pb0O1IMt_SwzvU3W7a2_T3pvdoSDcm8_WI7hw,2592
54
- pydantic_ai/profiles/_json_schema.py,sha256=sTNHkaK0kbwmbldZp9JRGQNax0f5Qvwy0HkWuu_nGxU,7179
53
+ pydantic_ai/profiles/_json_schema.py,sha256=CthOGmPSjgEZRRglfvg31zyQ9vjHDdacXoFpmba93dE,7206
55
54
  pydantic_ai/profiles/amazon.py,sha256=O4ijm1Lpz01vaSiHrkSeGQhbCKV5lyQVtHYqh0pCW_k,339
56
55
  pydantic_ai/profiles/anthropic.py,sha256=J9N46G8eOjHdQ5CwZSLiwGdPb0eeIMdsMjwosDpvNhI,275
57
56
  pydantic_ai/profiles/cohere.py,sha256=lcL34Ht1jZopwuqoU6OV9l8vN4zwF-jiPjlsEABbSRo,215
@@ -63,7 +62,7 @@ pydantic_ai/profiles/mistral.py,sha256=ll01PmcK3szwlTfbaJLQmfd0TADN8lqjov9HpPJzC
63
62
  pydantic_ai/profiles/moonshotai.py,sha256=LL5RacKHKn6rdvhoKjpGgZ8aVriv5NMeL6HCWEANAiU,223
64
63
  pydantic_ai/profiles/openai.py,sha256=80ffJK9T7YbBRR7mhyRkjDB29pYi2H4dIQOAmIr5Ppc,7530
65
64
  pydantic_ai/profiles/qwen.py,sha256=u7pL8uomoQTVl45g5wDrHx0P_oFDLaN6ALswuwmkWc0,334
66
- pydantic_ai/providers/__init__.py,sha256=6Jm4ioGiI5jcwKUC2Yxv-GHdrK3ZTJmb-9_eHBZgfdw,4005
65
+ pydantic_ai/providers/__init__.py,sha256=yxPgiTJKFYZbDW18tmVM6mmD2Znol3WwniwnhtlN0Ak,4141
67
66
  pydantic_ai/providers/anthropic.py,sha256=D35UXxCPXv8yIbD0fj9Zg2FvNyoMoJMeDUtVM8Sn78I,3046
68
67
  pydantic_ai/providers/azure.py,sha256=y77IHGiSQ9Ttx9f4SGMgdpin2Daq6eYyzUdM9ET22RQ,5819
69
68
  pydantic_ai/providers/bedrock.py,sha256=ycdTXnkj_WNqPMA7DNDPeYia0C37FP0_l0CygSQmWYI,5694
@@ -71,9 +70,9 @@ pydantic_ai/providers/cohere.py,sha256=LT6QaLPJBBlFUgYgXQOfKpbM9SXLzorWFxI7jNfOX
71
70
  pydantic_ai/providers/deepseek.py,sha256=kUdM8eVp1lse4bS_uy70Gy7wgog94NTZ36GY-vhSB50,3060
72
71
  pydantic_ai/providers/fireworks.py,sha256=TPbqOpNgXG59qovBaHWbbV2vsvROwlHwQ3PvqHUBH-s,3626
73
72
  pydantic_ai/providers/github.py,sha256=zPu3oVJKjUE4zIqZ0YfgcTFBNdEy5rIBrSOdPCHJEG4,4406
74
- pydantic_ai/providers/google.py,sha256=b8MOCsawPm07HrFEZGip5OGzW3zfq3HcCDzDNwXgPY4,5946
75
- pydantic_ai/providers/google_gla.py,sha256=BCF5_6EVtpkCZ6qIDuvgY1Qa9EirS71l51CBqPqk4C4,1825
76
- pydantic_ai/providers/google_vertex.py,sha256=MN3hnZg06pp2VFAmr3o_aAeop7LHj8TbgPSaF5D6PZE,9596
73
+ pydantic_ai/providers/google.py,sha256=iyAqYB-Rcpy6Rea-QfS_FL1v6ej-DZpGx-rPY3X_df0,6067
74
+ pydantic_ai/providers/google_gla.py,sha256=dLkDxps5gEtxsQiDbs1e88lXLYeX4i2qnJtDiFFJ0Ng,1965
75
+ pydantic_ai/providers/google_vertex.py,sha256=9wJGctzQTEtmTTr3KCFAubDREMQJ4zOXt9k52F8R8Zs,9739
77
76
  pydantic_ai/providers/grok.py,sha256=dIkpxuuJlZ4pFtTSgeeJgiM_Z3mJU9qvk4f7jvSzi24,3141
78
77
  pydantic_ai/providers/groq.py,sha256=hqcR-RFHHHeemYP3K16IFeQTJKywNEU2wNZOSGTz6fE,3957
79
78
  pydantic_ai/providers/heroku.py,sha256=NmDIkAdxtWsvCjlX-bKI5FgI4HW1zO9-e0mrNQNGMCk,2990
@@ -94,8 +93,8 @@ pydantic_ai/toolsets/prefixed.py,sha256=MIStkzUdiU0rk2Y6P19IrTBxspH5pTstGxsqCBt-
94
93
  pydantic_ai/toolsets/prepared.py,sha256=Zjfz6S8In6PBVxoKFN9sKPN984zO6t0awB7Lnq5KODw,1431
95
94
  pydantic_ai/toolsets/renamed.py,sha256=JuLHpi-hYPiSPlaTpN8WiXLiGsywYK0axi2lW2Qs75k,1637
96
95
  pydantic_ai/toolsets/wrapper.py,sha256=WjLoiM1WDuffSJ4mDS6pZrEZGHgZ421fjrqFcB66W94,1205
97
- pydantic_ai_slim-0.5.0.dist-info/METADATA,sha256=LGb7rsYjr9K6qD8sAP7-kSPjcTIWnL6x_reSXWeYmTQ,4173
98
- pydantic_ai_slim-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
99
- pydantic_ai_slim-0.5.0.dist-info/entry_points.txt,sha256=kbKxe2VtDCYS06hsI7P3uZGxcVC08-FPt1rxeiMpIps,50
100
- pydantic_ai_slim-0.5.0.dist-info/licenses/LICENSE,sha256=vA6Jc482lEyBBuGUfD1pYx-cM7jxvLYOxPidZ30t_PQ,1100
101
- pydantic_ai_slim-0.5.0.dist-info/RECORD,,
96
+ pydantic_ai_slim-0.6.0.dist-info/METADATA,sha256=81Lw6t1HUv6eaklhJfPDILdK5semxPBQ0h34FgqEFJY,4173
97
+ pydantic_ai_slim-0.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
98
+ pydantic_ai_slim-0.6.0.dist-info/entry_points.txt,sha256=kbKxe2VtDCYS06hsI7P3uZGxcVC08-FPt1rxeiMpIps,50
99
+ pydantic_ai_slim-0.6.0.dist-info/licenses/LICENSE,sha256=vA6Jc482lEyBBuGUfD1pYx-cM7jxvLYOxPidZ30t_PQ,1100
100
+ pydantic_ai_slim-0.6.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- from typing_extensions import deprecated
2
-
3
- from .format_prompt import format_as_xml as _format_as_xml
4
-
5
-
6
- @deprecated('`format_as_xml` has moved, import it via `from pydantic_ai import format_as_xml`')
7
- def format_as_xml(prompt: str) -> str:
8
- """`format_as_xml` has moved, import it via `from pydantic_ai import format_as_xml` instead."""
9
- return _format_as_xml(prompt)