stay-within-limits
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStay Within Limits
遵守使用限制
Keep long-running agent work inside the current 5-hour and weekly usage windows.
Check usage before launching substantial work and between waves of parallel
subagents. If an active 5-hour or weekly limit is at or above 95%, pause new
work until the window is clear enough to continue safely.
确保长时间运行的Agent任务处于当前5小时和每周使用限制范围内。在启动大量任务前以及并行子Agent的任务波次之间检查使用情况。如果5小时或每周的活跃使用限制达到或超过95%,暂停新任务,直到限制窗口足够空闲后再安全继续。
Core Loop
核心流程
- Run a bounded wave of work. Default to at most 3 parallel subagents unless the user or host gives a different throttle.
- Wait for the wave to finish. Do not interrupt in-flight subagents just to save budget; that usually loses work.
- Check current 5-hour and weekly usage with the host's usage/budget tool.
- If either window is at or above 95%, stop launching work and schedule a self-contained resume when the relevant window should clear.
- On resume, re-check the real window or block before continuing. Do not trust elapsed wall-clock time alone.
- 执行一波有界任务。默认最多使用3个并行子Agent,除非用户或宿主指定了不同的限流规则。
- 等待这波任务完成。不要为了节省预算而中断正在运行的子Agent;这通常会导致工作成果丢失。
- 使用宿主的使用/预算工具检查当前5小时和每周的使用情况。
- 如果任一限制窗口的使用量达到或超过95%,停止启动新任务,并安排在相关限制窗口重置后自动恢复任务。
- 恢复任务时,重新检查实际限制窗口状态,确认安全后再继续。不要仅依赖流逝的挂钟时间。
Usage Signals
使用情况信号
Prefer a first-party host usage tool when available. In Claude Code, use:
sh
npx -y ccusage@latest blocks --active --jsonUse the JSON to identify the active block start, current cost or percentage, and
time remaining. On wake, compare the active block start timestamp with the
previous one; a new timestamp is stronger evidence than "enough time passed."
If the tool reports cost instead of a direct percentage, convert through the
current account limit when known. For Claude Max-style 5-hour blocks, some users
prefer an earlier caution threshold around $500-550; treat that as a
user-configured guardrail, not a universal rule. The default stop rule is still
95% of the active 5-hour or weekly limit.
如果有官方宿主使用工具,优先使用。在Claude Code中,使用以下命令:
sh
npx -y ccusage@latest blocks --active --json使用返回的JSON数据识别活跃限制周期的开始时间、当前成本或使用百分比,以及剩余时间。恢复任务时,将活跃限制周期的开始时间戳与之前的进行比较;新的时间戳比“足够时间已过去”更能作为限制重置的证据。
如果工具报告的是成本而非直接百分比,在已知当前账户限额的情况下进行转换。对于Claude Max风格的5小时限制周期,部分用户偏好设置更早的预警阈值(约500-550美元);将其视为用户配置的防护规则,而非通用标准。默认停止规则仍为活跃5小时或每周限制的95%。
Pausing And Resuming
暂停与恢复
When a wake/resume tool is available, schedule a wakeup for:
txt
min(3600, secondsUntilWindowClears)If the runtime clamps wake delays to 60-3600 seconds, chain wakeups for longer
waits. Each wakeup should re-check usage, reschedule if still over budget, and
continue only when the window is safely below the threshold.
Make wake prompts self-contained. Include:
- The remaining plan.
- The check-then-reschedule rule.
- The 95% threshold and wave throttle.
- The exact usage command or host usage tool to run.
- The previous block/window identifier when available.
- The next verification steps.
- The next wave's handoff packets, including scope, verification commands, and stop conditions, if delegation will resume.
当有唤醒/恢复工具可用时,按以下规则安排唤醒时间:
txt
min(3600, secondsUntilWindowClears)如果运行时将唤醒延迟限制在60-3600秒范围内,可通过链式唤醒处理更长的等待时间。每次唤醒都应重新检查使用情况,如果仍超出预算则重新安排唤醒时间,仅当限制窗口安全低于阈值时才继续任务。
确保唤醒提示是独立完整的,包含:
- 剩余任务计划。
- 检查后重新调度的规则。
- 95%的阈值和任务波次限流规则。
- 要执行的具体使用情况查询命令或宿主使用工具。
- 可用的话,之前的限制周期/窗口标识符。
- 后续验证步骤。
- 下一波任务的交接数据包,包括范围、验证命令和停止条件(如果将继续委托任务)。
Choosing The Wait Mechanism
选择等待机制
- Use a wake/resume tool when the agent needs instructions attached to the future resume.
- Use a background sleep or watcher for fixed timers and things a process can observe directly.
- Use cron or recurring schedules only for recurring fresh-session work.
Avoid short-interval polling for things the host will notify you about, such as
background task or subagent completion. For budget pauses, a prompt-cache miss
after a long sleep is acceptable; preserving the limit matters more.
- 当Agent需要在未来恢复时附带指令,使用唤醒/恢复工具。
- 对于固定计时器和进程可直接观察的情况,使用后台睡眠或监视器。
- 仅对周期性的新会话任务使用cron或重复调度。
避免对宿主会通知的事项进行短间隔轮询,例如后台任务或子Agent完成情况。对于因预算原因暂停的情况,长时间睡眠后提示缓存丢失是可以接受的;遵守限制比保持会话连续性更重要。
Reporting
报告
If you pause, tell the user which window is over threshold, the observed usage,
when you scheduled or expect the next check, and what work remains. Keep enough
state in the wake prompt that the next turn can resume without relying on
conversation momentum.
如果暂停任务,告知用户哪个限制窗口超出阈值、观测到的使用量、计划或预期的下一次检查时间,以及剩余任务内容。在唤醒提示中保留足够的状态信息,以便下次任务恢复时无需依赖会话上下文即可继续。