Skip to content

track finish reason in stream processing and update message accordingly#516

Merged
ilvalerione merged 1 commit intoneuron-core:3.xfrom
joecharm:Gemini-Stream-Finish-Reason
Mar 20, 2026
Merged

track finish reason in stream processing and update message accordingly#516
ilvalerione merged 1 commit intoneuron-core:3.xfrom
joecharm:Gemini-Stream-Finish-Reason

Conversation

@joecharm
Copy link
Contributor

When Gemini/Vertex AI blocks content via safety filters mid-stream, the final chunk contains a finishReason of SAFETY.

The streaming path was silently discarding this value, so AssistantMessage::stopReason() always returned null after streaming making it impossible to distinguish a normal completion from a moderation block.

  • Track finishReason from each stream chunk (the last value seen is authoritative)
  • Call $message->setStopReason() on the returned AssistantMessage after the stream loop
  • Change readLine visibility from private to protected to allow subclassing without full duplication

@ilvalerione ilvalerione merged commit 5a605d4 into neuron-core:3.x Mar 20, 2026
11 checks passed
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.

2 participants