Skip to content

Commit 04e02cc

Browse files
committed
feat(agents): resource discipline for parallel dev agents in one container
Maintainer-reported OOM under parallel dispatch. Memory peaks are the build/test phases, so heavy phases serialize on a container-wide flock (/tmp/os-heavy-verify.lock) while editing stays parallel; plus heap caps (NODE_OPTIONS max-old-space-size), scoped --filter builds/tests, capped vitest/turbo workers, and worktree cleanup after the PR is up. PM-side: batch:2 or mode:cloud for build-heavy tasks; OOM-killed agents redispatch alone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
1 parent 9856a65 commit 04e02cc

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

.claude/agents/os-dev.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ rules that most often get missed:
3333
consumer (`??` alias, tolerant parse), the bug is at the producer or in the
3434
spec — fix it there, or return `needs_decision`.
3535

36+
**Resource discipline — parallel agents share ONE container; unbounded
37+
build/test runs OOM it.** Binding rules:
38+
39+
1. **Serialize the heavy phase.** Wrap every build and test run in the shared
40+
verification lock, so editing parallelizes but memory peaks never stack:
41+
`flock -w 7200 /tmp/os-heavy-verify.lock -c '<build/test command>'`
42+
(one lock file per container; waiting on it is normal, not a hang).
43+
2. **Cap the heap.** Prefix heavy commands with
44+
`NODE_OPTIONS=--max-old-space-size=4096` (raise only with a reason).
45+
3. **Scope, don't sweep.** Build and test the affected packages
46+
(`pnpm --filter <pkg> build/test`), not the whole repo, unless the task
47+
explicitly requires a full pass. Cap test parallelism:
48+
vitest `--maxWorkers=2`, turbo `--concurrency=2`.
49+
4. **Clean up when done**: after the PR is up, remove your worktree
50+
(`git worktree remove <path> --force`) — leftover `node_modules` trees
51+
exhaust the container's disk, which fails as confusingly as OOM.
52+
3653
Definition of done, in order:
3754

3855
- Implementation matches the issue's acceptance criteria.

.claude/skills/pm-dispatch/SKILL.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,19 @@ Follow your operating procedure (you are the os-dev agent). Non-negotiables:
242242
Return ONLY the JSON report defined in your agent definition.
243243
```
244244

245+
#### Resource limits — parallel agents share ONE container
246+
247+
Memory peaks come from **build + test**, not editing, so the fix is not less
248+
parallelism but serialized heavy phases: the os-dev definition requires every
249+
build/test run to hold the container-wide verification lock
250+
(`flock /tmp/os-heavy-verify.lock`), a `NODE_OPTIONS=--max-old-space-size`
251+
heap cap, scoped `--filter` builds/tests, capped vitest/turbo workers, and
252+
worktree cleanup after the PR is up. PM-side: treat `batch:3` as assuming
253+
normal-sized tasks — for build-heavy ones (dependency-family upgrades, full
254+
regression passes) drop to `batch:2`, or dispatch that issue via
255+
`mode:cloud` so it gets its own container. If an agent dies with a
256+
heap/OOM signature, redispatch it alone rather than into a full batch.
257+
245258
#### Dispatch backends
246259

247260
**`mode:subagent` (default).** The `Agent` tool, as described above. The devs

0 commit comments

Comments
 (0)