# agent: Do not create user messages for tool results in thread \(\#29354\) · gitcafe/zed

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

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

Visibility: public

Requested revision: f81e65ae7c78e5fc575d01079dc81acf89180a1b

Requested commit: f81e65ae7c78e5fc575d01079dc81acf89180a1b

Commit: f81e65ae7c78e5fc575d01079dc81acf89180a1b

Tree: 765e6c70b5e400c564684b264a73fca9eb075239

Author: Agus Zubiaga

Committer: GitHub

## Message

```
agent: Do not create user messages for tool results in thread (#29354)

We used to insert empty user messages into the `Thread::messages` `Vec`
when tools finished running and then we would attach the results when
creating the request. This approach was very easy to mess up during
state handling, leading to empty user messages displayed in the
conversation and API failures.

Instead, we will no longer insert actual user messages for tool results
to the `Thread`, and will only do this on the fly when creating the
model request. This simplifies a lot of code and show fix the mentioned
errors.

Release Notes:

- agent: Improve reliability of LLM requests when including tool results

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Co-authored-by: Oleksiy Syvokon <oleksiy.syvokon@gmail.com>
```

## Parents

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

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