AH-HA!, I think now I get what's happening.
The item mix behavior is tricking you. Set it to "always mix" and in that case it will work with items of different lengths. So, if you put the action "Item: Set selected items mix behavior to always mix" at the top of that custom action, you hopefully are finally there
.
Maybe consider to put "Item: Set selected items mix behavior to default" at the end, if you need to switch back that option for the resulting item. [EDIT: that's not needed apparently the glued item is set to default anyway)
*knocks on wood*