Fix runagent denial with old protocol

The last commit is the important one, the rest are minor commits that had accumulated.