OptionalbreachedSet to the breach reason once any tree limit is exceeded
OptionalmaxMaximum cumulative LLM cost (in USD) allowed across the entire agent tree
OptionalmaxMaximum wall-clock duration (in milliseconds) allowed for the entire agent tree
OptionalmaxMaximum total steps allowed across the entire root-to-leaf agent tree
OptionalmaxMaximum total tokens (prompt + completion) allowed across the entire agent tree
Epoch timestamp (Date.now()) when the root agent run started
Live cumulative cost accumulator shared by reference across the agent tree (initialized to 0)
Live cumulative step counter shared by reference across the agent tree (initialized to 0)
Live cumulative token counter shared by reference across the agent tree (initialized to 0)
Shared cumulative budget and live usage counters across an entire root-to-leaf agent execution tree (including sequential and parallel sub-agents).
A single
AgentTreeBudgetinstance is created at the root of an agent execution (or supplied by the caller onExecuteAgentParams.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.