Skip to content

update_gemini_kwargs mutates caller generation config #2465

Description

@lntutor

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:

{"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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions