Skip to content

fix(gemini): correctly map finishReason for MAX_TOKENS, SAFETY, and R…#6

Open
MD-Mushfiqur123 wants to merge 1 commit into
masterfrom
fix-gemini-finish-reason
Open

fix(gemini): correctly map finishReason for MAX_TOKENS, SAFETY, and R…#6
MD-Mushfiqur123 wants to merge 1 commit into
masterfrom
fix-gemini-finish-reason

Conversation

@MD-Mushfiqur123

Copy link
Copy Markdown
Owner

…ECITATION

The Gemini provider was mapping all finish reasons to "stop", including MAX_TOKENS (truncated responses) and SAFETY/RECITATION (blocked content). This caused the agent runner to treat truncated or filtered responses as successful completions.

Added a mapFinishReason() helper that correctly maps:

  • STOP → stop
  • MAX_TOKENS → length
  • SAFETY → content_filter
  • RECITATION → content_filter
  • unknown → stop (fallback)

…ECITATION

The Gemini provider was mapping all finish reasons to "stop", including
MAX_TOKENS (truncated responses) and SAFETY/RECITATION (blocked content).
This caused the agent runner to treat truncated or filtered responses as
successful completions.

Added a mapFinishReason() helper that correctly maps:
- STOP → stop
- MAX_TOKENS → length
- SAFETY → content_filter
- RECITATION → content_filter
- unknown → stop (fallback)
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