Repository navigation
Support PAT and key-pair auth in the Snowflake Cortex Agent hook - #73932
Merged
Merged
Conversation
Lee-W
force-pushed
the
snowflake-cortex-auth-model
branch
2 times, most recently
from
October 1, 2026 09:59
a6b4496 to
955a2c5
Compare
Lee-W
commented
Oct 1, 2026
Lee-W
marked this pull request as ready for review
October 1, 2026 12:36
Lee-W
requested review from
ashb,
gopidesupavan,
kaxil and
potiuk
as code owners
October 1, 2026 12:36
kaxil
reviewed
Oct 1, 2026
Lee-W
force-pushed
the
snowflake-cortex-auth-model
branch
from
October 2, 2026 06:48
955a2c5 to
cc80a25
Compare
SnowflakeCortexAgentHook only accepted an OAuth access token, so teams whose Snowflake connections use key-pair or programmatic access tokens could not call Cortex Agents without a second, OAuth-only connection. The SQL API hook already minted all three header kinds; pulling that logic into a shared token provider lets both hooks authenticate the same way and keeps a key-pair JWT cached across requests until its renewal window, instead of re-signing on every call. A renewal delta at or beyond the token lifetime now re-signs every call rather than handing out an expired JWT.
Cortex chat models could only be reached through the snowflake: model prefix with SNOWFLAKE_ACCOUNT and SNOWFLAKE_TOKEN set on the worker: one credential per worker, no secrets backend, and no key-pair auth since the JWT expires within an hour. Setting a password on a pydanticai connection failed outright because the base hook passes it as api_key, which SnowflakeProvider rejects. Building the provider from an existing Snowflake connection, with the token refreshed per request, lets long agent runs outlive a single JWT and reuses the auth teams already configured for their warehouse. The hook sits behind an optional common.ai extra so the provider keeps working without Common AI.
Lee-W
force-pushed
the
snowflake-cortex-auth-model
branch
from
October 6, 2026 03:15
cc80a25 to
5037697
Compare
1 task
This was referenced Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SnowflakeCortexAgentHookonly accepted an OAuth access token, so ones whoseSnowflake connections use key-pair or programmatic access tokens could not
call Cortex Agents without a second, OAuth-only connection. The SQL API hook
already minted all 3 header kinds; pulling that logic into a shared token
provider lets both hooks authenticate the same way and keeps a key-pair JWT
cached across requests until its renewal window, instead of re-signing on
every call. A renewal delta at or beyond the token lifetime now re-signs every
call rather than handing out an expired JWT.
It also adds
PydanticAISnowflakeHook(thepydanticai_snowflakeconnectiontype), which points a Common AI model at an existing Snowflake connection, so
Cortex chat completions reuse the same credentials.
A connection with
authenticator: programmatic_access_tokenand the PAT inPassword now also works for
SnowflakeHook, so one connection serves the SQLconnector, the SQL API hook and both Cortex hooks. Without a
hostextra, theCortex base URL now appends the connection's
regionthe waySnowflakeHook.account_identifierdoes, so locator-style accounts outside AWSus-west-2 reach the right host; a connection that uses an org-account
identifier but still sets
regiongets a region-suffixed host, as the SQL APIhook already does.
Was generative AI tooling used to co-author this PR?
Generated-by: [Claude] following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.