一个失控的 AI 代理让我在睡觉时损失了 47 美元(以及我如何解决这个问题)
📄 中文摘要
在使用 AI 代理的过程中,可能会遇到意外的费用,例如因代理陷入循环而产生的高额 API 账单。最近,作者因调试 LangGraph 的重试循环而损失了 47 美元,代理不断失败,LangGraph 不断重试,OpenAI 也在不断收费。为了解决这一问题,作者开发了 Shekel,这是一个零配置的开源 Python 库,用于 LLM 预算执行和成本跟踪,支持 LangGraph、CrewAI、AutoGen 及其他调用 OpenAI、Anthropic 或 LiteLLM 的框架。该库的设计旨在帮助用户避免类似的高额费用。
📄 English Summary
How a runaway AI agent cost me $47 while I slept (and how I fixed it)
Waking up to a hefty API bill due to an AI agent stuck in a loop is a frustrating experience. The author recently incurred a cost of $47 while debugging a retry loop in LangGraph, where the agent kept failing, LangGraph kept retrying, and OpenAI continued to charge. To prevent others from facing similar costly lessons, the author created Shekel, a zero-config, open-source Python library designed for budget enforcement and cost tracking for LLMs. It is compatible with LangGraph, CrewAI, AutoGen, and any framework that interacts with OpenAI, Anthropic, or LiteLLM. This tool aims to provide better guardrails for AI agents and help users manage their expenses effectively.
Powered by Cloudflare Workers + Payload CMS + Claude 3.5
数据源: OpenAI, Google AI, DeepMind, AWS ML Blog, HuggingFace 等