Member Junction
    Preparing search index...

    Universal ForEach loop configuration used by all agent types. Flow agents convert AIAgentStep configuration to this format. Loop agents receive this from LLM responses.

    2.112.0

    interface ForEachOperation {
        action?: {
            name: string;
            outputMapping?: string;
            params: Record<string, unknown>;
        };
        collectionPath: string;
        continueOnError?: boolean;
        delayBetweenIterationsMs?: number;
        executionMode?: "sequential"
        | "parallel";
        indexVariable?: string;
        itemVariable?: string;
        maxConcurrency?: number;
        maxIterations?: number;
        prompt?: {
            name: string;
            outputMapping?: string;
            templateParameters?: Record<string, string>;
        };
        subAgent?: {
            context?: unknown;
            message: string;
            name: string;
            templateParameters?: Record<string, string>;
        };
    }
    Index

    Properties

    action?: {
        name: string;
        outputMapping?: string;
        params: Record<string, unknown>;
    }

    Execute action per iteration

    collectionPath: string

    Path in payload to array to iterate over

    continueOnError?: boolean

    Continue processing if an iteration fails (default: false)

    delayBetweenIterationsMs?: number

    Delay between iterations in milliseconds (default: 0)

    executionMode?: "sequential" | "parallel"

    Execution mode for iterations (default: 'sequential')

    • 'sequential': Process iterations one at a time in order (safest, maintains order, good for state accumulation)
    • 'parallel': Process multiple iterations concurrently (faster for independent operations like web scraping, API calls)

    2.113.0

    indexVariable?: string

    Variable name for loop index (default: "index")

    itemVariable?: string

    Variable name for current item (default: "item")

    maxConcurrency?: number

    Maximum number of iterations to process concurrently when executionMode='parallel' (default: 10) Only applies when executionMode='parallel'. Controls batch size to prevent resource exhaustion. Recommended values:

    • I/O-bound operations (API calls, web scraping): 10-20
    • CPU-bound operations (data processing): CPU core count
    • Sub-agent spawning: 2-5 (agents are resource-intensive)

    2.113.0

    maxIterations?: number

    Maximum iterations. undefined takes the default (1000); any other value is the limit, INCLUDING 0, which means zero iterations rather than unlimited.

    This corrects a long-standing comment that said 0=unlimited. The engines have always computed Math.min(collection.length, maxIterations ?? 1000), so zero has always meant zero — the comment described an intent the code never implemented.

    prompt?: {
        name: string;
        outputMapping?: string;
        templateParameters?: Record<string, string>;
    }

    Execute a prompt per iteration.

    The cheapest loop body there is: one model call per item with no agent wrapper, no reasoning loop, no guardrails and no run record. Right whenever an iteration is a single transformation — classify this, extract these fields, describe this column — and wrong the moment an iteration needs to decide what to do next, which is what a sub-agent is for.

    Type Declaration

    • name: string
    • OptionaloutputMapping?: string

      JSON mapping from the prompt's response into the payload, per iteration.

    • OptionaltemplateParameters?: Record<string, string>

      Values bound into the prompt's template, alongside the loop's own item and index.

    subAgent?: {
        context?: unknown;
        message: string;
        name: string;
        templateParameters?: Record<string, string>;
    }

    Execute sub-agent per iteration

    Type Declaration

    • Optionalcontext?: unknown

      Runtime context propagated to the sub-agent. Allows sub-agents to access API keys, environment settings, and other runtime configuration from the parent agent.

      2.127.0

    • message: string
    • name: string
    • OptionaltemplateParameters?: Record<string, string>