To prevent shareholders from switching projects, bondholders can include covenants prohibiting this in the debt contract. The effect of borrowing is likely to cause agency costs to be incurred, which costs would not be present if there were no borrowing. All such costs are priced into the interest rates or other terms in bond contracts. There are some devices which exist in financial markets to reduce the costs of agency conflicts. There are convertible bonds.
Bondholders can also have call provisions in the bond contract.
This allows the company to repurchase its bonds at a fixed price for a given period of time. This lets the bondholder initially assume that the company will make a decision adverse to the interests of bondholders, and thus set low prices on the bonds at initial issuance. But then, when the company does not take such a decision, the bond value increase which occurs can be captured by the company for its shareholders through exercising the call provision on the bonds at a price lower than the upwardly revised expectations would require. Were interest payments to be deducted from the cash flows, it would amount to double counting since the discounting process already considers the cost of capital in the form of the discount rate. The factory option is not wealth creating.