Bug
instructor.v2.providers.gemini.utils.update_gemini_kwargs() shallow-copies the request dictionary but mutates the nested generation_config dictionary in place while translating OpenAI-style keys.
Reproduction
from instructor.v2.providers.gemini import utils
utils._default_safety_thresholds = lambda: None
generation_config = {"max_tokens": 5}
utils.update_gemini_kwargs({"generation_config": generation_config})
print(generation_config)
Current output:
Expected:
The function should treat caller-owned configuration as read-only and return a normalized copy.
Impact
Reusing the same options dictionary for a retry or later request silently changes the accepted parameter names and can produce behavior that depends on call order.
Bug
instructor.v2.providers.gemini.utils.update_gemini_kwargs()shallow-copies the request dictionary but mutates the nestedgeneration_configdictionary in place while translating OpenAI-style keys.Reproduction
Current output:
{"max_output_tokens": 5}Expected:
{"max_tokens": 5}The function should treat caller-owned configuration as read-only and return a normalized copy.
Impact
Reusing the same options dictionary for a retry or later request silently changes the accepted parameter names and can produce behavior that depends on call order.