Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/durable-cost-store.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@agentskit/observability': minor
---

Add the `CostStore` port (`reserve`, `commit`, `release`, `window`) for durable, tenant-scoped spend accounting, with `createInMemoryCostStore` for development and an optional `@agentskit/observability/postgres` subpath: BYO Drizzle/node-postgres store with atomic cap admission, idempotent reservations, a usage ledger, exported schema and migration SQL. `@agentskit/observability/cost-store-contract` exports the contract suite for custom stores.

`costGuard`, `multiTenantCostGuard` and `createAdvancedCostGuard` accept an optional `store`. With it, each priced call is written to the store and the budget is checked against spend recorded by every instance in the current accounting window (UTC month by default). Without it behavior is unchanged, except for a one-time warning in production runtimes (`NODE_ENV=production`, or Cloudflare Workers with `NODE_ENV` unset; `warnWithoutStore` overrides it), because process-local totals do not hold across instances or isolates. A store write that fails goes to `onError`, or to one warning when no handler is set. `costGuard` also accepts `tenant` to name the store partition.

`expirePostgresCostReservations({ db, olderThan })` releases reservations that were never settled; the store has no background reaper. `reserve` with the id of a released reservation throws `AK_COST_RESERVATION_RELEASED`. Match `CostReservationError` by `code`: each CommonJS subpath bundles its own copy of the class.
2 changes: 1 addition & 1 deletion .doc-bridge/capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "AgentsKit",
"root": "."
},
"contentHash": "067a1c851a5ecc5d384f61db7a0e5b5eaaffce52b7d67ce9a19e39bf95c49d83",
"contentHash": "67a7cb465aadd34c99468f94869e00495bcc92863f5819adaec1eb1e13e13d2c",
"artifacts": {
"index": ".doc-bridge/index.json",
"llmsTxt": ".doc-bridge/llms.txt"
Expand Down
Loading
Loading