页面简介
正文摘录
Home Toolsets ↑↓ Navigate ⏎ Select Esc Close Toolsets¶ A toolset is a group of tools an agent may call. Pass toolsets to AgentOperator or @task.agent in toolsets=[...]. The model sees each tool’s name, description and arguments, and what each call returns. The connection a toolset authenticates with is resolved in the worker and is not part of any of that. Toolset What the agent gets What you limit it with HookToolset The methods you list from any Airflow hook, one tool per method allowed_methods (required), pinned_arguments SQLToolset list_tables, get_schema, query and check_query against a DBAPI database allowed_tables, allow_writes (off by default), max_rows, max_result_bytes ObjectStorageToolset list_files, get_file_info and read_file under one object-storage path. It cannot write. path, the root every requested path is checked against; max_read_bytes, max_output_bytes DataFusionToolset SQL over Parquet, CSV and Avro files and Iceberg tables, run in the worker The tables you register in datasource_configs, allow_writes (off by default), max_rows MCPToolset Every tool the MCP server behind mcp_conn_id exposes .filtered() to offer only some of them AgentSkillsToolset SKILL.md instruction bundles that the model loads when it needs one exclude_tools={"run_skill_script"} to stop skill scripts running on the worker; exclude_resources SandboxToolset A shell and a filesystem in a sandbox isolated from the worker process SandboxSpec (block_network is on by default, allow_egress_to), command timeouts ManagedAgentToolset One tool that sends a prompt to an agent running on a cloud vendor’s infrastructure timeout for each call; what the remote agent may touch is set at the vendor Three controls work on every toolset. .approval_required() pauses the task before a matching call runs, until a person approves or rejects it on the Required Actions page. It needs Airflow 3.3 or later, pauses at every step that calls a matching tool on Airflow 3.4 and later (once per Dag run on 3.3), and does not combine with durable=True or a SandboxToolset that provisions its own sandbox (Approve an agent’s tool calls lists every limit). .filtered() drops tools from what the model is offered, as the MCP guide shows. .defer_loading() hides a toolset’s tools from the model until it searches for them, which pays off on a toolset with many tools (see Progressive tool disclosure). In an agent written for another framework, which gets the toolset through AirflowTools, .filtered(), .prefixed() and .renamed() carry over; .approval_required() and .defer_loading() raise a TypeError (see Agent frameworks). Tool call logging and LangChain tools in both directions do not reach a system of their own: one wraps a toolset to log its calls, the other converts a toolset for a LangChain agent. Importing toolsets¶ Every toolset imports from the airflow.providers.common.ai.toolsets package root: from airflow.providers.common.ai.toolsets import ( AgentSkillsToolset, DataFusionToolset, HookToolset, ManagedAgentToolset, MCPToolset, ObjectStorageToolset, SandboxToolset, SQLToolset, ) SQLToolset, DataFusionToolset and MCPToolset depend on optional extras. If the extra is not installed, they raise AirflowOptionalProviderFeatureException. For SQLToolset and DataFusionToolset this happens on the first access to the name. MCPToolset imports without its extra; it raises only when the toolset first connects to the MCP server. Every toolset here implements pydantic-ai’s AbstractToolset interface, so it works in any pydantic-ai Agent. AgentOperator accepts any AbstractToolset too, such as pydantic-ai’s own MCPToolset or a third-party toolset; those miss the connection handling the toolsets on this page add. To write a toolset of your own on the same base class, see Writing your own toolset. Choosing a toolset¶ Pick a route by what you already have. More than one row of the table below can be true at once, and the rows are not exclusive: one agent can carry several toolsets. Two questions break the ties. Whose credential is it? Prefer the route whose credential is an Airflow connection somebody on your side already reviewed. Whose tool list is it? Prefer the route whose exposed surface you chose rather than inherited. The pair that most often overlaps is an Airflow hook and a vendor MCP server reaching the same target; both questions point at the hook, because its credential is the connection and allowed_methods is a list you write. Reach for the server when its tools cover work the hook does not expose, or when the alternative is re-wrapping that API by hand. Those two questions do not separate HookToolset from SQLToolset when the target is a DBAPI database, because both answer them the same way. A third one does: is the work a fixed operation or an open-ended question? A named method you can enumerate in advance is a hook. A question the agent has to express as SQL is a query, and SQLToolset answers it with schema discovery, bounded results and an allowed_tables walk you can switch on, none of which HookToolset has an equivalent of. Start with what you have¶ What you have Route A target that already has an Airflow connection, and a hook method that already does the thing HookToolset A question that is a query, against a DBAPI database SQLToolset Files on an object store that the agent should read the way a person would: browse a directory, open a report, look at the first rows of a Parquet file ObjectStorageToolset Files on an object store (Parquet, CSV, Avro) or a catalog-managed table format such as Iceberg, to query with SQL rather than read DataFusionToolset A vendor that already ships a server built for agents, whose tools you would otherwise re-wrap by hand MCPToolset Procedural knowledge (how to carry out a task) rather than an endpoint to call AgentSkillsToolset Work that means running code the model wrote, not calling a tool you chose SandboxToolset Reasoning that should happen on the vendor’s own infrastructure ManagedAgentToolset over a vendor hook that implements the managed-agent contract The hook, SQL, object storage, DataFusion, MCP, Agent Skills and managed-agent guides each have a When to choose it section giving the case for choosing it, what it cannot do, an example that exists in this repository, and where its credentials and its work come from. Sandboxes carries the same section for SandboxToolset. Where the credentials come from¶ Airflow connections and hooks are the access-governance machinery this provider already has: a connection lives in a secret backend rather than in Dag code, and its scope is set outside the Dag. A hook turns that scope into typed methods. Where a route ends up getting its credential is therefore a decision worth making on purpose rather than inheriting. Route Credential source Where the tool call runs HookToolset Whatever connection the hook you supply resolves Worker process SQLToolset db_conn_id, via BaseHook.get_connection Worker process, against the database ObjectStorageToolset conn_id; with conn_id=None, the store’s default credentials, such as the worker’s AWS role Worker process, against the store DataFusionToolset conn_id on each DataSourceConfig Worker process (embedded engine) MCPToolset mcp_conn_id, unless token_provider or env_provider supplies one from elsewhere Remote server, or a child process on the worker host for stdio AgentSkillsToolset GitSkills.conn_id for private repositories; none for local directories Worker process SandboxToolset None from Airflow. Host-level sbx login and sbx policy init for sbx; ambient Modal token on the worker for Modal A microVM on the worker host (sbx), or Modal’s infrastructure off the worker (Modal) ManagedAgentToolset The vendor hook’s own connection The vendor’s infrastructure Two rows are worth pausing on. SandboxToolset deliberately takes no Airflow credential; that is the whole point of it, and it substitutes a backend-level boundary, on the host or at the vendor, for the connection-level one. ManagedAgentToolset authenticates through the vendor hook’s connection, but what the remote agent may touch is governed on the vendor’s side. Neither is a defect, but in both cases the access decision has moved somewhere Airflow cannot see it, and somebody has to make that decision again in the new place. The defense-layer table is the right companion when you do. Tool calls as barriers¶ HookToolset, SQLToolset, DataFusionToolset and SandboxToolset each build their own tool definitions and set sequential=True on them, which pydantic-ai treats as a barrier: the tool runs alone, tools the model emitted before it finish first, and tools emitted after it start only once it returns. A slow call on any of those four therefore holds up the rest of that step, not just its own toolset. Expect this from all four; it is not a reason to prefer one of them. ManagedAgentToolset sets sequential=False deliberately, because the wait it introduces is remote. ObjectStorageToolset leaves it unset, so its calls are not barriers, but each of them still waits for a hook, SQL or DataFusion call in progress: the hook, SQL, DataFusion and object storage toolsets run their blocking work in worker threads under one lock per task process. MCPToolset and AgentSkillsToolset define no tools of their own: they pass through whatever the upstream toolset declares, so the setting is not theirs to make. How often the model may correct a failed call¶ When the model calls a tool with arguments that fail its schema, or the tool asks the model to try again (ModelRetry), the error goes back to the model so it can correct the call. What counts differs by toolset: SQLToolset counts an error the database returns for a statement, such as a misspelled column, and a statement it refuses itself (a write while allow_writes is off, a table outside allowed_tables). Failing to reach the database fails the run straight away, except through a hook that only connects when the statement runs; see SQL databases: SQLToolset. DataFusionToo