Fixes#4413. Anthropic API rejects requests where the final assistant
message ends with trailing whitespace (400 invalid_request_error).
This strips trailing whitespace from the last assistant message content
in _format_messages_for_anthropic, handling both string and list content.
Co-Authored-By: João <joao@crewai.com>