{"record":{"id":"2f2b133c2b0a75f8","repo":"microsoft/autogen","slug":"graph-must-have-at-least-one-start-node","errorCode":null,"errorMessage":"Graph must have at least one start node","messagePattern":"Graph must have at least one start node","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py","lineNumber":213,"sourceCode":"                if dfs(node):\n                    has_cycle = True\n\n        return has_cycle\n\n    def get_has_cycles(self) -> bool:\n        \"\"\"Indicates if the graph has at least one cycle (with valid exit conditions).\"\"\"\n        if self._has_cycles is None:\n            self._has_cycles = self.has_cycles_with_exit()\n\n        return self._has_cycles\n\n    def graph_validate(self) -> None:\n        \"\"\"Validate graph structure and execution rules.\"\"\"\n        if not self.nodes:\n            raise ValueError(\"Graph has no nodes.\")\n\n        if not self.get_start_nodes():\n            raise ValueError(\"Graph must have at least one start node\")\n\n        if not self.get_leaf_nodes():\n            raise ValueError(\"Graph must have at least one leaf node\")\n\n        # Outgoing edge condition validation (per node)\n        for node in self.nodes.values():\n            # Check that if a node has an outgoing conditional edge, then all outgoing edges are conditional\n            has_condition = any(\n                edge.condition is not None or edge.condition_function is not None for edge in node.edges\n            )\n            has_unconditioned = any(edge.condition is None and edge.condition_function is None for edge in node.edges)\n            if has_condition and has_unconditioned:\n                raise ValueError(f\"Node '{node.name}' has a mix of conditional and unconditional edges.\")\n\n        # Validate activation conditions across all edges in the graph\n        self._validate_activation_conditions()\n\n        self._has_cycles = self.has_cycles_with_exit()","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py#L195-L231","documentation":"Raised by DiGraph.graph_validate when the graph has nodes but no start node — a node with no incoming edges. Execution begins at start nodes, so a graph where every node has an incoming edge (e.g. everything is in a cycle or all edges were added in a closed chain) has no valid entry point and is rejected.","triggerScenarios":"Creating only cyclic edges (A->B, B->A) so every node has an incoming edge; explicitly calling set_start_node on a node that nonetheless receives an incoming edge later, disqualifying it; building a graph where the intended entry node was accidentally given a parent.","commonSituations":"Cyclic review loops with no designated entry; forgetting to branch the first node out; refactoring that adds an edge into the former start node.","solutions":["Designate an entry node with no incoming edges (builder.set_start_node(first_agent)) and make sure no edge targets it.","For loops, add a dedicated starter node whose only edge leads into the cycle.","Inspect builder.nodes and each node's incoming edges to confirm exactly which nodes qualify as start nodes."],"exampleFix":"// before\nbuilder.add_edge(reviewer, reviser)\nbuilder.add_edge(reviser, reviewer)  # no start node possible\n\n// after\nbuilder.add_edge(triage, reviewer)\nbuilder.add_edge(reviewer, reviser, condition=\"needs work\")\nbuilder.add_edge(reviser, reviewer, condition_function=lambda m: not _done(m))\nbuilder.set_start_node(triage)","handlingStrategy":"validation","validationCode":"graph = builder.build()\nif not graph.get_start_nodes():\n    raise ValueError(\"No start node: ensure one node has no incoming edges and call set_start_node\")\nflow = GraphFlow(participants, graph_builder=builder)","typeGuard":"def has_start_node(incoming: dict[str, int]) -> bool:\n    return any(count == 0 for count in incoming.values())","tryCatchPattern":"try:\n    flow = GraphFlow(participants, graph_builder=builder)\nexcept ValueError as e:\n    if \"at least one start node\" in str(e):\n        # add an entry node with no incoming edges and set_start_node on it\n        ...","preventionTips":["Always include a dedicated entry (triage) node in cyclic workflows.","Never point an edge back into the designated start node.","Visualize the graph (dot export) during development to spot missing entries."],"tags":["graph","validation","start-node","workflow"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}