Intelligence · class
Budget
A ceiling on what an agent may spend, enforced here rather than asked for in a prompt.
Explained in Agents and behaviour.
class Budgetimport { Budget } from '@driftengine/ai';In depth
Exhaustion degrades. charge past a limit returns normally and latches
exhausted; the session stops issuing continuations and the policy floor keeps
producing intents. Throwing would put an exception inside a fixed step, which is
worse than the overspend it prevents.
What it costs: an agent that goes over is quietly less capable, and a consumer
that never reads reason will not know why. What would make it wrong: if a
consumer needs to know at the moment it happens rather than by polling, this needs
a callback — deliberately not added until something asks, because a callback firing
inside a fixed step has the same hazard the throw did.
Constructor
new
constructor(limits: BudgetLimits)| Parameter | Type | Description |
|---|---|---|
limits | BudgetLimits |
Accessors
| Name | Type | Description |
|---|---|---|
exhaustedget | boolean | |
reasonget | string | The sentence a consumer reports. Empty while not exhausted. |
Methods
charge
charge(usage: Readonly<AiUsage>, nowMs: number): void| Parameter | Type | Description |
|---|---|---|
usage | Readonly<AiUsage> | |
nowMs | number |