As a workaround, I've added this ReaScript before running the action (repeats the bpm at the end of the time selection when needed to avoid change in bpm)
Code:
tsStart, tsEnd = reaper.GetSet_LoopTimeRange2(0, false, false, 0, 0, false)
activeTempoIndex = reaper.FindTempoTimeSigMarker(0, tsEnd + 0.01)
if activeTempoIndex > -1 then
retval, timepos, measurepos, beatpos, bpm, timesig_num, timesig_denom, lineartempo = reaper.GetTempoTimeSigMarker(0, activeTempoIndex)
if (reaper.TimeMap2_GetDividedBpmAtTime(0, tsStart - 0.01) ~= (reaper.TimeMap2_GetDividedBpmAtTime(0, tsEnd + 0.01))) then
if timepos < tsEnd then
reaper.AddTempoTimeSigMarker(0, tsEnd, bpm, timesig_num, timesig_denom, lineartempo)
reaper.UpdateTimeline()
elseif timepos == tsEnd then
reaper.SetTempoTimeSigMarker(0, activeTempoIndex, timepos, measurepos, beatpos, reaper.TimeMap2_GetDividedBpmAtTime(0, tsEnd + 0.01), timesig_num, timesig_denom, lineartempo)
reaper.UpdateTimeline()
end
end
end