# Emit ordinary stop events for Zed-hosted Gemini models \(\#64263\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/46ee98a8e0268cb85381413c01cd38d84b60ac67)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 46ee98a8e0268cb85381413c01cd38d84b60ac67

Requested commit: 46ee98a8e0268cb85381413c01cd38d84b60ac67

Commit: 46ee98a8e0268cb85381413c01cd38d84b60ac67

Tree: e998651220f99d6adf87147aa4d2da2344180464

Author: Cole Miller

Committer: GitHub

## Message

````
Emit ordinary stop events for Zed-hosted Gemini models (#64263)

Previously, the Gemini per-event mapper shared by Zed-hosted models and
BYOK recorded `finishReason`, but did not emit
`LanguageModelCompletionEvent::Stop` for ordinary text completions such
as:

```json
{
  "candidates": [
    {
      "index": 0,
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "What can I help you with today?"
          }
        ]
      },
      "finishReason": "STOP"
    }
  ]
}
```

The BYOK stream wrapper compensated by emitting the recorded stop reason
at EOF. The hosted path called the per-event mapper without that
wrapper, so completed text responses could reach consumers without a
`Stop` event.

This PR emits the stop event from the shared per-event mapper, after
processing the chunk’s content, while preserving tool-use and refusal
handling. It also removes the BYOK EOF-to-success fallback: a direct
stream ending without a completion signal now reports an unexpected-end
error instead of synthesizing successful completion.

Release Notes:
- N/A
````

## Parents

- [f092e5e9af23e128396be129ee8dedbe23561784](https://git.cafe/gitcafe/zed/commit/f092e5e9af23e128396be129ee8dedbe23561784?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/46ee98a8e0268cb85381413c01cd38d84b60ac67?format=markdown)
