Member Junction
    Preparing search index...

    Shared cumulative budget and live usage counters across an entire root-to-leaf agent execution tree (including sequential and parallel sub-agents).

    A single AgentTreeBudget instance is created at the root of an agent execution (or supplied by the caller on ExecuteAgentParams.treeBudget) and passed by reference into every child, related, and parallel sub-agent invocation. Every agent in the hierarchy increments the shared counters (totalSteps, totalTokens, totalCost) and checks the shared ceilings (maxTreeSteps, maxTreeTokens, maxTreeCost, maxTreeDurationMs) before and after executing steps.

    interface AgentTreeBudget {
        breachedReason?: string;
        maxTreeCost?: number;
        maxTreeDurationMs?: number;
        maxTreeSteps?: number;
        maxTreeTokens?: number;
        startedAtMs: number;
        totalCost: number;
        totalSteps: number;
        totalTokens: number;
    }
    Index

    Properties

    breachedReason?: string

    Set to the breach reason once any tree limit is exceeded

    maxTreeCost?: number

    Maximum cumulative LLM cost (in USD) allowed across the entire agent tree

    maxTreeDurationMs?: number

    Maximum wall-clock duration (in milliseconds) allowed for the entire agent tree

    maxTreeSteps?: number

    Maximum total steps allowed across the entire root-to-leaf agent tree

    maxTreeTokens?: number

    Maximum total tokens (prompt + completion) allowed across the entire agent tree

    startedAtMs: number

    Epoch timestamp (Date.now()) when the root agent run started

    totalCost: number

    Live cumulative cost accumulator shared by reference across the agent tree (initialized to 0)

    totalSteps: number

    Live cumulative step counter shared by reference across the agent tree (initialized to 0)

    totalTokens: number

    Live cumulative token counter shared by reference across the agent tree (initialized to 0)