How are you all handling cost enforcement on agents — not just
monitoring but a hard gate before tool calls fire?
Working on something for this and curious what patterns people are using.
We’re treating it as two separate layers:
- Hard ceiling on tokens/spend (budget middleware or pre-tool check that aborts before the call).
- Reducing unnecessary tokens before they ever count against that budget.
On the second part, a lot of the spend in longer runs comes from retrieved context and tool results that are already stale. We’ve been using a thin proxy that scores those blocks on temporal decay and drops high-decay ones before they reach the model. It doesn’t replace a proper spending limit, but it lowers the baseline consumption the limit has to enforce.
Curious what patterns others are using for the actual hard gate & are you doing it inside middleware, at the tool wrapper level, or outside the agent entirely?