Focal length affects DOF blur size

When you increase the focal length, it increases the blur size of the depth of field, and I don’t mean in the sense that it scales up with the image. I mean the DOF blur truly gets more intense.
I don’t know if this replicates the real optics of cameras but either way, I would like to cancel out the effect with mathematical precision because I’m writing an add-on that affects the focal length and I don’t want the DOF to change in consequence. Does anyone have any clue what the formula would be?

Nevermind. Using the sensor size instead of the focal length preserves the blur size so that’s an easier solution for me.