Skip to content

Add SnowflakeCortexAgentHook#68942

Merged
vincbeck merged 2 commits into
apache:mainfrom
SameerMesiah97:SnowflakeCortexAgentHook
Jul 6, 2026
Merged

Add SnowflakeCortexAgentHook#68942
vincbeck merged 2 commits into
apache:mainfrom
SameerMesiah97:SnowflakeCortexAgentHook

Conversation

@SameerMesiah97

Copy link
Copy Markdown
Contributor

Description

This change introduces a new hook for interacting with Snowflake Cortex Agents (SnowflakeCortexAgentHook).

The hook provides a run_agent() method that executes a Cortex Agent using Snowflake's REST API and returns the JSON response payload. It supports conversation threading (thread_id and parent_message_id), model configuration, agent instructions, orchestration settings, tool selection, and tool resource configuration.

A helper method, get_text_response(), is also provided to extract text content from Cortex Agent responses.

Authentication is delegated to SnowflakeHook by reusing connection parameters and access tokens resolved by the existing Snowflake provider infrastructure.

Rationale

Snowflake Cortex Agents provide a programmable interface for interacting with AI agents hosted within Snowflake. While the Snowflake provider currently includes hooks and operators for executing SQL workloads, it does not provide an integration for Cortex Agents.

Introducing a dedicated hook establishes the foundation for future Cortex Agent integrations while providing users with a reusable interface for invoking agents from Airflow tasks.

This initial implementation is scoped to OAuth authentication by reusing access tokens resolved by SnowflakeHook. Support for additional authentication mechanisms can be added in future enhancements.

Tests

Added unit tests verifying that:

  • run_agent() executes a Cortex Agent request and returns the expected response.
  • Thread identifiers are correctly included in the request payload.
  • Optional request parameters are included when provided.
  • A ValueError is raised when thread_id is provided without parent_message_id.
  • HTTP errors returned by the Cortex Agents API are propagated to the caller.
  • A ValueError is raised when an access token is unavailable.
  • get_text_response() correctly extracts text content from agent responses.

Documentation

Docstrings have been added describing the hook and its public methods, including supported request parameters and response behavior.

Backwards Compatibility

This change is additive only and does not modify existing Snowflake provider functionality or public APIs.

@boring-cyborg boring-cyborg Bot added area:providers provider:snowflake Issues related to Snowflake provider labels Jun 24, 2026
@SameerMesiah97
SameerMesiah97 force-pushed the SnowflakeCortexAgentHook branch from ce974bc to 4ec3220 Compare June 24, 2026 11:19
@SameerMesiah97
SameerMesiah97 force-pushed the SnowflakeCortexAgentHook branch 2 times, most recently from 69f020d to 45cfbea Compare June 25, 2026 15:10
@SameerMesiah97
SameerMesiah97 marked this pull request as ready for review June 25, 2026 18:13
@SameerMesiah97
SameerMesiah97 requested a review from potiuk as a code owner June 25, 2026 18:13
@SameerMesiah97
SameerMesiah97 marked this pull request as draft June 25, 2026 18:13
@SameerMesiah97
SameerMesiah97 force-pushed the SnowflakeCortexAgentHook branch from 45cfbea to 7266785 Compare June 26, 2026 10:12
@SameerMesiah97
SameerMesiah97 marked this pull request as ready for review June 30, 2026 12:08

@justinpakzad justinpakzad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR. I left a couple of comments.

Sameer Mesiah added 2 commits July 1, 2026 21:14
the Snowflake REST API and extracting text responses.

Includes unit tests covering successful execution, threaded
conversations, optional parameters, and error handling.
@SameerMesiah97
SameerMesiah97 force-pushed the SnowflakeCortexAgentHook branch from 7266785 to 6b44829 Compare July 1, 2026 20:14
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 2, 2026
@justinpakzad

Copy link
Copy Markdown
Contributor

Thanks for the updates. Were you able to run this end-to-end against an actual Snowflake instance? Not sure if it's a hard requirement but feels worth doing for a new hook.

@SameerMesiah97

Copy link
Copy Markdown
Contributor Author

Thanks for the updates. Were you able to run this end-to-end against an actual Snowflake instance? Not sure if it's a hard requirement but feels worth doing for a new hook.

Yes. I have tested the hook with a DAG that has task for different types of prompts and it is behaving as expected.

@justinpakzad

Copy link
Copy Markdown
Contributor

Yes. I have tested the hook with a DAG that has task for different types of prompts and it is behaving as expected.

Sounds good. Thanks for confirming.

@vincbeck
vincbeck merged commit f6acde5 into apache:main Jul 6, 2026
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:snowflake Issues related to Snowflake provider ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants