[Feature] Agent Teams: Set higher oom_score_adj on teammate agents than on the lead/orchestrator

Resolved 💬 2 comments Opened Mar 7, 2026 by gwpl Closed Apr 4, 2026

AI Assistant:

Problem

When running Agent Teams (lead + teammates), all Claude Code processes currently set the same oom_score_adj=200. Under memory pressure, the Linux OOM killer may choose to kill the lead/orchestrator agent instead of a teammate, because they all have equal OOM scores and the lead often consumes more RSS memory (it holds team coordination state).

When the lead gets OOM-killed, the teammate agents remain alive as orphaned processes in their tmux panes — still consuming resources but with no coordinator. The user loses the orchestration session and must manually clean up the remaining agents.

Observed in the wild: A lead orchestrator running an Agent Team (--model default with 4 teammates: literature-researcher, behavioral-finance-consultant, math-formalism-consultant, python-implementer) was killed by OOM while all teammates survived as orphans.

Current Behavior

All Claude Code processes (lead and teammates) set oom_score_adj=200:

PID    OOM_ADJ  ROLE
1062788  200    lead/orchestrator
1075665  200    teammate (literature-researcher)
1075887  200    teammate (behavioral-finance-consultant)
1076949  200    teammate (math-formalism-consultant)
1079192  200    teammate (python-implementer)

Proposed Solution

Implement a hierarchical oom_score_adj strategy for Agent Teams:

| Role | oom_score_adj | Rationale |
|------|-----------------|-----------|
| Lead/orchestrator | +200 (current) | Most valuable — coordinates all work, holds team state |
| Teammate agents | +300 or +250 | Expendable before the lead — their work can be re-assigned |

This mirrors how Chromium already does it:

  • Main browser process: +200
  • Renderer (tab) processes: +300

The lead is like the browser — losing it means losing everything. Teammates are like tabs — losing one is recoverable.

Implementation Notes

  • The oom_score_adj is set via /proc/self/oom_score_adj (or the Node.js equivalent)
  • The teammate processes already receive --parent-session-id, so they know they're children
  • The adjustment could be: parent_oom_adj + 100 or a fixed value like +300
  • This is Linux-specific; macOS doesn't have oom_score_adj (but has similar mechanisms)

Additional Consideration

When the lead dies, teammates should ideally detect this (e.g., by monitoring the parent session) and gracefully shut down rather than running indefinitely as orphans. This is related to but separate from #28552.

Related Issues

  • #13126 — Claude Code killed by OOM due to subprocess management
  • #28552 — Agent team not terminated after lead reports shutdown
  • #23620 — Agent team lost when lead's context gets compacted

Environment

  • Claude Code 2.1.71
  • Linux 6.17.3-arch2-1
  • Agent Teams (experimental, CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1)

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗