aarmens702-hub commented on code in PR #77073:
URL: https://github.com/apache/airflow/pull/77073#discussion_r4714577680
##########
providers/common/ai/src/airflow/providers/common/ai/operators/agent.py:
##########
@@ -1020,6 +1020,23 @@ def llm_hook(self) -> PydanticAIHook:
}
return PydanticAIHook.get_hook(self.llm_conn_id,
hook_params=hook_params)
+ def build_agent(self) -> Agent[object, Any]:
+ """
+ Build the pydantic-ai Agent this task runs, from the operator's config.
+
+ An eval or test can call this on a task from a Dag (for example
+ ``dag.get_task("triage").build_agent()``) to run the same agent as
``execute``, with
+ the same connection, instructions, toolsets and capabilities. Each
call builds a new
+ agent. A subclass that changes how the agent is built should override
+ ``_build_agent``, which both this and ``execute`` call.
+
+ Template fields are only rendered during a task run, so outside one
every template
+ field (``system_prompt``, ``llm_conn_id``, ``model_id`` and the rest)
is used as
+ written. For a durable task, the returned agent has no tool-approval
step: a run can
Review Comment:
Thanks, fixed in 0c74cd0861. The docstring and `local_development.rst` now
say that only `execute()` acts on tool approval, so outside a task a run that
calls an approval-required tool ends with a `DeferredToolRequests` as its
output instead of an answer. The docs also say that a case checking the answer
then fails. I dropped the durable condition from the matching test docstring
too.
Drafted-by: Claude Code (Opus 5.5); reviewed by @aarmens702-hub before
posting
--
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]