Agent awareness of long-running background Bash processes (RAM pressure)

Resolved 💬 3 comments Opened Apr 24, 2026 by mosquss Closed Apr 28, 2026

What happened

I use web new experience beta Claude Code (agent mode) to drive a domain-specific CLI tool — a ~14,000-line Java/ASM fat-jar called ClaudePatcher that statically analyzes 355-jar Minecraft Forge modpacks (~65k classes). Each invocation is a separate JVM process consuming 1.5–2 GB RAM.

During a session, the agent sometimes launches the same heavy command multiple times for timing tests / verification, without realizing previous background processes are still running. Seen today: 3 concurrent java processes × 1.5 GB each on a box without that headroom → memory thrashing → a command that finishes in ~15 s alone took 14 minutes before being killed.

The root problem: the agent has BashOutput and KillShell for shells it explicitly tracks, but no mechanism to see "what heavy processes are live right now" or to be warned before launching a new one.

Requests

  1. Surface pre-launch signals to the agent: running-process summary and available RAM, especially before Bash calls expected to be long / memory-heavy (or tagged run_in_background: true).
  2. Auto soft-kill or explicit warning for duplicate invocations: "a previous java -jar X ... is still running, continue? / will this thrash?"
  3. Expose a tool like "list my active background shell IDs" to the agent (currently it must self-track).

Workaround I'm building locally

A PreToolUse hook matching Bash that shells out to ps/free and returns {"decision":"block","reason":...} when the command matches a heavy-pattern AND a previous instance is already alive. Happy to share the script if useful as a community example.

Env

Claude Code web/IDE session (no terminal), ~April 2026 session date. Observed on a modpack with 355 mods

View original on GitHub ↗

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