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


##########
providers/common/ai/src/airflow/providers/common/ai/operators/llm_branch.py:
##########
@@ -95,4 +108,54 @@ def execute(self, context: Context) -> str | Iterable[str] 
| None:
         else:
             branches = str(output)
 
+        if self.require_approval:
+            choices = sorted(self.downstream_task_ids)
+            chosen = branches if isinstance(branches, str) else 
json.dumps(branches)
+            body = (
+                f"```\nPrompt: {self.prompt}\n\nChosen branch(es): 
{chosen}\n```\n\n"
+                f"Valid branches: {', '.join(f'`{c}`' for c in choices)}"

Review Comment:
   `prompt` is in `template_fields`, so this body can carry text the DAG author 
did not write -- the example in `llm_branch.rst` is `{{ dag_run.conf['message'] 
}}`. A prompt containing a triple-backtick run closes the fence early, and 
everything after it renders as markdown, including a forged `Valid branches:` 
line that looks like part of the form. Since `Valid branches:` is the line the 
reviewer is meant to trust, it is worth making the fence hold whatever the 
prompt contains (size it past the longest backtick run, or escape them) rather 
than assuming the prompt stays inside 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