Skip to content

fix: Snowflake PAT auth and Claude streaming support - #38

Merged
mateo-di merged 1 commit into
carto/mainfrom
fix/snowflake-pat-and-claude-streaming
Dec 10, 2025
Merged

fix: Snowflake PAT auth and Claude streaming support#38
mateo-di merged 1 commit into
carto/mainfrom
fix/snowflake-pat-and-claude-streaming

Conversation

@josemaria-vilaplana

Copy link
Copy Markdown

This PR addresses two critical issues with the Snowflake provider:

1. PAT Token Authentication Failure

  • Fixed KeyError when using PAT tokens with pat/ prefix
  • Now correctly strips pat/ prefix and sets X-Snowflake-Authorization-Token-Type to PROGRAMMATIC_ACCESS_TOKEN instead of hardcoded KEYPAIR_JWT
  • Maintains backward compatibility with JWT tokens

2. Claude Model Streaming Failure

  • Fixed KeyError: 'created' when streaming with Claude models (sonnet-3.5, sonnet-4-5)
  • Implemented custom SnowflakeChatCompletionStreamingHandler that provides default timestamp when 'created' field is missing
  • Other models (mistral, llama) continue to work as before

Changes

  • litellm/llms/snowflake/chat/transformation.py: Added PAT detection logic and custom streaming handler
  • litellm/llms/snowflake/common_utils.py: Added PAT detection logic
  • tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py: Added comprehensive test coverage for both fixes

Testing

  • Added unit tests for JWT authentication (existing behavior)
  • Added unit tests for PAT authentication with pat/ prefix
  • Added unit tests for streaming with and without 'created' field
  • All tests verify backward compatibility

Model Compatibility

Model Authentication Streaming Status
mistral-7b JWT/PAT ✅ Has created ✅ Fixed
llama-3.3-70b JWT/PAT ✅ Has created ✅ Fixed
claude-sonnet-3-5 JWT/PAT ❌ No created ✅ Fixed
claude-sonnet-4-5 JWT/PAT ❌ No created ✅ Fixed

  - Add PAT token detection with pat/ prefix handling
  - Strip pat/ prefix and set PROGRAMMATIC_ACCESS_TOKEN header type
  - Add custom streaming handler for Claude models missing 'created' field

@mateo-di mateo-di left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@mateo-di
mateo-di merged commit 9ee08fe into carto/main Dec 10, 2025
5 of 6 checks passed
mateo-di added a commit that referenced this pull request Feb 10, 2026
…, #58

Port 5 CARTO features that were silently dropped during the v1.81.0
upstream sync due to class hierarchy refactoring:

- Add SnowflakeStreamingHandler for missing 'created' field and
  Claude-format tool_use -> OpenAI tool_calls transformation
- Add _transform_messages() for role="tool" -> Snowflake content_list
- Enhance _transform_tool_choice() to convert strings to Snowflake
  object format (e.g. "auto" -> {"type": "auto"})
- Add get_model_response_iterator() override
- Default tool_choice to "auto" when tools present in Responses API

Also adds .github/carto-features.yml manifest to track critical
customizations and prevent future sync regressions.
mateo-di added a commit that referenced this pull request Feb 10, 2026
Static registry of critical CARTO customizations that must survive
upstream syncs. The resolver should verify all patterns exist after
every sync to prevent silent feature regressions (like the OCI Gemini
and Snowflake tool calling drops in v1.81.0).

Tracks: OCI Gemini (#68), Snowflake streaming/tool calling (#38, #58),
Azure URL stripping (#70), JSON repair (#54), Redis sessions (#16).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants