# agent: Fix a UTF-8 boundary panic in the agent streaming parser \(\#58432\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 19b7625a67351a5a574b73f010145b1d050559c2

Requested commit: 19b7625a67351a5a574b73f010145b1d050559c2

Commit: 19b7625a67351a5a574b73f010145b1d050559c2

Tree: 34411129b925592e3084273b30ce881ac87c00a6

Author: Anthony Eid

Committer: GitHub

## Message

```
agent: Fix a UTF-8 boundary panic in the agent streaming parser (#58432)

The parser stores emitted byte offsets between partial tool-call parses.
Because partial JSON can be repaired differently as more bytes arrive, a
byte offset that was valid in an earlier string can land inside a
multibyte character in a later string. We now normalize those offsets
with `find_char_boundary` before slicing.

Added property tests covering boundary-sensitive write/edit streaming
sequences to prevent regressions.

Fixes Sentry ZED-8Y1 / 7523469866.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed a crash that could occur while streaming agent edits containing
multibyte characters.
```

## Parents

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

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