kaxil commented on code in PR #74470:
URL: https://github.com/apache/airflow/pull/74470#discussion_r4222825045
##########
providers/common/ai/src/airflow/providers/common/ai/decorators/agent.py:
##########
@@ -98,7 +98,6 @@ def execute(self, context: Context) -> Any:
feature_enabled=self.enable_hitl_review,
)
- self.render_template_fields(context)
Review Comment:
Thanks @pankajkoti. The second render wasn't an accident. I added it in
#62598 so `@task.llm` would behave like `@task.bash` and `@task.sql`, which
both render the string the function returns. The bash docs lead with that
pattern (`return 'echo "ti_key={{ task_instance_key_str }}"'`), so I'd expect
people to bring the habit over.
With this PR, a task like this:
```python
@task.llm(llm_conn_id="openai", system_prompt="You are a data analyst.")
def summarize_daily_events():
return "Summarize the events for {{ ds }} in region {{ params.region }}."
```
still succeeds, but the model now receives:
```
Summarize the events for {{ ds }} in region {{ params.region }}.
```
instead of `Summarize the events for 2026-10-08 in region emea.` There's no
error or warning, so the only sign is a strange answer from the model. The same
applies to `@task.agent`, `@task.llm_branch`, `@task.llm_sql`,
`@task.llm_file_analysis` and `@task.llm_schema_compare`.
I can see the case for it, though. Unlike a bash command, a prompt often
embeds text the Dag author didn't write. In the ticket-triage example,
rendering that text can fail the task, or resolve `{{ var.value.x }}` and send
the value to the model provider. That seems like a stronger reason than the
double render.
Was there a specific case that made you want to remove it, a user report or
something you ran into? If so, could you link it and mention in the description
that this departs from `@task.bash` and `@task.sql` on purpose? That way the
tradeoff is on record for anyone porting the bash habit. WDYT?
--
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]