# agent: Make messages vec cheap to clone \(\#57712\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 63ff99795c1294dfdb71e5f64fffee3d08744b9d

Requested commit: 63ff99795c1294dfdb71e5f64fffee3d08744b9d

Commit: 63ff99795c1294dfdb71e5f64fffee3d08744b9d

Tree: 2754e7a71549bda87424252a624130d728861107

Author: Lukas Wirth

Committer: GitHub

## Message

```
agent: Make messages vec cheap to clone  (#57712)

For long threads we will spend more and more time cloning the messages
just to save them to the database, as we need a copy of everything to do
so asynchronously. Messages are really expensive to clone though and we
accumulate a lot of them really fast, so even for smaller threads we
start seeing pauses in the millisecond range. The fix to this is fairly
simple though, we never mutate the messages once pushed to the vec, so
just Arc them.

This PR also slightly changes `UserMessage` to be a bit faster to clone
as well.

Release Notes:

- Fixed a cause of stutters when interacting with the agent
```

## Parents

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

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