You can not completely avoid new items being generated, but you can limit that by not unnecessarily crafting or selling items to NPCs.
The issue is how far back you need to revert in order to not run into this problem again during the rest of the game. That would depend on how close you are to the end of the game, and when you did most of the crafting and selling.
If you are close to the end of the game, and do crafting and selling in batches, maybe going back before the last session of that would avoid the problem. If you are not very close to the end, and relatively frequently craft and trade, then it would be harder to guess how far back would give a reasonable chance of finishing the game without running into this again.
Unfortunately, the counter for the item handles is already at the maximum possible for how it is used in the code and stored in the data. That will be changed in D:OS 2, but it isn't feasible to do so for D:OS.