Error handling improvements

This adds the ability for custom agents to be notified when their workers die, as well as ensures error messages are shipped to the server correctly.

The testing for agents has also been improved to cover agents re-requesting work after one of their workers has died (i.e. they don't just stop creating workers).