renoise.song().instruments[]:delete_phrase_at(index) will also change the selected phrase. This isn’t documented or consistent with how other remove methods work.
It’s easy to work around, but you never know what weird stuff people are up to with the API so maybe it’s best to fix.
Do you mean the automatic change of the name of the phrase?
Renoise has an automatic way to rename phrases with the “Phrase XX” format, which I particularly don’t like. When adding or removing phrases, Renoise will rename the names. This is not from the API. But it is confusing. Because it’s actually renaming names that do exist. If you import a phrase with the name “Phrase 12” in the slot of phrase 03, that phrase will automatically be renamed to “Phrase 03”.
If a phrase is removed with the method I mentioned, renoise will change what phrase is currently selected. I’m not sure how to explain it better, but I’m pretty sure taktik knows.