Greetings. There is no way to set messages to be retained in a MQTT Agent at this time, I would be interested to understand the use case for why it is a need for you.
A MQTT broker only retains the last update sent to a topic and a retained message is only sent when a client first subscribes to a topic. Assuming that the publishing interval on the IoT Gateway Agent is fairly quick, the amount of time that a client would get the retained message before getting the next message is limited.
Adding the ability to publish messages with the retain flag is a small enhancement but I would be interested to understand how it would be used.
Thanks!
-Ben Macri