Skip to content

Add SnowflakeCortexAgentHook#68942

Draft
SameerMesiah97 wants to merge 1 commit into
apache:mainfrom
SameerMesiah97:SnowflakeCortexAgentHook
Draft

Add SnowflakeCortexAgentHook#68942
SameerMesiah97 wants to merge 1 commit 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
the Snowflake REST API and extracting text responses.

Includes unit tests covering successful execution, threaded
conversations, optional parameters, and error handling.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant