agent: Fix an issue with messages containing trailing whitespace (#33643)

Seeing this come up in our server logs when sending requests to
Anthropic: `final assistant content cannot end with trailing
whitespace`.


Release Notes:

- agent: Fixed an issue where Anthropic requests would sometimes fail
because of malformed assistant messages
ca0bd53bedBennet Bo Fenner committed on 6/30/2025, 9:31:40 AM· committed by GitHubparentae62371
2 files changedLine totals unavailable