A $37 bill taught me to put spending limits on my AI agents
说明与用途
问题:AI 代理可能进入错误循环,导致超出预设支出限额,产生意外账单。解决方案:为每个代理分配独立预算,使用允许列表,限制单笔交易,并监控异常。结果:支出得到控制,代理在设定限额内运行。
问题
AI agents can enter error loops that exceed intended spending limits, leading to unexpectedly high bills.
结果
The agent system now prevents runaway costs, provides clear budget exhaustion notifications, and allows quick adjustments without monitoring bills nightly.
工作流
- 1. List all paid services and their monthly costs.
- 2. Assign each main agent a dedicated budget and enforce it in code.
- 3. Use one API key per agent to isolate billing and limits.
- 4. Split budgets into Exploration, Project, and Escalation buckets.
- 5. Create an allow-list of trusted services and request new ones through the agent.
- 6. Set per-call and per-day caps to stop retry loops.
- 7. Flag any single charge over $2 for human review.
- 8. Freeze accounts on anomaly detection (high call rate, failure rate, or spend speed).
- 9. Use a visible owner identifier for agent calls to encourage merchant trust.
证据
On the third night the bill said $37 for one day.
A subtask had fallen into an error loop. Call fails, agent tweaks a parameter, retries, fails again.
I use three buckets: Exploration, Project, Escalation.
Now nothing is allowed by default: Start with services you already trust, like OpenAI, Anthropic and your existing data sources.
Any single charge over $2 goes to a human.
- 记录日期: 2026-10-18T04:41:13.857Z