kaxil commented on code in PR #77073:
URL: https://github.com/apache/airflow/pull/77073#discussion_r4701837282
##########
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:
This isn't only durable tasks, and the durable wording came from me, sorry.
`_agent_output_type()` adds `DeferredToolRequests` whenever
`_supports_tool_approval()` is true, durable or not, and only `execute()` acts
on it, so outside a task any agent that calls an approval-required tool ends
its run with a `DeferredToolRequests` as the output. Could this and the
matching sentence in `local_development.rst` drop the durable condition and say
that instead? An eval using the `Contains("3")` example would otherwise just
fail with no hint why.
--
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]