Skip to main content
ThunderLang™Programming Language
← All examples

AgentSpendBudget

examples/AgentSpendBudget.thunder

AgentSpendBudget.thunder
1# area: Agent safety
2mission AgentSpendBudget
3
4goal
5 Admit an agent step only when its reserved cost fits the remaining budget.
6
7why
8 Repeated model and tool calls need a predictable spending boundary.
9
10guarantee a proposed charge stays inside the remaining budget
11 verify test SpendAdmission
12
13never admit negative cost or negative remaining budget
14 verify test SpendAdmission
15
16decision SpendAdmission
17 inputs
18 remainingCents
19 reservedCents
20 rule affordable step
21 when remainingCents >= 0 and reservedCents >= 0 and reservedCents <= remainingCents
22 return Admit
23 default
24 return Stop
25
26test SpendAdmission
27 case below the budget
28 given remainingCents 100, reservedCents 99
29 expect Admit
30 case exactly at the budget
31 given remainingCents 100, reservedCents 100
32 expect Admit
33 case above the budget
34 given remainingCents 100, reservedCents 101
35 expect Stop
36 case exhausted budget
37 given remainingCents 0, reservedCents 1
38 expect Stop
39 case negative reservation
40 given remainingCents 100, reservedCents -1
41 expect Stop
42 case negative budget
43 given remainingCents -1, reservedCents 0
44 expect Stop
45
46note engineering
47 The host must validate integer cents, reserve atomically across concurrent calls, and reconcile actual cost. These cases test admission only.
Draft syntax. This file is illustrative and does not run yet.