kaxil commented on code in PR #74272:
URL: https://github.com/apache/airflow/pull/74272#discussion_r4211601932


##########
providers/common/ai/src/airflow/providers/common/ai/operators/llm.py:
##########
@@ -308,6 +308,8 @@ def execute(self, context: Context) -> Any:
         output = result.output
 
         model_confidence = ModelConfidence.from_result(result)
+        if model_confidence.model is not None:
+            self._push_xcom(context, MODEL_NAME_XCOM_KEY, 
model_confidence.model)

Review Comment:
   `LLMBranchOperator` doesn't get this by inheritance. Its `execute` 
(llm_branch.py:206) replaces this one without calling `super().execute()`, 
builds its own `ModelConfidence.from_result(result)` and only pushes 
`decision`, so `@task.llm_branch` never publishes the key even though the 
description and the comment on the constant say it does. Could the push move 
into a small helper that both `execute`s call, with a test in 
test_llm_branch.py? A case with `model_name=None` asserting the key is absent 
would be good too, since every fixture sets a model today.
   
   `LLMSQLQueryOperator`, `LLMSchemaCompareOperator` and 
`LLMFileAnalysisOperator` also override `execute`. Fine to leave those out (as 
#74355 does), but then the description should say `LLMOperator` only.



##########
providers/common/ai/src/airflow/providers/common/ai/utils/logging.py:
##########
@@ -94,6 +94,11 @@ def _log_cache_and_cost(logger: Logger | logging.Logger, 
usage: RunUsage) -> Non
         logger.info("LLM run cost: $%s (USD, best-effort)", format(usage.cost, 
"f"))
 
 
+# XCom key the LLM and agent operators publish the run's resolved model name 
under, so downstream
+# tasks and the UI can read which model actually answered without parsing the 
decision record.
+MODEL_NAME_XCOM_KEY = "__AIRFLOW__COMMON_AI_MODEL_NAME__"

Review Comment:
   Can this go into observability.rst next to `run_id` and `usage`? That's 
where users find which keys exist and which operators push them, and its Scope 
bullet still says those XComs come only from `AgentOperator`. Worth saying 
there that with `enable_hitl_review` this is the initial run's model, same as 
the other two, since `regenerate_with_feedback` doesn't re-push it.



-- 
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