For finding the endpoints of confidence intervals for a shift, the p-value will generally be constant over a range of values of the shift.
Brentq will find a legitimate CI, but the lower endpoint might be unnecessarily low and the upper endpoint might be unnecessarily high.
The solution would seem to be to use something other than a root-finder to find the endpoints, or--if we do use a root-finder--to then try marching up or down to see whether the p-value changes.