re-write Agent to use new QCA infrastructure