Case 1: you keep training engineers.
Case 1.1: AGI soon, you don't need juniors or seniors besides a very few. You cost yourself a ton of money that competitors can reinvest into R&D, use to undercut your prices, or return to keep their investors happy.
Case 1.2: No AGI. Wages rise, a lot. You must remain in line with that to avoid losing those engineers you trained.
Case 2: You quit training juniors and let AI do the work.
Case 2.1: AGI soon, you have saved yourself a bundle of cash and remain mostly in in line with the market.
Case 2.2: no AGI, you are in the same bidding war for talent as everyone else, the same place you'd have been were you to have spent all that cash to train engineers. You now have a juicier balance sheet with which to enter this bidding war.
The only way out of this, you can probably see, is some sort of external co-ordination, as is the case with most of these situations. The high-EV move is to quit training juniors, by a mile, independently of whether AI can replace senior devs in a decade.