Lee-W commented on code in PR #74695:
URL: https://github.com/apache/airflow/pull/74695#discussion_r4402370481


##########
providers/common/ai/src/airflow/providers/common/ai/utils/output_type.py:
##########
@@ -38,6 +46,59 @@
 _CONVERSION_ERRORS = (ValidationError, ValueError, TypeError, AttributeError, 
KeyError, IndexError)
 
 
+def is_model_dump_required(output: Any, output_type: Any) -> bool:
+    """
+    Tell whether an output holding ``BaseModel`` instances must be pushed to 
XCom dumped.
+
+    The instances are looked up in the output itself, as 
``_iter_models_in_output`` walks it: the elements
+    of a list, tuple (a NamedTuple included), set or frozenset, and the keys 
and values of a dict. A downstream task can load a model from XCom only if the 
worker
+    registered the model's class, and the worker registers the classes 
``iter_pydantic_models`` finds in
+    ``output_type``. It finds none in a list of output types, an output 
marker, an output function, a
+    ``TypeAliasType`` or a ``NewType``, so an instance of a class it did not 
find is dumped. Without
+    ``iter_pydantic_models`` there is no evidence that a class is 
unregistered, so nothing is dumped.
+    """
+    if iter_pydantic_models is None:

Review Comment:
   `AgentOperator` and `@task.agent` now push their output through the same 
`dump_output_for_xcom` helper as the LLM operators, and its private 
`_dump_unregistered_models` is gone, so one `output_type` gives one XCom value 
(field names rather than aliases, `date` next to a model in a tuple arrives as 
a string, a tuple arrives as a list). Before task-sdk 3.3 both still dump only 
a top-level model and push `list[MyModel]` as instances, as 1.0.0 does



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to