DOC: Issue in make_supervisor_node function in Hierarchical Agent Teams Tutorial #961

Closed
opened 2026-02-20 17:42:32 -05:00 by yindo · 1 comment
Owner

Originally created by @BirenMer on GitHub (Sep 6, 2025).

Issue with current documentation:

File Path: langgraph/docs/docs/tutorials/multi_agent/hierarchical_agent_teams.ipynb
Error in Helper Utils code block in the notebook (.ipynb file):

Parent Function: make_supervisor_node
Sub Function: Router

Full function code:

def make_supervisor_node(llm: BaseChatModel, members: list[str]) -> str:
    options = ["FINISH"] + members
    system_prompt = (
        "You are a supervisor tasked with managing a conversation between the"
        f" following workers: {members}. Given the following user request,"
        " respond with the worker to act next. Each worker will perform a"
        " task and respond with their results and status. When finished,"
        " respond with FINISH."
    )

    class Router(TypedDict):
        """Worker to route to next. If no workers needed, route to FINISH."""

        next: Literal[*options]

    def supervisor_node(state: State) -> Command[Literal[*members, "__end__"]]:
        """An LLM-based router."""
        messages = [
            {"role": "system", "content": system_prompt},
        ] + state["messages"]
        response = llm.with_structured_output(Router).invoke(messages)
        goto = response["next"]
        if goto == "FINISH":
            goto = END

        return Command(goto=goto, update={"next": goto})

    return supervisor_node

Error 1:

next: Literal[*options]
                  ^
SyntaxError: invalid syntax

Even if we fix this with:
next: Literal[tuple(Option)]

We encounter another error from the research agent which is calling the above make_supervisor_node function :

raise ValueError(f"Found edge ending at unknown node `{target}`")
ValueError: Found edge ending at unknown node `('search', 'web_scraper')`

Proposed fix in PR:
#6089

Originally created by @BirenMer on GitHub (Sep 6, 2025). ### Issue with current documentation: File Path: `langgraph/docs/docs/tutorials/multi_agent/hierarchical_agent_teams.ipynb` Error in Helper Utils code block in the notebook (.ipynb file): Parent Function: `make_supervisor_node` Sub Function: `Router` Full function code: ``` def make_supervisor_node(llm: BaseChatModel, members: list[str]) -> str: options = ["FINISH"] + members system_prompt = ( "You are a supervisor tasked with managing a conversation between the" f" following workers: {members}. Given the following user request," " respond with the worker to act next. Each worker will perform a" " task and respond with their results and status. When finished," " respond with FINISH." ) class Router(TypedDict): """Worker to route to next. If no workers needed, route to FINISH.""" next: Literal[*options] def supervisor_node(state: State) -> Command[Literal[*members, "__end__"]]: """An LLM-based router.""" messages = [ {"role": "system", "content": system_prompt}, ] + state["messages"] response = llm.with_structured_output(Router).invoke(messages) goto = response["next"] if goto == "FINISH": goto = END return Command(goto=goto, update={"next": goto}) return supervisor_node ``` Error 1: ``` next: Literal[*options] ^ SyntaxError: invalid syntax ``` Even if we fix this with: next: Literal[tuple(Option)] We encounter another error from the research agent which is calling the above `make_supervisor_node` function : ``` raise ValueError(f"Found edge ending at unknown node `{target}`") ValueError: Found edge ending at unknown node `('search', 'web_scraper')` ``` Proposed fix in PR: [#6089](https://github.com/langchain-ai/langgraph/pull/6089)
yindo added the documentation label 2026-02-20 17:42:32 -05:00
yindo closed this issue 2026-02-20 17:42:32 -05:00
Author
Owner

@sydney-runkle commented on GitHub (Sep 10, 2025):

Thanks for the fix - we're actually no longer using this example in our new docs site, so going to close for now.

We're rewriting our multi-agent docs though so we'll be sure to include supervisor patterns :)

@sydney-runkle commented on GitHub (Sep 10, 2025): Thanks for the fix - we're actually no longer using this example in our new docs [site](https://docs.langchain.com/oss/python/langchain/overview), so going to close for now. We're rewriting our multi-agent docs though so we'll be sure to include supervisor patterns :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#961