Repository navigation
fix(ai): pass safety settings on Google Interactions - #65036
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
The change looks sound. The new test fails on the base and passes with this change. The Interactions and Gemini tests pass (78/78), and tsc type-checks both packages/ai configs cleanly. I didn't call the real Google API.
Public API: Google Interactions provider options gain an optional safetySettings key, using the same shape as GenerateContent. This is additive and backwards compatible. The shared SafetySetting schema moved into the internal gemini-generate-content util; the GenerateContent wire format is unchanged.
I have no blocking concerns.
1 task
4 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
No linked issue.
Type of change
What does this PR do?
Google Interactions silently drops configured
safetySettings. I reused the GenerateContent option schema and translate the settings when building the Interactions request. No config or core changes are needed.safetySettings: [{ category: "HARM_CATEGORY_HARASSMENT", threshold: "BLOCK_LOW_AND_ABOVE" }] - Interactions request: no safety settings + Interactions request: safety_settings: [{ type: "harassment", threshold: "block_low_and_above" }]Google still validates the values. Interactions does not document equivalents for some GenerateContent values, including
BLOCK_NONEandHARM_CATEGORY_CIVIC_INTEGRITY.How did you verify your code works?
I added a regression test that checks the outgoing request body. All 43 Interactions tests passed, along with the AI package typecheck and
bun run check.I also sent both requests to Gemini Developer API v1beta on
gemini-3.8-flash: Google completed the request with a valid setting and returned HTTP 400 pointing tosafety_settings[0].typefor a bogus category. I did not probe Vertex.Screenshots / recordings
Not a UI change.
Checklist
Added by the opencode bot (AI-generated).
Public API: adds the optional
safetySettingsprovider option to Google Interactions (backwards compatible)