LangGraph.js API Reference
    Preparing search index...
    • Add a router to the currently active agent to the StateGraph.

      Type Parameters

      • AnnotationRootT extends AnnotationRoot<any> = AnnotationRoot<
            {
                activeAgent: {
                    Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
                    (): LastValue<string>;
                    (
                        annotation: SingleReducer<string, string>,
                    ): BinaryOperatorAggregate<string, string>;
                };
                messages: BinaryOperatorAggregate<
                    BaseMessage<MessageStructure, MessageType>[],
                    Messages,
                >;
            },
        >

      Parameters

      • builder: StateGraph<
            AnnotationRootT["spec"],
            AnnotationRootT["State"],
            AnnotationRootT["Update"],
            any,
            AnnotationRootT["spec"],
            AnnotationRootT["spec"],
        >

        The graph builder (StateGraph) to add the router to.

      • params: { defaultActiveAgent: string; routeTo: string[] }

        Parameters for the router.

        • defaultActiveAgent: string

          Name of the agent to route to by default (if no agents are currently active).

        • routeTo: string[]

          A list of agent (node) names to route to.

      Returns StateGraph<
          AnnotationRootT["spec"],
          AnnotationRootT["State"],
          AnnotationRootT["Update"],
          any,
          AnnotationRootT["spec"],
          AnnotationRootT["spec"],
      >

      StateGraph with the router added.