The only thought I have is that it might be worth checking whether it matters how you select the item. If, for example, you usually select the desired item using the Return key, get into the habit, for a while (however many days you feel necessary to test), of using a mouse click instead. If the problem does not reoccur over the test period, that would suggest that the trigger method is relevant.
Alternatively, go straight to checking through your KM macros (and any other automation you have set up) whether your usual selection method (such as using Return) could be triggering some other macro or interaction, which is what I am getting at by suggesting the above test.
It's a double click that is betraying me. If I go down the list and double click it pastes the item that is currently at the top of the list. In addition the item that I double clicked on now moves to the top of the list. Given that I'm looking for a psychotherapist right now, we could start making jokes that double clicking in KM has sent me to therapy ;-).
If Safari is caching the clipboard and not noticing the change before pasting, that would be sad.
That said, it's possible the issue is with the web page and how it behaves.
I'm afraid there isn't anything I can do, the behaviour from Keyboard Maestro Engine is essentially:
Set the clipboard
Simulate Command-V.
Setting the clipboard is a synchronous action - that is, the clipboard is set in to the system clipboard at the time, there is no delay in it happening.
Simulating a key on the other hand is a queue action, and so the key is added to the queue and at some later time the application asks for the next key, and gets the Command-V and hands that to the system to activate the appropriate menu, in this case Paste (or possibly the web page intercepts the Command-V and does whatever it feels like - and this could be affected by extensions you have installed).
So there isn't any realistic way for the previous value of the clipboard to be pasted except by something somewhere caching it.
Ok, it's Safari (18.0.1) that is the main offender. If display the KM clipboard, scroll down and double-click on an item, I will get the existing contents of the system keyboard. The item I double-clicked on is moved to the top.
As an experiment, I tried Paste plain from the list and it works.
It now looks like a system-wide issue with your particular setup. Do you have any other applications that interact with the clipboard or extend it beyond the usual copy/cut/paste?
Do you (@mlevison) have any applications besides KM that might sometimes do this?
You could try booting in Safe mode, and then launching Keyboard Maestro, and then trying it to see if that resolves the behaviour - that might further indicate that it is a third party involved that is affecting the behaviour.
I've been away from my computer all weekend, and so I couldn't reply.
I had an app called Paste installed (via SetApp). I, was using it because it 1) syncs to my iOS devices and 2) gives me an infinite clipboard history.
Likely, it conflicted with KM's clipboard functionality.
Is there any way, I could get the KM clipboard to store more than 200 items? I often know that I copied something 10 days ago and can't find it. Would it be possible to set my queue length to 1000 or 10,000?
Taking that to be a typical example of why you want an incredibly long clipboard history, let's think about alternatives to having an incredibly long clipboard history! For instance...
If the "something" is in the form of text (rather than graphics, audio or whatever), You could write a macro, triggered by ⌘-C, that has a "copy" action but which also appends the text to a text file ("~/Documents/my incredibly long clipboard history.txt", perhaps!).
If you also wish to cache large amounts of other kinds of data, you could have a macro that either writes to disk in the appropriate formats, or perhaps devise a method that uses named clipboards.
Those are just ideas off the top of my head. The underlying point I wish to make that with KM you can, I am sure, devise a more organised system for your needs than chucking 10,000 into clipboard history and having a rummage through it. I could be wrong – in terms of your requirements and workflow preferences – and that's for you to judge... but I hope the point is clear, either way.
Indeed... rather than writing macros, might it not be easier to just file potentially valued data? Keeping everything you have copied would suggest a low signal-to-noise ratio... Wouldn't it be easy enough to paste potentially useful items into a text editor or, better, into something like Obsidian?
I don't mean to dismiss your question about extending the maximum number of items in KM's clipboard history (to which I do not know the answer), or to have the presumption to tell you how you should deal with your data. These are just ideas from my own perspective! "YMMV", as they used to say.