Skip to content

Rename HookToolset tool_name_prefix to tool_prefix - #74447

Merged
Lee-W merged 5 commits into
apache:mainfrom
astronomer:common-ai-hook-toolset-tool-prefix
Oct 12, 2026
Merged

Lee-W merged 5 commits into
apache:mainfrom
astronomer:common-ai-hook-toolset-tool-prefix

Conversation

@Lee-W

@Lee-W Lee-W commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Why

MCPToolset and SandboxToolset already name this parameter tool_prefix, while HookToolset calls it tool_name_prefix. Align HookToolset before the 1.0 release so the three toolsets share one name.

What

  • HookToolset accepts tool_prefix. It is joined to the method name with _ (tool_prefix="s3" gives s3_list_keys) and must be a valid identifier, like SandboxToolset, ObjectStorageToolset and MCPToolset.
  • tool_name_prefix stays as a deprecated alias, concatenated as given, and emits AirflowProviderDeprecationWarning. Passing both is accepted when tool_name_prefix == f"{tool_prefix}_" and raises ValueError otherwise.
  • The duplicate tool name error in tools/__init__.py, the docs (toolsets/hook.rst, agent_security.rst, stability.rst) and the example Dags (example_agent.py, example_hook_toolset.py) use the new name.
  • Tests in providers/common/ai/tests/unit/common/ai/: toolsets/test_hook.py (prefix joining, identifier validation, deprecated alias, both-passed) and tools/test__from_toolset.py.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: [Claude] following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@Lee-W
Lee-W force-pushed the common-ai-hook-toolset-tool-prefix branch from 4b83941 to e3c63f7 Compare October 9, 2026 04:54
@Lee-W
Lee-W force-pushed the common-ai-hook-toolset-tool-prefix branch from e3c63f7 to 6f1fe3b Compare October 11, 2026 06:58
Lee-W added 5 commits October 11, 2026 10:38
`MCPToolset` and `SandboxToolset` already name this parameter `tool_prefix`.
Align `HookToolset` before the 1.0 release, and keep `tool_name_prefix` as a
deprecated alias that raises `ValueError` when it conflicts with `tool_prefix`.
- `tool_prefix="s3"` now names the tool `s3_list_keys`, matching
  `SandboxToolset`, `ObjectStorageToolset` and `MCPToolset`.
- `tool_prefix` must be a valid identifier, otherwise `ValueError`.
- The deprecated `tool_name_prefix` keeps its raw concatenation.
- Passing both now requires `tool_name_prefix == f"{tool_prefix}_"`.
- Docs and example Dags use `"s3"` / `"http"`.
Every toolset that takes a prefix now calls it `tool_prefix`, so the
error no longer lists them per class.
- The `tool_name_prefix` deprecation warning now suggests the `tool_prefix` value to use, with the trailing `_` removed
- Renaming `tool_name_prefix="s3_"` to `tool_prefix="s3_"` would otherwise name the tools `s3__list_keys`
- The duplicate tool name error now tells the user to give the toolsets different `tool_prefix` values "where they take one"
- `SQLToolset` and `DataFusionToolset` take no `tool_prefix`, so the unqualified advice led to a `TypeError`
@Lee-W
Lee-W force-pushed the common-ai-hook-toolset-tool-prefix branch from 6f1fe3b to e8d3828 Compare October 11, 2026 09:38
@Lee-W
Lee-W requested a review from kaxil October 11, 2026 09:48

@kaxil kaxil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@Lee-W
Lee-W merged commit 1530df8 into apache:main Oct 12, 2026
85 checks passed
@Lee-W
Lee-W deleted the common-ai-hook-toolset-tool-prefix branch October 12, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants