I imagine you're doing something like this:
- In a header/footer, there's a link to an inventory passage.
- The inventory passage returns to the last passage, either by going to (history:)'s last or by saving the passage name to a variable.
- In a given passage, you add a stone to the player's inventory.
If this is true, then whatever code is happening in the final point is triggering each time that passage is navigated to by the player, whether they're going there the first time or returning from the inventory, which is intended; harlowe has no way of knowing that one of those passages is a "menu" that the player needs to return from without side effects.
There are a number of ways to fix this problem. My suggestion is generally to tie certain variable changes to player action rather than just the location. If you're setting a variable that is simply a discreet value, like a chapter number, you can set that anywhere. However, variables changes that should only happen once, like adding to player stats or an inventory, I think should be used as part of the links that transition players. So in this case, you'd do something like
(set: $inv to it + (a: 'stone'))
(goto: 'some passage')
and that code would go in the preceding passage, replacing the normal passage link. Unfortunately, you'll lose the passage connections in your story map. To get the arrows back if you want them, you can use a commented out link:
<!-- [[some passage]] -->
Again, this is just the way I try to avoid this issue. There are other ways, but many of them depend on your specific needs.