consolidate agent code