Assuming the next tangent is flat and I have unweighted curves, is there an equation I can use to calculate the maximum angle of the tangent on the first keyframe?

If you use weighted tangents, figure out the position of the handles for the second key (it will be time - weight, value). The tangent handle for the first key should be in the same spot as that handle: I think (back of the envelope and not tested) you want:

target_pos = (end time - end weight, end value)
start pos = (start_time + start weight, start value)
delta value = end_value - start value
deltat_time = start_time - target_pos.x
rotation = atan2( normalize(target_pos) - (0,1))
weight = sqrt of (delta time ^2) + (delta value ^ 2)

will give you the rotation and weight you need.

Any combination of rotation and weight that doesn’t put the first tangent’s handle higher than the value of the second keyframe will not overshoot