Member Junction
    Preparing search index...

    Tracks hierarchical token, cost, wall-clock duration, and step/attempt budgets across parent -> sub-agent execution trees.

    Index

    Constructors

    Methods

    • Ensures that a shared AgentTreeBudget instance exists for the current execution tree and is attached to params.treeBudget and fallbackParams.treeBudget.

      • When params.treeBudget is already provided (for example, propagated by a parent agent in ExecuteSubAgent or supplied directly by a caller), that exact object reference is reused so all root, sequential child, and parallel child runs mutate the same shared counters (totalSteps, totalTokens, totalCost, startedAtMs, breachedReason).
      • When params.treeBudget is absent (root run), a new AgentTreeBudget is created and seeded with any top-level convenience ceilings (maxTreeSteps, maxTreeTokens, maxTreeCost, maxTreeDurationMs) declared on params.

      Parameters

      Returns AgentTreeBudget

    • Returns the current execution count for an action or sub-agent ID (0 if never executed).

      Parameters

      • counts: Map<string, number>
      • itemId: string

      Returns number

    • Increments the execution counter for an action or sub-agent ID within the run's map.

      Parameters

      • counts: Map<string, number>
      • itemId: string

      Returns number

    • Accumulates token and cost usage from a completed prompt execution into the shared AgentTreeBudget for the execution tree.

      Prefers rollup figures on promptRun (TokensUsedRollup / TokensPromptRollup + TokensCompletionRollup and TotalCost) so hierarchical child prompts are counted, falling back to direct promptRun columns (TokensUsed / TokensPrompt + TokensCompletion and Cost) or the AIPromptRunResult summary fields when promptRun is not populated.

      Parameters

      Returns { CostDelta: number; TokensDelta: number }