I really wanted something like this in the game, too. In order to avoid accidentally losing something that I'd like to buy back, maybe don't do it on rests but with a conversation option with the merchant: "Could you declutter your inventory, I won't need to buy buck anything I've sold you.", etc. Or with a button somewhere in the traiding screen.
Of course, don't remove any quest items. Will be a nice optimisation for the save file size. I haven't noticed stuttering, but that also. And improved clarity in the shop inventory.