Repository navigation
Render only the returned value in TaskFlow decorators that template it - #76244
Merged
potiuk merged 2 commits intoNov 2, 2026
Merged
Conversation
potiuk
requested review from
Lee-W,
ashb,
gopidesupavan,
hussein-awala,
jedcunningham,
jscheffl and
kaxil
as code owners
November 1, 2026 19:29
jscheffl
approved these changes
Nov 1, 2026
hussein-awala
approved these changes
Nov 1, 2026
kaxil
reviewed
Nov 1, 2026
The decorators that build their main field from the function's return value called render_template_fields() inside execute() to render it, which rendered every other template field a second time after the task runner had already rendered them. Render only the returned value, as apache#71402 did, and document how to reference function arguments in the returned @task.llm prompt. Generated-by: Claude Opus 5
Only op_kwargs were merged into the context, so a prompt that referenced an argument by name
failed with an undefined variable when the task was called positionally, as in the docs'
summarize("...") example. The six common.ai decorators now merge the bound call arguments,
without defaults so that a ti=None default cannot shadow the context's ti, just before rendering
the returned prompt. The docs, the examples the page includes and the Usage docstrings reference
the argument by name instead of formatting it in with an f-string.
The returned-command test of @task.bash runs on Airflow 3 only: on Airflow 2 the decorator is the
one in Airflow core.
Generated-by: Claude Opus 5
potiuk
force-pushed
the
taskflow-decorators-render-returned-value-only
branch
from
November 1, 2026 23:18
d7ffcd5 to
52de6de
Compare
potiuk
enabled auto-merge (squash)
November 1, 2026 23:51
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.
The TaskFlow decorators that build their main field from the function's return value (
@task.bash,@task.sql,@task.analytics,@task.kubernetes_cmdand the six common.ai decorators@task.llm,@task.agent,@task.llm_sql,@task.llm_branch,@task.llm_file_analysis,@task.llm_schema_compare) calledself.render_template_fields(context)insideexecute()to render that returned value. The task runner has already rendered every template field once beforeexecute(), so that call rendered all the other template fields (env,cwd,op_args,op_kwargs,parameters,system_prompt, ...) a second time. A value that came out of the first pass containing{{ ... }}was rendered again, whichBashOperatorand the other plain operators never do.This renders only the returned value (
self.bash_command = self.render_template(self.bash_command, context)and the equivalent forsql,queries, the generated pod command andprompt), the same approach as #71402. The returned value is still rendered as before, includingtemplate_extfile lookup.@task.kubernetes_cmdalso rendered all fields once more before calling the function; that call is dropped too.The common.ai docs did not say that the returned prompt is rendered as a template, and the ticket-triage example formatted the ticket text into it with an f-string.
llm.rstnow explains it and shows how to reference a function argument by name in the returned template, and the example uses that.Changes:
execute(), as at runtime.llm.rstandexample_llm_analysis_pipeline.pyupdated.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 5 following the guidelines