oharness-budget
Budget middleware (token, step, cost, time) for open-harness.
BudgetMiddleware is a plain Llm wrapper: wrap any provider,
get pre-call + post-call accounting for free. When the cap trips,
the underlying call returns
LlmError::Provider(BudgetExceeded), which the agent loop
converts to Termination::Failed { category: Llm }.
Shipped budget handles
| Handle | Feature | Default | What it caps |
|---|---|---|---|
TokenBudget |
token |
✅ | Input + output tokens (configurable: input-only, output-only, or both). |
StepBudget |
step |
✅ | Number of complete() calls. |
CostBudget |
cost |
Dollars, via a PricingTable. |
|
TimeBudget |
wall-clock |
Wall-clock duration across the run. | |
CompositeBudget |
(always) | ✅ | Combine multiple handles; any child trip trips the composite. |
All implement the BudgetHandle trait.
Quickstart
use ;
use BudgetHandle;
use Arc;
let budget: = new;
let bounded = new;
// Pass `bounded` to `AgentBuilder::with_llm(...)` as you would any Llm.
See the budget_enforcement example in oharness-loop/examples/.
License
Dual-licensed under MIT or Apache-2.0.