Original Reddit post

I’m building AI CostGuard , a local-first TypeScript runtime safety layer for AI agents. The problem I’m trying to solve is simple: AI agents can fail in expensive ways before you notice. Examples: similar prompt loops retry storms max-step explosions unknown model pricing accidental budget overruns repeated provider calls from bad agent logic AI CostGuard sits before the provider API call and decides whether the call should be allowed. It is not a SaaS product, not a billing ledger, and not a hard security boundary. The goal is runtime damage reduction for developers building agents. Why this matters: A lot of AI safety tooling focuses on content, evals, or observability after execution. I’m interested in the boring runtime layer before the expensive thing happens. Before the provider call executes, can we catch the obvious failure modes? Limitations: token estimation is approximate provider pricing can change this is not a replacement for billing alerts this is not a security sandbox false positives are possible false negatives are possible local state has tradeoffs developers still need real observability in production npm: https://www.npmjs.com/package/@salimassili/ai-costguard GitHub: https://github.com/salimassili62-afk/ai-costguard I’d appreciate technical feedback on: API design false positive risk pricing assumptions whether guard() / guardFunction() feel natural where this would or would not fit in real agent systems what failure modes I’m missing submitted by /u/salim_assili

Originally posted by u/salim_assili on r/ClaudeCode