How does the obstacle avoidance of PX4 work in mission mode?

Hello,
I’m trying to implement something similar to the existing obstacle avoidance.
My question is how exactly is a new waypoint inserted in the current mission to go around an obstacle?
MAVSDK, as far as I know, doesn’t provide an option to insert a waypoint into a current mission.
Or does the obstacle avoidance use another technique?
The problem is that currently I’m inserting a waypoint and afterwards upload the mission again, which in my opinion isn’t optimal.
Thanks.