开发者在Hacker News上发布了agent-usage-guard,这是一个Claude Code模块,旨在防止AI代理在短时间内耗尽用户的API使用额度1。该工具通过监控实时使用情况、限制子代理并发和重试循环,在支出发生前进行干预1。
根据开发者的记录,五小时使用窗口曾在十分钟内被耗尽1。一次会话产生了394个子代理调用,其中341个同时运行,仅在十分钟内就消耗了约8400万个上下文token1。过去60天的日志显示,用户经历了12次锁定和166个十分钟的代理突发事件1。
该模块由约2,400行TypeScript代码组成,不依赖任何外部依赖1。用户可通过命令/plugin marketplace add rbartoli/agent-usage-guard安装,支持Claude Code v2.1.287或更高版本1。默认暂停窗口设置为10分钟,适配的环境包括claude终端、Desktop应用Code标签、claude -p和Agent SDK1。
A Claude Code module called agent-usage-guard has been released to help developers protect their API usage allowances from being exhausted by runaway AI agents 1. The tool monitors real-time consumption and intervenes before spending occurs, addressing a critical problem where a five-hour usage window can be depleted within minutes 1.
The tool emerged from real-world incidents in which a single session generated 394 sub-agent calls, with 341 executing concurrently and consuming approximately 84 million context tokens in just ten minutes 1. Analysis of 60-day logs revealed 12 account lockouts and 166 ten-minute agent burst events 1. Agent-usage-guard limits concurrent sub-agents and retry loops to prevent such scenarios 1.
The module comprises approximately 2,400 lines of TypeScript code and requires no external dependencies 1. Installation is available through the Claude Code plugin marketplace using the command /plugin marketplace add rbartoli/agent-usage-guard, and it requires Claude Code version 2.1.287 or higher 1. The default pause window is set to ten minutes via the AGENT_GUARD_WINDOW_SECONDS variable 1. The tool is compatible with the Claude terminal, Desktop application Code tab, claude-p, and Agent SDK 1.
评论
还没有评论,欢迎留下第一条。