Repository navigation
Make common.ai tool_prefix and output_type signatures consistent - #74695
Merged
Merged
Conversation
kaxil
reviewed
Oct 14, 2026
Lee-W
force-pushed
the
common-ai-1-0-api-unify
branch
from
October 14, 2026 09:09
6b90e59 to
880b666
Compare
Lee-W
marked this pull request as ready for review
October 14, 2026 09:46
kaxil
reviewed
Oct 14, 2026
Lee-W
force-pushed
the
common-ai-1-0-api-unify
branch
3 times, most recently
from
October 14, 2026 16:29
ad14ff9 to
5a39459
Compare
kaxil
reviewed
Oct 16, 2026
Lee-W
force-pushed
the
common-ai-1-0-api-unify
branch
2 times, most recently
from
October 19, 2026 08:36
14aa848 to
8ebf222
Compare
kaxil
reviewed
Oct 19, 2026
Lee-W
force-pushed
the
common-ai-1-0-api-unify
branch
3 times, most recently
from
October 21, 2026 14:59
fee7efb to
ff71888
Compare
kaxil
reviewed
Oct 21, 2026
Lee-W
force-pushed
the
common-ai-1-0-api-unify
branch
from
October 22, 2026 10:36
ff71888 to
ba54cc3
Compare
kaxil
reviewed
Oct 22, 2026
Lee-W
force-pushed
the
common-ai-1-0-api-unify
branch
2 times, most recently
from
October 27, 2026 10:13
51fb24c to
293be44
Compare
kaxil
reviewed
Oct 27, 2026
Lee-W
force-pushed
the
common-ai-1-0-api-unify
branch
3 times, most recently
from
October 29, 2026 04:03
b135b94 to
20cbe30
Compare
The worker only registers the model classes it finds in an output_type that is a single type or a union. A model returned under output_type=[MyModel, int] was therefore pushed to XCom as an instance and failed to load in the downstream task with "not found in allow list". Return it as a dict instead, as AgentOperator already did after human review. A model under a single type or a union is still returned as an instance.
A bare MagicMock accepts any attribute, so a call_tool signature change would not fail these tests. Give the helper the same RunContext and ToolsetTool specs that the other SQLToolset call_tool tests use.
…e walker The worker walker that registers output_type classes exists only from Airflow 3.3, so is_model_dump_required has nothing to consult on older task-sdk versions. Defer to the caller's serialize_output there instead of forcing a dump: the operators already pass serialize_output=True on those versions, and rehydrate_pydantic_output returns an instance again for a direct serialize_output=False call, as it did before. The tests that need the walker are skipped without it, which is what the Airflow 3.3 compatibility jobs were failing on.
- HookToolset accepts tool_name_prefix again and warns with AirflowProviderDeprecationWarning, as in common.ai 1.0.0 - Drop the 1.0.0 changelog note that announced the removal
…s serialize - Models are dumped with pydantic_core.to_jsonable_python through one shared dump_output_for_xcom helper, so a model with an HttpUrl, Path or Enum field no longer fails at the XCom push - Models inside a list, tuple, set or dict output are dumped too when the worker registers no class for them, such as under output_type=[list[Item], str] - Dumped models keep field names, not aliases, as dump_output_to_json does
- serialize_output=True, and task-sdk versions without the walker, dump models with model_dump() as 1.0.0 did, so date, datetime, Decimal and UUID fields keep their types instead of turning into strings - Only a model whose class the worker cannot register is dumped to JSON values - An output with a set, frozenset or dict key holding a model is dumped to JSON values, as pydantic cannot hold a dumped model in a set or as a key
…ck does - test_output_type.py and test_llm.py imported deserialize and serialize at module top, so collection failed on Airflow 2.11, 3.0 and 3.1 where airflow.sdk.serde does not exist - The imports now sit in the existing try block beside the walker flag, and the tests that use them are already skipped without the walker
…mmon.ai docs - With serialize_output=True every output holding a model is dumped, with model_dump() except where a set or dict key holds the model - Without it only a model whose class the worker cannot register is dumped, so output_type=list[MyModel] still pushes instances
serialize_output=True dumped the whole output in Python mode, so a list[Link] or dict[str, Link] kept its HttpUrl field inside a plain dict and the XCom push failed. Dump with model_dump() only when the output is itself a model, as 1.0.0 did, and leave a container of registered models to serde. A model whose class the worker cannot register is still dumped to JSON values, wherever it sits in the output.
… docs The serialize_output docstrings and the guide disagreed: the docstrings said the dump uses to_jsonable_python while the guide said model_dump(). Both are right for different outputs, so state the three cases in each place: a model that is itself the output with serialize_output=True is dumped to Python values, a container of registered models is left to serde, and a model the worker cannot register is dumped to JSON values. AgentOperator walks list, tuple and dict values only, while the LLM operators also walk sets and dict keys, so stop saying the Agent row follows the same rules as @task.llm.
AgentOperator dumped models with its own helper while LLMOperator, @task.llm and LLMFileAnalysisOperator used dump_output_for_xcom, so one output_type produced different XCom values: a model with serialize_by_alias came out as fullName from the agent but full_name from the LLM operators, and a date next to a model in a tuple stayed a date. AgentOperator now calls dump_output_for_xcom as well. Tuples next to an unregistered model arrive as lists, and on task-sdk before 3.3 a top-level model is dumped while list[MyModel] is pushed as instances, as in 1.0.0.
… walker The Compat 3.1.8 and 3.2.2 jobs failed test_execute_with_hitl_returns_the_approved_output_as_output_type[list-in-output-marker]: it expects a dict but gets the model instance. Those task-sdk versions ship airflow.sdk.serde without the deserialization walker, so the operator deliberately pushes nested models as instances (a top-level model is still model_dump()ed). The enum-and-url-fields case in the same parametrize already carries requires_typed_xcom; add the same mark here.
Four toolsets and the hook each carried their own copy of the prefix handling, so they could drift apart.
Both now take the prefix validation, tool naming and id suffix from the shared helper, so a fix to prefix handling lands in one place.
…oxToolset Both now take the prefix validation, tool naming and id suffix from the shared helper, so a fix to prefix handling lands in one place.
HookToolset used a fourth copy of the identifier check; it now calls the shared one.
…lker Without iter_pydantic_models (Airflow < 3.3 or an older task-sdk) the worker registers no class, so is_model_dump_required now treats every model in the output as unregistered instead of returning False. A list of models is pushed as dicts there, as AgentOperator already did in 1.1.0, and the LLM operators follow it.
…anges 1.1.0 is released, so its changelog note and the upgrade list in structured_output.rst are back to the text in the tag. The changes made after it, the dump of models in containers without the walker and the MCP tool_prefix signature, get their own notes above 1.1.0 and a short section in structured_output.rst. stability.rst no longer says list[MyModel] is pushed as instances before Airflow 3.3.
The serialize_by_alias, tuple and date changes of AgentOperator apply whenever a model in the output is dumped, also on Airflow < 3.3. The new section in structured_output.rst sat in the middle of the page and turned the paragraphs after it into its own subsection, so it now closes the page.
… walker - Skip the output_type tests that assume the 3.3 walker when it is absent - Test that every model, a top-level one included, is dumped to a dict without the walker - State in the changelog and structured_output docs that LLMOperator, @task.llm and LLMFileAnalysisOperator push a top-level model as a dict on Airflow < 3.3
…Mixin - Drop _strip_tool_prefix; SQLToolset, DataFusionToolset and ObjectStorageToolset use _find_base_tool_name, so with a tool_prefix set an unprefixed name raises "Unknown tool", as SandboxToolset already did - Move tool_name_conflict_hint into ToolPrefixMixin, so ObjectStorageToolset and SandboxToolset get it too
…dration - rehydrate_pydantic_output returns the raw text on a TypeError only when a list of output types cannot be joined into a union; a TypeError raised while building the TypeAdapter now propagates - Make is_model_dump_required private, as only output_type.py calls it
…i's OutputSpec - output_type accepts OutputSpec[Any] | UnionType, so output markers such as ToolOutput and NativeOutput and output functions type-check, as documented - Mention the output markers and output functions in the output_type docstrings
- Add a "When a model arrives as a dict" section to structured_output.rst and drop the section that repeated its rules - Point the serialize_output docstrings, stability.rst, the operator pages and the unreleased changelog note at that section instead of repeating the rules - Correct the claim that a top-level model is dumped to JSON values on Airflow < 3.3; it is dumped with model_dump(), as in 1.1.0 - Stop naming the internal output helper in user-facing docs
Lee-W
force-pushed
the
common-ai-1-0-api-unify
branch
from
November 12, 2026 05:16
f74af9b to
654306c
Compare
1 task done
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Public signatures freeze at 1.0, and changing a parameter's type, default or availability afterwards is a breaking change.
tool_prefixwasstron some toolsets,str | NoneonMCPToolsetandMCPHook, and missing onSQLToolsetandDataFusionToolset.AgentOperatoralso annotatedoutput_typenarrower thanLLMOperatoreven though both accept the same values at runtime.HookToolsetkeeps its deprecatedtool_name_prefixalias until 2.0.SQLToolsetandDataFusionToolsetalso overridetool_name_conflict_hintso a name conflict points users totool_prefix.rehydrate_pydantic_outputnow accepts a listoutput_typeby validating it as a union, so a listoutput_typeno longer crashes after a HITL review.Models returned under a list
output_typeare dumped through a shareddump_output_for_xcomhelper. Withserialize_output=True, and on task-sdk versions without the walker, the dump keepsmodel_dump()as in 1.0.0. A model whose class the worker cannot register is dumped withto_jsonable_python, soHttpUrl,PathandEnumfields serialize.Was generative AI tooling used to co-author this PR?
Generated-by: [Claude] following the guidelines
{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.