Repository navigation
Python: map Vertex AI RECITATION/BLOCKLIST/PROHIBITED_CONTENT/SPII finish reasons to CONTENT_FILTER - #14712
Open
alexcastgonz (pcbeingused333) wants to merge 1 commit into
Conversation
…nish reasons to CONTENT_FILTER The Vertex AI connector only mapped SAFETY to CONTENT_FILTER, so responses Gemini stopped for recitation, blocklist, prohibited content or SPII came back with finish_reason=None. Map them the same way the Google AI connector already does.
alexcastgonz (pcbeingused333)
deployed
to
github-app-auth
November 3, 2026 03:30 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the Vertex AI finish-reason mapping update.
No open issues 🎉
What changed in this PR
Aligns the Vertex AI connector with the Google AI connector by mapping additional content-related finish reasons to CONTENT_FILTER.
Changes:
- Maps
SAFETY,RECITATION,BLOCKLIST,PROHIBITED_CONTENT, andSPIIthrough a shared immutable set. - Preserves existing handling of
STOP,MAX_TOKENS, and unrelated reasons. - Adds parametrized tests covering all five content-filter reasons.
| File | Description |
|---|---|
python/tests/unit/connectors/ai/google/vertex_ai/services/test_vertex_ai_utils.py |
Adds coverage for all five content-filter finish reasons. |
python/semantic_kernel/connectors/ai/google/vertex_ai/services/utils.py |
Expands the Vertex AI content-filter mapping using a shared set. |
Review effort: Balanced
This branch was successfully deployed
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.
Motivation and Context
The Vertex AI connector's
finish_reason_from_vertex_ai_to_semantic_kernelonly mappedSAFETYtoFinishReason.CONTENT_FILTER. When Gemini on Vertex AI stopped a response forRECITATION,BLOCKLIST,PROHIBITED_CONTENTorSPII, the result came back withfinish_reason=None, so callers could not tell a content stop from an unknown one. The Google AI connector already maps these reasons toCONTENT_FILTER; this brings the Vertex AI connector in line.Description
Add a
_VERTEX_AI_CONTENT_FILTER_REASONSset (SAFETY,RECITATION,BLOCKLIST,PROHIBITED_CONTENT,SPII) and map any member toCONTENT_FILTER.STOP,MAX_TOKENSand unrelated reasons behave as before.Added a parametrized test in
test_vertex_ai_utils.pycovering the five reasons. It fails on main (4 of the new cases) and passes with the change; the file passes (15), andruff format --check/ruff checkare clean.Contribution Checklist
This pull request was prepared with the assistance of an AI coding agent (Claude Code) and submitted by Alex Castillo, who is responsible for its content.