Praise be to Allah.
He must go back to the beginning, and if he did not do that, then let him repeat sa‘i now, because the first sa‘i was not valid, as he did not have the intention of doing it from the beginning, and he formed the intention whilst doing it. So now he must repeat sa‘i. End quote.
Majmoo‘ Fataawa Ibn ‘Uthaymeen (24/100)