Extend one side of rectangle - bad result

Hi. I am trying to create a flat 2D file with some modifications (dxf for CNC machine) from 3D objects but I am facing some issues.

I need to extend the side that is touching the external shape and I am getting wrong direction for extension in one of the curves.

To explain better what I want to achieve: create the 2D edges from the 3D object, the outside shape of the object to be create into the layer called “contour”, remove the vertical lines from the generated 3D edges, sort the geometry by depth of mechanisation and create a separate layer for each tool and depth used, extend the edge of the pockets that have a predefined length of one of the edges (in my case the ones with an 13mm edge) outside of the contour" edge with 10-20mm.

I am using custom components from the “Vipers” and “LunchBox” to simplify the things.

"Wrong_extend_Direction.gh (166.4 KB)