move usecacheonfailure in the agent part