While running the /compact command and queueing a message the message is instantly sent.
Tried fixing it on my own - figured out that isBusy() is checking only whether the session is in the pending state, but the session could also be compacting which isn't setting the pending state.
I got to the point where it will wait for the compacting to end but the queued message pops up in the history and there is no callback from the model provider.