> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ag2.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.interop.PydanticAIInteroperability

<h2 id="autogen.interop.PydanticAIInteroperability" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">PydanticAIInteroperability</span>
</h2>

```python theme={null}
PydanticAIInteroperability()
```

A class implementing the `Interoperable` protocol for converting Pydantic AI tools
into a general `Tool` format.<br />This class takes a `PydanticAITool` and converts it into a standard `Tool` object,
ensuring compatibility between Pydantic AI tools and other systems that expect
the `Tool` format. It also provides a mechanism for injecting context parameters
into the tool's function.

### Static Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### convert\_tool

```python theme={null}
convert_tool(
    cls,
    tool: Any,
    deps: Any = None,
    **kwargs: Any
) -> Tool
```

Converts a given Pydantic AI tool into a general `Tool` format.<br />This method verifies that the provided tool is a valid `PydanticAITool`,
handles context dependencies if necessary, and returns a standardized `Tool` object.<br />

<b>Parameters:</b>

| Name       | Description                                                                                                                                                           |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cls`      |                                                                                                                                                                       |
| `tool`     | The tool to convert, expected to be an instance of `PydanticAITool`.<br /><br />**Type:** Any                                                                         |
| `deps`     | The dependencies to inject into the context, required if the tool takes a context.<br /><br />Defaults to None.<br /><br />**Type:** Any<br /><br />**Default:** None |
| `**kwargs` | Additional arguments that are not used in this method.<br /><br />**Type:** Any                                                                                       |

<b>Returns:</b>

| Type                                           | Description                                                             |
| ---------------------------------------------- | ----------------------------------------------------------------------- |
| [Tool](/docs/api-reference/autogen/tools/Tool) | Tool: A standardized `Tool` object converted from the Pydantic AI tool. |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_unsupported\_reason

```python theme={null}
get_unsupported_reason() -> str | None
```

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### inject\_params

```python theme={null}
inject_params(ctx: Any, tool: Any) -> Callable[..., Any]
```

Wraps the tool's function to inject context parameters and handle retries.<br />This method ensures that context parameters are properly passed to the tool
when invoked and that retries are managed according to the tool's settings.<br />

<b>Parameters:</b>

| Name   | Description                                                                                     |
| ------ | ----------------------------------------------------------------------------------------------- |
| `ctx`  | The run context, which may include dependencies and retry information.<br /><br />**Type:** Any |
| `tool` | The Pydantic AI tool whose function is to be wrapped.<br /><br />**Type:** Any                  |

<b>Returns:</b>

| Type                | Description                                                                                 |
| ------------------- | ------------------------------------------------------------------------------------------- |
| Callable\[..., Any] | Callable\[..., Any]: A wrapped function that includes context injection and retry handling. |

<br />
