Skip to main content

Class: CostGuard

Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:64

Constructors​

Constructor​

new CostGuard(config?): CostGuard

Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:69

Parameters​

config?​

Partial<CostGuardConfig>

Returns​

CostGuard

Methods​

canAfford()​

canAfford(agentId, estimatedCostUsd): object

Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:78

Whether an operation estimated at estimatedCostUsd fits the caps that apply to agentId. A refusal names the cap that refused it in capType, says why in reason, and carries that cap's numbers: currentCostUsd, the id's total under the cap before the operation (for the single-operation cap, the estimate itself), and limitUsd, the cap.

Parameters​

agentId​

string

estimatedCostUsd​

number

Returns​

object

allowed​

allowed: boolean

capType?​

optional capType: CostCapType

currentCostUsd?​

optional currentCostUsd: number

limitUsd?​

optional limitUsd: number

reason?​

optional reason: string


getSnapshot()​

getSnapshot(agentId): CostSnapshot

Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:153

Parameters​

agentId​

string

Returns​

CostSnapshot


recordCost()​

recordCost(agentId, costUsd, operationId?, metadata?): CostRecord

Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:122

Parameters​

agentId​

string

costUsd​

number

operationId?​

string

metadata?​

Record<string, unknown>

Returns​

CostRecord


resetDailyAll()​

resetDailyAll(): void

Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:180

Returns​

void


resetSession()​

resetSession(agentId): void

Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:172

Parameters​

agentId​

string

Returns​

void


setAgentLimits()​

setAgentLimits(agentId, overrides): void

Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:187

Parameters​

agentId​

string

overrides​

Partial<Pick<CostGuardConfig, "maxSessionCostUsd" | "maxDailyCostUsd">>

Returns​

void