@@ -34,29 +34,41 @@ Three toolsets are included:
3434 `MCP servers <https://modelcontextprotocol.io/ >`__ configured via Airflow
3535 connections.
3636
37- All three implement pydantic-ai's
38- `AbstractToolset <https://ai.pydantic.dev/toolsets/ >`__ interface and can be
39- passed to any pydantic-ai ``Agent ``, including via
40- :class: `~airflow.providers.common.ai.operators.agent.AgentOperator `.
37+ :class: `~airflow.providers.common.ai.toolsets.hook.HookToolset ` and
38+ :class: `~airflow.providers.common.ai.toolsets.mcp.MCPToolset ` implement pydantic-ai's
39+ `AbstractToolset <https://ai.pydantic.dev/toolsets/ >`__ interface.
40+ :class: `~airflow.providers.common.ai.toolsets.sql.SQLToolset ` implements the
41+ framework-agnostic :class: `~airflow.providers.common.ai.hooks.base_ai.BaseToolset ` interface.
42+ All three can be passed to
43+ :class: `~airflow.providers.common.ai.operators.agent.AgentOperator `, which routes each
44+ toolset to the correct agent parameter automatically.
4145
4246.. note ::
4347
44- ``AgentOperator `` accepts **any ** ``AbstractToolset `` implementation — not
45- just the Airflow-native toolsets above. PydanticAI's own MCP server
46- classes (``MCPServerStreamableHTTP ``, ``MCPServerSSE ``, ``MCPServerStdio ``)
47- and third-party toolsets work too. The Airflow-native toolsets add
48- connection management, secret backend integration, and the connection UI,
49- but you are not locked in.
48+ ``AgentOperator `` accepts a mixed ``toolsets `` list containing any
49+ combination of:
5050
51+ - pydantic-ai ``AbstractToolset `` implementations (``HookToolset ``,
52+ ``MCPToolset ``, ``DataFusionToolset ``).
53+ - Any third-party ``AbstractToolset ``, including PydanticAI's own MCP
54+ server classes (``MCPServerStreamableHTTP ``, ``MCPServerSSE ``,
55+ ``MCPServerStdio ``).
56+ - :class: `~airflow.providers.common.ai.hooks.base_ai.BaseToolset `
57+ subclasses (``SQLToolset ``).
58+ - Plain Python callables (``def my_tool(...): ... ``).
59+ - Native pydantic-ai ``Tool `` objects.
5160
52- Using Toolsets Directly with PydanticAI
53- ---------------------------------------
61+ The hook routes each item to the correct agent parameter automatically.
5462
55- Toolsets are standard pydantic-ai ``AbstractToolset `` implementations with no
56- dependency on ``AgentOperator `` or ``@task.agent ``. You can use them anywhere
57- you can run Python within Airflow -- ``@task `` functions, ``PythonOperator ``
58- callables, or any custom operator's ``execute() `` method -- by creating a
59- ``pydantic_ai.Agent `` yourself:
63+
64+ Using Toolsets Directly
65+ -----------------------
66+
67+ Toolsets can be used anywhere you can run Python within Airflow — ``@task ``
68+ functions, ``PythonOperator `` callables, or any custom operator's
69+ ``execute() `` method — without needing ``AgentOperator `` or ``@task.agent ``.
70+ Pass toolsets via :class: `~airflow.providers.common.ai.hooks.base_ai.AgentRunRequest `
71+ and call the hook yourself:
6072
6173.. exampleinclude :: /../../ai/src/airflow/providers/common/ai/example_dags/example_pydantic_ai_hook.py
6274 :language: python
@@ -67,11 +79,13 @@ This works because toolsets resolve Airflow connections lazily via
6779``BaseHook.get_connection() ``, which is available in any task execution
6880context.
6981
70- This approach gives you full control over the agent lifecycle -- you can call
71- `` agent.run_sync() `` multiple times, swap models at runtime , or combine
72- results from several agents in a single task . The tradeoff is that you lose
82+ This approach gives you direct control over the agent lifecycle — you can
83+ build and run multiple agents in a single task , or combine results from
84+ several runs . The tradeoff is that you lose
7385the durable execution (step-level caching with retry replay), HITL review
74- integration, and automatic tool call logging that ``AgentOperator `` provides.
86+ integration, and the automatic tool call logging and routing that
87+ ``AgentOperator `` provides via
88+ :class: `~airflow.providers.common.ai.toolsets.logging.LoggingToolset `.
7589
7690
7791``HookToolset ``
0 commit comments