Skip to content

Commit 244a819

Browse files
committed
Use FinishReasonNull for EOF fallthrough with no output
When the stream ends via EOF without an explicit finish reason and produces no content or tool calls, use FinishReasonNull instead of FinishReasonStop. The provider never signalled natural completion, so claiming stop would give clients a false signal.
1 parent a35226f commit 244a819

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/runtime/streaming.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ func (r *LocalRuntime) handleStream(ctx context.Context, stream chat.MessageStre
196196

197197
finishReason := chat.FinishReasonToolCalls
198198
if stoppedDueToNoOutput {
199-
finishReason = chat.FinishReasonStop
199+
// No finish reason was received from the provider and the stream
200+
// produced nothing. Use FinishReasonNull rather than FinishReasonStop
201+
// so clients don't mistake this for a natural completion.
202+
finishReason = chat.FinishReasonNull
200203
}
201204

202205
return streamResult{

0 commit comments

Comments
 (0)