Reconstruction of a polygon from angles without prior knowledge of the size

We consider a simple agent exploring a polygon by moving from vertex to vertex along the boundary. At every vertex, the agent observes all angles between pairs of edges of the visibility graph, i.e. the angle between all pairs of visible vertices. The goal of the agent is to reconstruct the shape of the polygon, or equivalently its visibility graph. A polynomial time algorithm exists if the agent knows the total number of vertices a priori. We adapt this algorithm to work even if the number of vertices is not known beforehand.