Sitic added a comment.
Mentioning here for reference, the recent change seems to have caused T89702: Edits fail with "badtoken: Invalid token" after script runs for a while https://phabricator.wikimedia.org/T89702. Village pump (technical)#How long does it take for a session timeout? https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(technical)&oldid=649751259#How_long_does_it_take_for_a_session_timeout.3F:
The test fetching the edit token at the beginning and end of the run should certainly have not given you the same token each time; even fetching two tokens one second apart should give you two different tokens (but both valid) since the end of October. Since you got the same token hours apart, whatever you're using to fetch the tokens is apparently caching them rather than fetching a new one the second time.
Ideally, your bot should be able to attempt the edit, and if it gets a badtoken error it should automatically fetch a fresh token and retry the edit.
As for the time it takes, the configuration is currently using the default of 1 hour for $wgObjectCacheSessionExpiry. I don't see any recent changes to the timeout, but I do see there was this recent change to session handling that probably made page views no longer reset the session timer. Anomieā 13:05, 3 March 2015 (UTC)
TASK DETAIL https://phabricator.wikimedia.org/T61678
REPLY HANDLER ACTIONS Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign <username>.
EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Sitic Cc: Sitic, Qgil, Daniel_Mietchen, jayvdb, valhallasw, Ricordisamoa, 555, Multichill, Ladsgroup, pywikipedia-bugs