In the agent chat, each message has some actions you can take from it's context menu. Depending on the message type (chat, email, auto message), those options may very.
If during a chat you hit send too soon and realize you made some mistake, you can instantly correct your last message from this menu.
Alternative way is to put the cursor in the chat field and press the up arrow ↑ on your keyboard. Edit the message and send it again.
Note that only chat messages can be edited, and only if they were not resent on email as a reply notification.
Email messages have an additional opption to display original HTML version, as we do not display it in chat by default.