microsoft/autogen · error · ValueError

Start node '{node_name}' must be added before setting as ent

Error message

Start node '{node_name}' must be added before setting as entry point.

What it means

DiGraphBuilder.set_entry_point() raises ValueError when the named node has not yet been added to the builder via add_node(). The builder validates that the entry point references an existing node before assigning it as the graph's default start node. This prevents building a DiGraph whose default_start_node points to a nonexistent node.

Source

Thrown at python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_graph_builder.py:194

            Self for method chaining
        """

        warnings.warn(
            "add_conditional_edges will be changed in the future to support callable conditions. "
            "For now, please use add_edge if you need to specify custom conditions.",
            DeprecationWarning,
            stacklevel=2,
        )

        for condition_keyword, target in condition_to_target.items():
            self.add_edge(source, target, condition=condition_keyword)
        return self

    def set_entry_point(self, name: Union[str, ChatAgent]) -> "DiGraphBuilder":
        """Set the default start node of the graph."""
        node_name = self._get_name(name)
        if node_name not in self.nodes:
            raise ValueError(f"Start node '{node_name}' must be added before setting as entry point.")
        self._default_start_node = node_name
        return self

    def build(self) -> DiGraph:
        """Build and validate the DiGraph."""
        graph = DiGraph(
            nodes=self.nodes,
            default_start_node=self._default_start_node,
        )
        graph.graph_validate()
        return graph

    def get_participants(self) -> list[ChatAgent]:
        """Return the list of agents in the builder, in insertion order."""
        return list(self.agents.values())

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Call builder.add_node(agent) (or add_node(name=...)) for the entry node before set_entry_point(...).
  2. If passing a ChatAgent to set_entry_point, pass the exact same agent object (or its .name) that was registered with add_node.
  3. Assert membership first: if name not in builder.nodes: builder.add_node(...) before setting the entry point.

Example fix

# before
builder = DiGraphBuilder()
builder.set_entry_point("researcher")  # ValueError: not added yet
builder.add_node(researcher_agent)

# after
builder = DiGraphBuilder()
builder.add_node(researcher_agent)
builder.set_entry_point(researcher_agent)  # or "researcher" if that is its name
Defensive patterns

Strategy: validation

Validate before calling

name = agent.name
if name not in builder.nodes:
    builder.add_node(agent)
builder.set_entry_point(name)

Type guard

def is_registered_node(builder: DiGraphBuilder, name: str) -> bool:
    return name in builder.nodes

Try / catch

try:
    builder.set_entry_point(name)
except ValueError as e:
    raise ValueError(f"Entry point '{name}' not added. Known nodes: {list(builder.nodes)}") from e

Prevention

When it happens

Trigger: Calling DiGraphBuilder().set_entry_point("agent1") (or passing a ChatAgent instance whose name was never added) before calling add_node() for that name; also renaming an agent after set_entry_point or using a name with a typo.

Common situations: Building a GraphFlow/DiGraph topology where the developer wires the entry point first and adds nodes afterwards; using an AssistantAgent's name string that differs from the name used in add_agent(); copy-paste node names between examples.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/2f7e11926f9e6122. Report an issue: GitHub.