The code at https://gerrit.wikimedia.org/g/operations/mediawiki-config/+/66a3710620a8693b7c3666e0584a7c7d042e75a5/wmf-config/CommonSettings.php#2226 checks if the value of the action parameter in the main context request is visualeditoredit (or discussiontoolsedit). This caused T426751: Stuck in FancyCaptcha challenge loop on VisualEditor when ApiEditPage was updated to also set the main context request to the API request (it only set $wgRequest before that). The core patch was reverted again and I've since filed T426894: Fix discrepancy between $wgRequest and the main context request in ApiEditPage, which is now blocked by this task.
The code should no longer depend on action=visualeditoredit/action=discussiontoolsedit in the main context request, but instead check if the current edit is a VE/DiscussionTools edit through $_REQUEST.