Adding an entry to recently_used.xbel crashes kactivitymanagerd

I’m writing a small Python utility to list/clean/add entries to the ~/.locale/share/recently_used.xbel file.

list and remove operations work OK, and I can even mass-remove entries without problems.

However the add operation, which, as far as I can tell, adds a valid entry in the xbel file, causes kactivitymanagerd to crash.

Is there a “nice” way to update the xbel file?

Running Kubuntu 24.04.