This repository was archived by the owner on Mar 29, 2026. It is now read-only.
fix: normalize OpenAI tool call arg keys and restore Snowflake session schema#1099
Open
lanzalibre wants to merge 2 commits into
Open
Conversation
gpt-4o-mini occasionally emits Python-style kwarg notation in tool call
JSON (e.g. {"question=": "value"} instead of {"question": "value"})
when function-call examples in the system prompt use keyword argument
syntax. This causes Pydantic validation to fail when the argument keys
do not match the expected field names.
Add a _normalize_args() helper that strips trailing '=' from all
argument dict keys, and apply it in both send_request() (non-streaming)
and stream_request() (streaming) tool call extraction paths.
Snowflake resets the active schema to the database default whenever USE DATABASE is executed. SnowflakeRunner was passing schema as a connector kwarg but then calling USE DATABASE inside run_sql(), which silently discarded the schema for the rest of the session. Extract schema from **kwargs at __init__ time and issue an explicit USE SCHEMA after USE DATABASE in run_sql() to guarantee the correct schema is always active.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Two runtime bugs found while integrating vanna2 with Snowflake and gpt-4o-mini:
OpenAI — trailing
=in tool call argument keys:gpt-4o-minioccasionally emits Python-style kwarg notation in tool call JSON (e.g.{"question=": "value"}instead of{"question": "value"}), causing Pydantic validation to fail. Fixed by adding a_normalize_args()helper that strips trailing=from all argument dict keys, applied in both the streaming and non-streaming code paths ofOpenAILlmService.Snowflake — schema reset after
USE DATABASE: Snowflake resets the active schema to the database default wheneverUSE DATABASEis executed.SnowflakeRunnerwas passingschemaas a connector kwarg but then callingUSE DATABASEinsiderun_sql(), silently discarding the configured schema for the duration of the query. Fixed by extractingschemafrom**kwargsat__init__time and issuing an explicitUSE SCHEMAafterUSE DATABASEinrun_sql().Test plan
gpt-4o-miniwithquestion=style keys are normalised and dispatched correctly