agentskit.js

CostGuardOptions

Auto-generated API reference for CostGuardOptions.

Interface: CostGuardOptions

Defined in: observability/src/cost-guard.ts:48

#Properties

#budgetUsd

budgetUsd: number

Defined in: observability/src/cost-guard.ts:50

Hard budget in USD. Aborts the run when exceeded.


#controller

controller: AbortController

Defined in: observability/src/cost-guard.ts:55

AbortController to signal the runtime to stop. The runtime picks this up via RunOptions.signal (RT13).


#modelOverride?

optional modelOverride?: string

Defined in: observability/src/cost-guard.ts:78

Force a specific model id if the runtime doesn't emit one.


#name?

optional name?: string

Defined in: observability/src/cost-guard.ts:80

Observer name for tracing.


#onCost?

optional onCost?: (info) => void | Promise<void>

Defined in: observability/src/cost-guard.ts:64

Called whenever the running total changes. Useful for progress UI. Sync throws and async rejections are isolated.

#Parameters

info
budgetRemainingUsd

number

completionTokens

number

costUsd

number

promptTokens

number

#Returns

void | Promise<void>


#onError?

optional onError?: CostGuardErrorHandler

Defined in: observability/src/cost-guard.ts:76

Isolated sink for internal / callback failures. Never allowed to escape.


#onExceeded?

optional onExceeded?: (info) => void | Promise<void>

Defined in: observability/src/cost-guard.ts:74

Called when the budget is exceeded (just before / after abort bookkeeping). Sync throws and async rejections are isolated.

#Parameters

info
budgetUsd

number

costUsd

number

#Returns

void | Promise<void>


#prices?

optional prices?: Record<string, TokenPrice>

Defined in: observability/src/cost-guard.ts:59

Optional price table override. Partial β€” merged over DEFAULT_PRICES.

Explore nearby

✎ Edit this page on GitHubΒ·Found a problem? Open an issue β†’Β·How to contribute β†’

On this page

Ask the docs
Ask anything about AgentsKit. Answers come from the docs corpus and cite their sources.