fix packing and unpacking of agent IDs