I got a follow-up PR ready in core, which adds a flag to DMenu to prevent these types of issues from re-occurring:
DMenu
Once that’s merged, I’ll revisit and follow-up in the AI plugin.