وَمَنْ سَهَا عَنِ الْقَعْدَةِ الْأُولَى، ثُمَّ تَذَكَّرَ وَهُوَ إِلَى حَالِ الْقُعُودِ أَقْرَبُ: عَادَ فَجَلَسَ وَتَشَهَّدَ، وَإِنْ كَانَ إِلَى حَالِ الْقِيَامِ أَقْرَبَ: لَمْ يَعُدْ، وَسَجَدَ لِلسَّهْوِ.
Translation: If one forgets the first sitting and remembers while still closer to sitting, one returns, sits and recites tashahhud. If already closer to standing, one does not return; one performs sujud al-sahw.
The first sitting is wajib in Hanafi law. What matters is the physical stage when the omission is remembered: closer to sitting or closer to standing.
Once near full standing, one does not interrupt the standing to recover the missed wajib; sujud al-sahw compensates.