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?
optionalcapType:CostCapType
currentCostUsd?
optionalcurrentCostUsd:number
limitUsd?
optionallimitUsd:number
reason?
optionalreason:string
getSnapshot()
getSnapshot(
agentId):CostSnapshot
Defined in: packages/agentos/src/safety/runtime/CostGuard.ts:153
Parameters
agentId
string
Returns
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
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