-
Notifications
You must be signed in to change notification settings - Fork 121
Description
The SDK jumbles up the order of fields in parameter schema json by running it through this line: https://github.com/googleapis/go-genai/blob/main/models.go#L4063C1-L4063C36 which converts the inputs to a nested map, which in golang do not have any ordering.
This breaks the core underlying feature of the model that it preserves generation order: https://blog.google/technology/developers/gemini-api-structured-outputs/
This also breaks stability of output when 0 temperature is used because the fields are jumbled by the map which makes the sequence of input tokens different.
Environment details
- Programming language: Golang
- OS: Mac Tahoe, Windows 11, WSL (Ubuntu)
- Language runtime version: go1.24.2 linux/amd64
- Package version: v1.38.0
Steps to reproduce
- Use 'SendMessage' API with any function call that takes a json schema with 2 or more properties
- https://github.com/googleapis/go-genai/blob/main/models.go#L4063C1-L4063C36 jumbles up the order before making the http request
Converting to a string with preserved order doesn't work either, the api errors out returning status 400. Using Google AI Studio, propertyOrder field doesn't seem to work either.
IMO this seems to be blocking issue and should have higher priority.