Skip to content

v0.14.0: budget checks you can replace

Choose a tag to compare

@eadwinCode eadwinCode released this 03 Nov 20:25
· 7 commits to main since this release
d576679

The two budget checks the loop runs after every step can now be replaced, in both runtimes. A host can stop a run on its own rule, such as a live balance that other runs spend at the same time. Go module github.com/eadwinCode/agentic-kit/packages/go-agentenkit@v0.14.0, npm agentenkit@0.14.0 and use-agentenkit@0.14.0.

No breaking changes.

New: your own budget checks (#44)

Go: RuntimeOptions.CheckTokenBudgetExhausted and CheckCostBudgetExhausted. TS: checkTokenBudgetExhausted and checkCostBudgetExhausted on setupAgentCore.

  • The defaults are the old token cap and money cap, exported as DefaultCheckTokenBudgetExhausted / DefaultCheckCostBudgetExhausted (TS: defaultCheck…Exhausted), so a hook can call them and keep the cap.
  • A check is told the run (runId, threadId, agentId, state), the step that just finished (step, the stored step record), whether another step would follow (willContinue), what the run has spent with its cap, and publish.
  • True ends the run before the next step, with stopReason token_budget or cost_budget. The check says why with publish; the defaults still send TOKEN_BUDGET_EXHAUSTED and COST_BUDGET_EXHAUSTED.
  • A check that fails (TS: throws; Go: returns an error or panics) is logged and read as false. To fail closed, handle your own errors and return true.
  • Nested runs are checked against their parent's run id, and may call the check at the same time as their parent.
  • The first step of a segment runs without a check. Refuse a run on an empty balance in billingPreCheck at pickup.

Changed

  • stopReason: 'token_budget' now comes from the token check's answer, not from a sum at finalize. With the default check, nothing changes.

See Your own budget checks.