Ask HN: 你们是如何防止 AI 编程助手烧钱的?

2作者: bhaviav1005 个月前
我的代理重试次数有点超标,导致我的账单蹭蹭往上涨。 我尝试找出原因,但现有的工具帮不上什么忙。 更糟糕的是,所有数据都显示为总使用量。总的Token数、总费用,可能按模型区分一下。 所以我最终在OpenAI前面搭建了一个薄薄的中间层,强制每个请求都携带一些上下文信息(代理、任务、用户、团队),然后记录并计算每次调用的费用,并在其上设置一些基本限制,这样如果出现问题,你就可以阻止它。 它非常简陋,但即使只是看到“这个代理 + 这个任务 = 这个费用”也让我松了一口气。 它使用你自己的OpenAI密钥,所以在执行方面并没有做什么神奇的事情,只是观察和强制执行。 我想知道你们现在是如何处理这个问题的。你们是只关注总使用量并相信它,还是已经构建了一些东西来按代理/任务进行细分? 如果对你有用,这是我正在使用的粗略版本:https://authority.bhaviavelayudhan.com/
查看原文
My agents retry a bit more than it should, and there goes my bill up in the sky. I tried figuring out what is causing this but none of the tools helped much.<p>and the worse thing for me is that everything shows up as aggregate usage. Total tokens, total cost, maybe per model.<p>So I ended up hacking together a thin layer in front of OpenAI where every request is forced to carry some context (agent, task, user, team), and then just logging and calculating cost per call and putting some basic limits on top so you can actually block something if it starts going off the rails. It’s very barebones, but even just seeing “this agent + this task = this cost” was a big relief.<p>It uses your own OpenAI key, so it’s not doing anything magical on the execution side, just observing and enforcing.<p>I want to know you guys are dealing with this right now. Are you just watching aggregate usage and trusting it, or have you built something to break it down per agent &#x2F; task?<p>If useful, here is the rough version I’m using : https:&#x2F;&#x2F;authority.bhaviavelayudhan.com&#x2F;