def try_actuate_agent(self, step_infos, stage="before_step"):
        """
        Some policies should make decision before physics world actuation, in particular, those need decision-making
        But other policies like ReplayPolicy should be called in after_step, as they already know the final state and
        exempt the requirement for rolling out the dynamic system to get it.
        """
        assert stage == "before_step" or stage == "after_step"
        for agent_id in self.active_agents.keys():
            policy = self.get_policy(self._agent_to_object[agent_id])
            is_replay = isinstance(policy, ReplayTrafficParticipantPolicy)
            assert policy is not None, "No policy is set for agent {}".format(agent_id)
            if is_replay:
                if stage == "after_step":
                    policy.act(agent_id)
                    step_infos[agent_id] = policy.get_action_info()
                else:
                    step_infos[agent_id] = self.get_agent(agent_id).before_step([0, 0])
            else:
                if stage == "before_step":
                    action = policy.act(agent_id)
                    step_infos[agent_id] = policy.get_action_info()
                    step_infos[agent_id].update(self.get_agent(agent_id).before_step(action))

        return step_infos

        Some policies should make decision before physics world actuation, in particular, those need decision-making
        But other policies like ReplayPolicy should be called in after_step, as they already know the final state and
        exempt the requirement for rolling out the dynamic system to get it.
        
metadrive/manager/agent_manager.py