Member Junction
    Preparing search index...

    Implementation of the Flow Agent Type pattern.

    This agent type enables deterministic workflow execution where agents follow predefined paths through a graph of steps. Key features:

    • Graph-based workflow definition
    • Conditional path evaluation using safe boolean expressions
    • Support for Actions, Sub-Agents, and Prompts as step types
    • Deterministic execution with optional AI-driven decision points

    FlowAgentType

    // Flow agents execute steps based on graph structure
    const flowAgent = new FlowAgentType();
    const nextStep = await flowAgent.DetermineNextStep(promptResult, payload);

    // Steps are determined by evaluating path conditions
    // Path: "payload.status == 'approved' && payload.amount < 1000"
    // Leads to: "Auto-Approve" step

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _jsonValidator: JSONValidator = ...

    JSON validator instance for cleaning and validating responses

    CURRENT_PAYLOAD_PLACEHOLDER: "_CURRENT_PAYLOAD" = '_CURRENT_PAYLOAD'

    Common placeholder for current payload injection

    Accessors

    • get InjectLoopResultsAsMessage(): boolean

      Flow agents don't need loop results injected as messages - they navigate paths

      Returns boolean

    • get RequiresAgentLevelPrompts(): boolean

      Flow agents don't require agent-level prompts - they use step-level prompts exclusively

      Returns boolean

    Methods

    • Flow agents apply ActionOutputMapping after each iteration

      Type Parameters

      • P

      Parameters

      • iterationResult: {
            actionResults?: ActionResult[];
            currentPayload: P;
            index: number;
            item: any;
            itemVariable: string;
            loopContext: any;
            subAgentResult?: any;
        }

      Returns P

    • Called before each loop iteration to prepare parameters and payload.

      Loop agents use this to resolve template variables ("item.email"). Flow agents typically don't need this (params already resolved).

      Type Parameters

      • P

      Parameters

      • context: {
            actionParams: Record<string, unknown>;
            index: number;
            item: any;
            itemVariable: string;
            loopType: "ForEach" | "While";
            payload: P;
            subAgentRequest?: {
                message: string;
                name: string;
                templateParameters?: Record<string, string>;
            };
        }

        Current iteration context

      Returns {
          actionParams?: Record<string, unknown>;
          payload?: P;
          subAgentRequest?: {
              message: string;
              name: string;
              templateParameters?: Record<string, string>;
          };
      }

      Modified context or null for default behavior

      2.112.0

    • Protected

      Creates a standardized next step object with common defaults

      Type Parameters

      • P

        The payload type

      Parameters

      • step:
            | "Actions"
            | "Chat"
            | "Failed"
            | "ForEach"
            | "Retry"
            | "Sub-Agent"
            | "Success"
            | "While"

        The step type

      • options: Partial<BaseAgentNextStep<P>> = {}

        Additional options to merge

      Returns BaseAgentNextStep<P>

      The next step object

    • Injects flow-specific context into the prompt parameters.

      Type Parameters

      • P = any
      • ATS = any

      Parameters

      • payload: P

        The payload to inject

      • agentState: ATS
      • prompt: AIPromptParams

        The prompt parameters to update

      • agentInfo: { agentId: string; agentRunId?: string }

        Agent identification info

      Returns Promise<void>

    • Processes action results and applies output mapping if configured This should be called by BaseAgent after action execution

      Type Parameters

      • P

      Parameters

      • actionResult: Record<string, unknown>
      • _stepId: string
      • OptionaloutputMapping: string
      • OptionalcurrentPayload: P

      Returns AgentPayloadChangeRequest<P>

    • Protected

      Instantiates the appropriate agent type class based on the agent type entity.

      This method uses the MemberJunction class factory to dynamically instantiate agent type classes. It uses the DriverClass field. If DriverClass is not specified it throws an error.

      Parameters

      Returns Promise<BaseAgentType>

      Instance of the agent type class

      // For an agent type with DriverClass "LoopAgentType"
      const agentTypeInstance = await this.getAgentTypeInstance(loopAgentType);

      @protected
    • Helper method that retrieves an instance of the agent type based on the provided agent type entity.

      This method uses the ClassFactory to create an instance of the agent type class specified in the DriverClass field of the agent type entity. If the DriverClass is not specified, it throws an error.

      Parameters

      Returns Promise<BaseAgentType>

      An instance of the agent type class

      GetAgentTypeInstance

      If the agent type does not have a DriverClass specified or if instantiation fails