Skip to content

fix(ai): pass safety settings on Google Interactions - #65036

Merged
rekram1-node merged 1 commit into
devfrom
interactions-safety
Nov 20, 2026
Merged

rekram1-node merged 1 commit into
devfrom
interactions-safety

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

No linked issue.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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_NONE and HARM_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 to safety_settings[0].type for a bogus category. I did not probe Vertex.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Public API: adds the optional safetySettings provider option to Google Interactions (backwards compatible)

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rekram1-node
rekram1-node merged commit 7b6b285 into dev Nov 20, 2026
13 checks passed
@rekram1-node
rekram1-node deleted the interactions-safety branch November 20, 2026 01:38
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant