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
63ff99795cLukas Wirth committed on 5/26/2026, 10:00:34 AM· committed by GitHubparent49fe1fc
10 files changedLine totals unavailable