Skip to content

fix(gemini): map RECITATION finish reason to content_filtered - #4898

Open
charan-rathore wants to merge 1 commit into
strands-agents:mainfrom
charan-rathore:fix-4723-recitation-stop
Open

charan-rathore wants to merge 1 commit into
strands-agents:mainfrom
charan-rathore:fix-4723-recitation-stop

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Description

Fixes #4723

GeminiModel mapped finishReason: RECITATION to end_turn, the same as an ordinary STOP, so callers could not tell a normal completion from a response cut off for recitation. SAFETY already maps to a distinct stop reason.

This maps RECITATION to content_filtered, which is already a member of the StopReason type ("Content was filtered due to policy violation"). Other Gemini finish reasons are unchanged.

Testing

  • Added RECITATION to the existing parametrized test_stream_response_without_usage_metadata. It fails on the old code and passes with the change.
  • pytest tests/strands/models/test_gemini.py: 79 passed. ruff check, ruff format --check and mypy on the touched files pass.
  • Not run: the full repo suite, integration tests that need a Gemini API key.

Prepared with AI assistance (Claude Code).

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
@charan-rathore
charan-rathore requested a review from a team as a code owner October 5, 2026 19:35
@github-actions github-actions Bot added the bug Something isn't working label Oct 5, 2026
@github-actions github-actions Bot added complexity/low Touched functions have low cognitive complexity (<=10) size/xs labels Oct 7, 2026
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@charan-rathore

Copy link
Copy Markdown
Contributor Author

Gentle nudge - this is approved and CI is green. Anything else you need from me before it can merge?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working complexity/low Touched functions have low cognitive complexity (<=10) size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] GeminiModel loses the RECITATION finish reason by mapping it to end_turn

2 participants