Repository navigation
v0.14.0: budget checks you can replace
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, andpublish. - True ends the run before the next step, with
stopReasontoken_budgetorcost_budget. The check says why withpublish; the defaults still sendTOKEN_BUDGET_EXHAUSTEDandCOST_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
billingPreCheckat 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.