You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "SameerMesiah97 (via GitHub)" <gi...@apache.org> on 2026/07/15 21:25:12 UTC
[PR] Add SnowflakeCortexAgentOperator to Snowflake Provider [airflow]
SameerMesiah97 opened a new pull request, #69939:
URL: https://github.com/apache/airflow/pull/69939
**Description**
This change introduces a new `SnowflakeCortexAgentOperator` for executing Snowflake Cortex Agents from Airflow DAGs.
The operator delegates to the existing `SnowflakeCortexAgentHook`, providing a declarative interface for invoking Cortex Agents with support for Airflow templating and XCom.
**Rationale**
`SnowflakeCortexAgentHook` already exposes the Snowflake Cortex Agent Run API, but users currently need to invoke it from custom Python tasks. This operator promotes that functionality to a first-class Airflow task, making Cortex Agent execution consistent with other operators in the Snowflake provider and enabling it to be composed naturally within DAGs.
**Tests**
Added unit tests verifying that:
* `SnowflakeCortexAgentOperator` correctly delegates execution to `SnowflakeCortexAgentHook.run_agent`.
* The response returned by the hook is propagated by the operator.
**Example DAG**
Added a new example DAG, `example_snowflake_cortex_agent`, demonstrating how to execute a Snowflake Cortex Agent using `SnowflakeCortexAgentOperator`.
**Documentation**
Added documentation for `SnowflakeCortexAgentOperator`, including its supported parameters and a usage example.
**Backwards Compatibility**
This is a new operator and does not modify existing functionality. No breaking changes are introduced.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add SnowflakeCortexAgentOperator to Snowflake Provider [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on code in PR #69939:
URL: https://github.com/apache/airflow/pull/69939#discussion_r3632855928
##########
providers/snowflake/src/airflow/providers/snowflake/operators/snowflake_cortex_agent.py:
##########
@@ -0,0 +1,135 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+from collections.abc import Sequence
+from functools import cached_property
+from typing import TYPE_CHECKING, Any
+
+from airflow.models import BaseOperator
+from airflow.providers.snowflake.hooks.snowflake_cortex_agent import SnowflakeCortexAgentHook
+
+if TYPE_CHECKING:
+ from airflow.providers.common.compat.sdk import Context
+
+
+class SnowflakeCortexAgentOperator(BaseOperator):
+ """
+ Execute a Snowflake Cortex Agent.
+
+ :param database: Database containing the Cortex Agent.
+ :param schema: Schema containing the Cortex Agent.
+ :param agent_name: Name of the Cortex Agent.
+ :param messages: Conversation messages to send to the agent.
+ :param thread_id: Existing conversation thread identifier. Optional.
+ Defaults to ``None``.
+ :param parent_message_id: Parent message identifier within the specified
+ thread. Required when ``thread_id`` is provided. Defaults to ``None``.
+ :param tool_choice: Tool selection configuration. Optional. Defaults to
+ ``None``.
+ :param models: Model configuration. Optional. Defaults to ``None``.
+ :param instructions: Agent instruction overrides. Optional. Defaults to
+ ``None``.
+ :param orchestration: Orchestration configuration. Optional. Defaults to
+ ``None``.
+ :param tools: Additional tools available to the agent. Optional. Defaults
+ to ``None``.
+ :param tool_resources: Configuration for tools specified in ``tools``.
+ Optional. Defaults to ``None``.
+ :param timeout: Maximum time in seconds to wait for the request to
+ complete. Defaults to ``600``.
+ :param snowflake_conn_id: Snowflake connection ID. Defaults to
+ ``snowflake_default``.
+ """
+
+ template_fields: Sequence[str] = ("messages",)
Review Comment:
Please consider adding database/schema/agent_name to `template_fields`
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add SnowflakeCortexAgentOperator to Snowflake Provider [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on code in PR #69939:
URL: https://github.com/apache/airflow/pull/69939#discussion_r3632839191
##########
providers/snowflake/src/airflow/providers/snowflake/operators/snowflake_cortex_agent.py:
##########
@@ -0,0 +1,135 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+from collections.abc import Sequence
+from functools import cached_property
+from typing import TYPE_CHECKING, Any
+
+from airflow.models import BaseOperator
Review Comment:
Could you please use here the compatibility shim?
`from airflow.providers.common.compat.sdk import BaseOperator`
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add SnowflakeCortexAgentOperator to Snowflake Provider [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 merged PR #69939:
URL: https://github.com/apache/airflow/pull/69939
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add SnowflakeCortexAgentOperator to Snowflake Provider [airflow]
Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on PR #69939:
URL: https://github.com/apache/airflow/pull/69939#issuecomment-4985423852
This depends on PR #69731 being merged first. Please do not review this until that happens.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org