Skip to content

Make execute_tool the public method AirflowToolset subclasses implement - #73938

Merged
kaxil merged 2 commits into
apache:mainfrom
astronomer:commonai-toolset-base-naming
Sep 30, 2026
Merged

kaxil merged 2 commits into
apache:mainfrom
astronomer:commonai-toolset-base-naming

Conversation

@kaxil

@kaxil kaxil commented Sep 30, 2026

Copy link
Copy Markdown
Member

Addresses @Lee-W's review on #73897, which merged before the comments were in.

A toolset subclass had to implement AirflowToolset._execute_tool: the method every toolset depends on had a private name, which says it is free to change (comment). It is now the public execute_tool, and ctx and tool are keyword-only so that arguments can be added later without breaking subclasses (comment).

The keyword-only suggestion was made on call_tool, but that signature has to stay as pydantic-ai defines it: pydantic-ai calls call_tool(name, tool_args, ctx, tool) positionally, in WrapperToolset, CombinedToolset and its durable-execution toolsets. So it applies to execute_tool, the method subclasses write, instead.

Renames:

Before After Why
with_masking ensure_masked A toolset that already masks its output comes back unchanged.
_masked _mask_call _mask is already the recursive walker in utils/masking.py.
_stripped _mask_attributes It read too much like _strip, which calls it.
MCPToolset._server_once_resolved _resolve_server

_json_default keeps its name, since it is what dumps_masked passes as json.dumps(default=...).

None of these names has been in a release yet, so nothing needs deprecating.

A subclass had to implement the private _execute_tool, so a method that was
free to change was also the one every toolset depends on. It is now the public
execute_tool, with ctx and tool keyword-only so that arguments can be added later
without breaking subclasses. call_tool keeps pydantic-ai's positional signature,
since pydantic-ai calls it that way.

Also renames with_masking to ensure_masked, which says that a toolset that
already masks its output comes back unchanged, and gives the masking helpers
names that are easier to tell apart: _masked becomes _mask_call and _stripped
becomes _mask_attributes. MCPToolset._server_once_resolved becomes
_resolve_server.

@Lee-W Lee-W 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.

This PR looks great. 2 suggestion (could be part of this PR or follow up)

  1. call_tool and execute_tool are not easy to distinguish. we'll need some doc or some other way so that users won't get confused
  2. their function signature is not the same. might be something confusing as well

Say in the class docstring which method a subclass writes, why overriding
call_tool skips the masking, and why the two signatures are shaped differently.
@kaxil

kaxil commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

Thanks. Both are now covered in the AirflowToolset docstring (427549f): which method a subclass writes and what call_tool does with it, why an override of call_tool gets re-wrapped by ensure_masked, and why the two signatures are shaped differently (pydantic-ai calls call_tool positionally, so only execute_tool can be keyword-only).

@kaxil
kaxil merged commit 7938c0d into apache:main Sep 30, 2026
83 checks passed
@kaxil
kaxil deleted the commonai-toolset-base-naming branch September 30, 2026 11:02
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