I started to experience this recently in the last week or two, generally happening when I start a search directly from the firefox search bar, I get an invalid token error. Kagi refreshes automatically after a few seconds and I'm still logged in at that point, so I suspect a mechanism similar to the one mentioned above.