Skip to main content

applyTokenBudget

@forge/monorepo


@forge/monorepo / backend/src / applyTokenBudget

Function: applyTokenBudget()

applyTokenBudget<T>(input): BudgetOutcome<T>

Defined in: backend/src/core/budget.ts:51

Keep what fits, in the order given, and name what did not.

Order is the caller's priority, not a ranking invented here. For tools that is the order the host's providers were registered in, which is a deployment's own statement about what matters; inventing a relevance order would mean guessing at the model's next need, and find_tools is the honest answer to that.

protect names what may never be dropped. Meta-tools are the reason it exists: dropping find_tools or learn_tools to save 35 tokens would remove the model's only route back to everything else, turning a budget into a permanent amputation.

Type Parameters

T

T

Parameters

input

budget

TokenBudget

items

readonly T[]

nameOf

(item) => string

protect?

(item) => boolean

tokensOf

(item) => number

Returns

BudgetOutcome<T>