If the grid connection ever had a nodelink and was deleted,newly connected grids will not be considered by the agent

I am working on GridGarph. Connect or disconnect node by Script.
If I Remove the Off-mesh link and the connect gridnode at same position, the agent can’t find connect .
the agent us Aipath and repath auto every 0.5s.

there is code connect node and create Nodelink2;

    void ConnectNode(GraphNode startNode, GraphNode endNode)
    {
        GraphNode.Connect(startNode, endNode, 1000, OffMeshLinks.Directionality.TwoWay); 
    }
    void AddLink2(GraphNode start, GraphNode end)
    {
        var link2 = Instantiate(_tempLinkPrefab);
        link2.transform.position = (Vector3)start.position;
        link2.end.transform.position = (Vector3)end.position;
        link2.Apply();
    }
        //remove 
        if (Mouse.current.rightButton.isPressed)
        {
            EndPos = Mouse3D.GetMouseWorldPosition();
            var node = _graph.GetNearest(EndPos).node;
            node.GetConnections(x => GraphNode.Disconnect(node, x));

            var offMeshLinks = AstarPath.active.offMeshLinks;

            var linkNode = offMeshLinks.GetNearest(EndPos,0.5f);
            if (linkNode.link !=null)
            {
                Destroy(linkNode.gameObject);
            }

            return;
        }

Make sure to only modify connections in a work item:

Hi,thank for reply so quick.
how about nodelink should modify in work item too?

The NodeLink2 comonent does not need to be modified during work items.
Any modifications to them will only affect the graph after the next update, though, since it internally schedules a work item.

I had try do this. it’s not fixed.

    void ConnectNode(GraphNode startNode, GraphNode endNode)
    {
        AstarPath.active.AddWorkItem(new AstarWorkItem(ctx =>
        {
            GraphNode.Connect(startNode, endNode, 1000, OffMeshLinks.Directionality.TwoWay); //单向
        }));
 
    }

and I find that if I Creat Link2 on other place and Destroy them, the agent will be find the path which there no find before.