Renewable CPU-rate budget ('CPU per minute') for long-running guest executions (agents)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- javascript, linux, rust, wasm
调研方向
先从 V8 CpuBudgetGuard 和 issue 中描述的执行限制开始,然后检查 docs/design/unified-sidecar-runtime.md 和 crates/execution/src/wasm.rs。检查 packages/load-tests/src/compute/server.ts 中的 agent-session 场景。完成的标准是:具备可续期的 CPU 限制、空闲/无进展处理、迁移后的 CPU/WASM 上限,以及能够证明空闲会话可以完成而 spinner 和卡住的执行会被停止的测试。
由索引模型根据 Issue 内容生成。
描述
Problem
Guest execution limits that are totals or wall-clock based are the wrong
shape for long-running, I/O-bound jobs — most importantly agent sessions.
An agent session (e.g. the pi ACP adapter) is a long-lived orchestrator that
runs for minutes across many LLM turns, spending ~95% of that time waiting
on the LLM, the network, and tool I/O — using almost no CPU. A per-execution
wall-clock limit counts that wait time, so a perfectly well-behaved agent is
killed mid-session:
Error: Script execution exceeded the wall-clock limit (limits.jsRuntime.wallClockLimitMs)
ACP adapter process ... exited with code 1 ... live session route evicted
(Observed in the agent load test: with realistic 1.5–6 s LLM latency × N tool
calls, a session runs past the limit and the adapter is terminated.)
Wall-clock conflates three distinct failure modes into one blunt cap:
- using too much CPU (a runaway/spinning execution),
- hung (blocked forever, using ~0 CPU),
- running too long (a legitimately huge session).
For a short untrusted tool call collapsing all three into "kill at 20 s" is
fine. For a long-lived agent runtime it is wrong — you must separate them.
Proposed fix: renewable CPU-rate budget ("CPU per minute")
Bound the long-lived execution by a renewable CPU-rate budget — the Linux
cgroup cpu.max model (quota per period, refilling), i.e. "X CPU-seconds per
1 s window":
- An I/O-bound agent that is mostly idle-on-CPU stays under budget indefinitely
→ runs the whole session, no guillotine. - A runaway/spinning execution pegs a core → burns its per-window allowance →
throttled/killed. This is what wall-clock was trying to catch, done correctly. - Rate-based ⇒ works for arbitrarily long sessions without a magic "max minutes".
Complements:
- Idle / no-progress timeout — a CPU-rate budget can't see a process stuck on
0 CPU (case 2 above), so kill on no LLM/tool activity for N seconds. - Optional session-max ceiling (generous, e.g. 30 min) as a final backstop.
Implementation note: the machinery already exists — the V8 CpuBudgetGuard
(the interrupt that enforces cpuTimeLimitMs today) is a total budget. Making
it renewable (refill over wall-clock time) turns it into exactly this rate
limiter, with no new subsystem and without per-thread cgroups (which
docs/design/unified-sidecar-runtime.md says to avoid for isolates).
Other caps with the same "total, should be renewable" flaw
While here, these per-execution caps are also totals/wall-clock-based and bite
long-running jobs the same way — they should move to the renewable model:
limits.jsRuntime.cpuTimeLimitMs— total accumulated CPU per execution
(defaultDEFAULT_V8_CPU_TIME_LIMIT_MS = 30_000). A long agent doing real work
accumulates >30 s CPU over minutes and is killed. This is the primary target
(wall-clock already defaults to0/disabled; CPU-time does not).limits.resources.maxWasmFuel— WASM fuel, enforced as a wall-clock
timeout for the WASM runtime (crates/execution/src/wasm.rs). Same total/
wall-clock shape; a long-running WASM command should get a renewable fuel rate.
Instantaneous caps (maxProcesses, maxOpenFds, maxSockets, v8HeapLimitMb,
maxWasmMemoryBytes, pendingEvent*, maxFilesystemBytes, maxInodeCount) are
"how many at once / how much stored" — not consumption budgets — and correctly
stay as-is.
Interim state
- Runtime default wall-clock is already disabled (
DEFAULT_V8_WALL_CLOCK_LIMIT_MS = 0). - The load-test actor (
packages/load-tests/src/compute/server.ts) had an explicit
wallClockLimitMs: 20_000that killed agent sessions; it has been set to0
(disabled) with a TODO pointing here. cpuTimeLimitMsis left in place for now; once the renewable budget lands, both
wall-clock and CPU-time should re-enable a sane renewable default.
Acceptance
- Renewable CPU-rate budget (
cpu.max-style) for guest executions, config-exposed. - Idle/no-progress timeout for the hung case.
-
cpuTimeLimitMsandmaxWasmFuelmigrated to (or complemented by) the rate model. - A long (minutes) mostly-idle agent session runs to completion; a CPU spinner
is still throttled/killed; a hung execution is still reaped. - Sane renewable defaults re-enabled (replacing the disabled wall-clock).
- 主要语言
- Rust
- 星标
- 4.8k
- 派生
- 270
- 平均合并
- 13 小时 37 分钟
- 30 天内合并 PR
- 48
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rivet-dev/agentos 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 20/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
rivet-dev/agentos#2087 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 3/5 半天 新手友好度 32/100
rivet-dev/agentos#2020 · 1 条评论 ·
维护者通常 1 天内回复
查看 rivet-dev/agentos 的全部 Issue
相似的 Issue
-
area:docs documentation good first issue priority:medium
难度 1/5 1 小时以内 新手友好度 78/100
维护者通常 1 天内回复
-
feature
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug]: streamed Responses API flex_unavailable error maps to 500 InternalServerError instead of 429未关闭llm translation
难度 2/5 1 小时以内 新手友好度 85/100
BerriAI/litellm#49736 · 1 条评论 ·
维护者通常 1 天内回复
-
question
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
field-report
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复