The Yahoo disconnects appear to be related to proxy settings. Messages is strange in that it ignores system-wide proxy settings for GTalk and AIM, but adheres to them for Yahoo.
When it connects to Yahoo it will first try to do so through your HTTP proxy. If it cannot connect using the HTTP proxy, it tries a SOCKS proxy (assuming that you have one configured).
In my case Yahoo would initially connect through the HTTP proxy and then disconnect. There is some sort of exchange that goes on between the client and Yahoo after a few minutes of being connected, and it does not like doing this through the HTTP proxy. Strangely, even after telling OS X’s network settings to bypass the the proxy for the two Yahoo-related domains that Messages seems to connect to (info.yahoo.com and messenger.yahooapis.com) these connections continued to be made through the HTTP proxy.
As I mentioned earlier, Messenger will use a SOCKS proxy to connect to Yahoo if it cannot find an HTTP proxy. Since Messages ignores the proxy settings for AIM and GTalk, I created a rule in Little Snitch to block Messages from speaking to the HTTP proxy at all. It is currently connecting to Yahoo through my SOCKS proxy and has remained on-line without a disconnect for an hour now.
I also tried blocking Messages from connecting to both the SOCKS and HTTP proxy using Little Snitch, assuming that it would simply attempt to connect directly to Yahoo’s servers as it does with GTalk and AIM. Strangely, it refused to do so.
It should be noted that Messages as a process only deals with Apple’s stuff. AIM and GTalk are handled through a process called imagent, while Yahoo is dealt with by a process named IMServicePluginAgent. In my case, I had to block IMServicePluginAgent and Messages from using the HTTP proxy.
My scenario may not match other people’s given the slightly convoluted network configuration i have, but some of the info should be helpful in understanding how Messages works.