Skip to content

fix(cli): host runs out of memory when several Claude CLI conversations start at once - #192534

Merged
obviyus merged 3 commits into
mainfrom
fix/cli-live-session-memory
Nov 4, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/cli-live-session-memory

Conversation

@obviyus

@obviyus obviyus commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: a Gateway using the Claude CLI runtime can push its host into memory exhaustion when several conversations start new Claude processes close together.

On an 8 GB Linux VM without swap, several Slack/Teams turns arrived within about 3 minutes. The Gateway went from 3 to 7 warm Claude CLI processes, available memory fell from ~3.8 GB to ~250 MB and stayed there, and the VM thrashed (no OOM kill, CPU ~5%) until a reboot about 2 hours later. The only limit on warm processes was a fixed count of 16; idle warm processes were kept even while the host ran out of memory.

User Impact

User impact: when host memory is low, a new Claude CLI conversation first closes idle warm processes (least recently used first). If memory is still low and every warm process is busy, that turn fails over instead of starting another process, and a channel reply says: "⚠️ This host is low on memory, so it could not start another session. Try again after active conversations finish." (Before, any such failure would have shown the generic "AI service needs a short break" rate-limit copy.) Hosts with enough free memory behave as before; turns that reuse their own warm process are unaffected; busy turns are never closed.

Why This Change Was Made

Before a turn starts a new warm process, the live-session registry reads host free memory through the existing readHostFreeMemoryBytes() helper (os.freemem(), which is MemAvailable on Linux; process.availableMemory() on macOS). It walks the warm processes once in least-recently-used order: while memory is below 1 GiB, it closes each idle process and waits for it to exit before the next reading. If memory is still below the floor after that pass, the turn fails over with the rate_limit category the 16-session cap already uses, plus a distinct cli_live_session_host_memory code. The existing failover-code copy (renderFailoverCodeUserCopy) owns its user text, and the rate-limit reply renderer now returns a host-authored code's copy before generic rate-limit text (auth-profile cooldown keeps its expiry-aware copy). The registry map is now kept in least-recently-used order, so both the memory path and the existing count cap close the conversation that has waited longest.

The 1 GiB floor comes from measurements of one warm session:

Measurement RSS
Claude Code 2.1.314, Linux arm64 container, stream-json, idle after start ~180 MiB
Same, after one Haiku turn / three concurrent Sonnet turns ~195–198 MiB each
Full warm session under a Gateway (macOS): Claude Code + two Node supervisor helpers ~490 MiB (264 + 138 + 87)

1 GiB leaves room for about two more warm sessions before the kernel has to reclaim. The 16-session cap stays as the upper bound. No config key is added.

Evidence

  • Two executePluginOwnedProcess tests (an entry point on both main and this branch), with host memory simulated at readHostFreeMemoryBytes:
    • Low memory, new conversation: the least recently used idle process closes; the busy one and the recently used one stay. On main this fails on behavior (recent.close not called).
    • Low memory, only a busy process: the turn rejects with rate_limit / cli_live_session_host_memory before the plugin runs, the busy process stays, and resolveReplyFailureSummary returns the host-memory copy. On main this fails on behavior (the turn runs: reason: "exit").
  • src/agents/cli-runner/, extensions/anthropic, and the CLI attempt-execution tests: 1479 passed on the candidate; the registry and execute-plugin tests pass on the exact head (108). One failure, extensions/anthropic/session-catalog.test.ts ("reports the discovery frontier…"), also fails alone on this host and does not touch the changed files.
  • Real path on the previous head a646b6b8 (the repair batch after it adds the failover code and copy and makes eviction one bounded pass; the tests above cover both): isolated Gateway (own state, config and Claude config dir, test API key from env only), anthropic/claude-haiku-4-5 with agentRuntime.id: "claude-cli", turns sent with openclaw agent. Memory pressure was simulated at the same seam the code reads (os.freemem / process.availableMemory), with each live Claude process under the Gateway counted as 700 MiB, so closing a process really raises the reading.
    • Real memory: 4 concurrent sessions start (activeSessions=1…4), no closures.
    • Low memory, new 5th session: free-memory read: live claude processes=4 reported=424MiB → memory pressure: closing idle session activeSessions=4 → processes=3 reported=1124MiB → cli live session start … activeSessions=4; the turn replied.
    • Low memory, existing session: reused its warm process, no memory read, no closure; replied.
    • Low memory, all four warm sessions busy with long turns, new session: failed over in 54 ms (Host memory is too low for another CLI live session.); all four busy turns completed.

Limits

  • Admission only. A warm process that grows during a long turn after it started is not limited here.
  • readHostFreeMemoryBytes() reads host memory on Linux, not a container cgroup limit; that helper is shared and unchanged.
  • Turns that start at the same instant can each read the same free-memory value before any process exists; the floor's headroom covers a small burst, and the 16-session cap still holds.
  • The failover category stays rate_limit, as the existing count cap uses; the distinct code carries the cause.
  • The live check ran on macOS with a simulated reading; the Linux numbers come from an isolated Claude Code container run.

Merge danger

Two-way door: a revert restores the previous behavior. No config, schema, stored state or published contract changes.

Blast radius: Gateways using a CLI runtime with warm live sessions (today Claude CLI). If the floor is wrong for a host, the effect is more closed idle sessions (a cold start on the next turn) or a failover when memory is below 1 GiB and every warm session is busy. Other runtimes and channels are not affected.

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Nov 4, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 4, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR closes idle warm CLI sessions under memory pressure and refuses new sessions with an actionable memory-specific message when necessary.

Example: A fifth Claude CLI conversation starts with four warm processes and 424 MiB available.

  • Before: Another process starts despite the host's low memory.
  • After: An idle process closes, available memory rises to 1124 MiB in the supplied trace, and the new conversation replies.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused fix with relevant Gateway evidence and distinct regression coverage; the live memory-pressure scenario uses simulated readings rather than actual Linux exhaustion.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Supplied isolated-Gateway traces exercise real Claude processes through openclaw agent under simulated memory readings, covering idle eviction, successful reuse, and all-busy refusal; later production changes preserve the diagnosis through regression-tested reply rendering, and the latest head changes only tests.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Several Claude CLI conversations can exhaust host memory and leave the Gateway unable to make useful progress.
Reason: The reported operational failure warrants a bounded admission safeguard, and collaborator authorship establishes direction for the documented resource tradeoff.

Merge readiness

✅ Ready for maintainer review

This PR addresses a concrete host-memory failure that current main still permits; the earlier reply-copy finding is fixed, and no introduced correctness defect was found.

Priority: P1
Reviewed head: 29d424bdc3bdc497feaa6c0e72b87947d1a8229c

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway's plugin execution host delegates warm-process ownership to the live-session registry, which now checks host memory before admitting another process and sends refusal facts through the shared failover renderer.

flowchart TD
  A[Conversation turn] --> B[Plugin execution host]
  B --> C[Live session registry]
  C --> D[Host memory reading]
  C --> E[Close idle process and await exit]
  C --> F[Claude CLI process]
  C --> G[Failover reply renderer]
Loading

Technical review

Best possible solution:

Land the focused registry-owned admission check and shared failure copy after the existing CI gate passes.

Do we have a high-confidence way to reproduce the issue?

Current main limits warm sessions by count alone, allowing additional processes despite low host memory; the incident report and supplied Gateway trace substantiate that path without a reviewer-run reproduction.

Is this the best way to solve the issue?

The change uses the existing capacity, cleanup, and reply-copy owners, preserves busy sessions and compatible reuse, and adds two regressions for distinct eviction and refusal failures.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ff8fe07318eb.

Provenance checked

  • Warm-session capacity and eviction changes intended behavior with a stated reason (12d0fd2: Keep compatible CLI processes warm under one host-owned registry with a fixed capacity bound.)
  • Process retirement and cleanup keeps the original intent (bcef3b3: Do not release or replace owned work until its resource cleanup is confirmed.)
  • Canonical failure copy and cooldown privacy keeps the original intent (c0effea: Keep saved-login diagnostics private while preserving useful recovery guidance through the shared renderer.)
  • Structured CLI failure guidance keeps the original intent (e60fbe9: Preserve a specific CLI diagnostic as actionable user-facing copy rather than a generic failure.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +66, Tests +72, Other +2. Total +140 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 73 7 +66
Tests 1 75 3 +72
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 6 150 10 +140

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The reported accumulation of warm Claude processes left a real Gateway host thrashing until reboot.
  • merge-risk: 🚨 availability: The new 1 GiB admission floor can refuse additional CLI conversations on constrained hosts; the collaborator-authored PR explicitly accepts this behavior to protect host availability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-04T04:43:15.064Z sha a646b6b :: needs changes before merge. :: [P2] Preserve the host-memory diagnosis in channel replies
  • reviewed 2026-11-04T05:33:16.635Z sha fe0a514 :: needs maintainer review before merge. :: none

Reviewed November 4, 2026, 12:42 AM ET / 05:42 UTC (Revision 3).

@obviyus
obviyus marked this pull request as ready for review November 4, 2026 05:03
@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 4, 2026
@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 4, 2026
@obviyus
obviyus merged commit de07e00 into main Nov 4, 2026
124 checks passed
@obviyus
obviyus deleted the fix/cli-live-session-memory branch November 4, 2026 05:52
@obviyus

obviyus commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in de07e00.

  • Bug: concurrent Claude CLI live sessions could exhaust host memory; the only limit was a fixed count of 16, so an 8 GB host thrashed for hours.
  • Fix: before a new live session starts, free memory below 1 GiB closes idle sessions in least-recently-used order; if none are idle, the turn fails over with a host-memory error and its own reply copy. Busy sessions are never closed.
  • Proof: entry-point tests that fail on main on behavior, plus an isolated Gateway run under simulated memory pressure.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…ns start at once (openclaw#192534)

## What Problem This Solves

Fixes: a Gateway using the Claude CLI runtime can push its host into memory exhaustion when several conversations start new Claude processes close together.

On an 8 GB Linux VM without swap, several Slack/Teams turns arrived within about 3 minutes. The Gateway went from 3 to 7 warm Claude CLI processes, available memory fell from ~3.8 GB to ~250 MB and stayed there, and the VM thrashed (no OOM kill, CPU ~5%) until a reboot about 2 hours later. The only limit on warm processes was a fixed count of 16; idle warm processes were kept even while the host ran out of memory.

## User Impact

User impact: when host memory is low, a new Claude CLI conversation first closes idle warm processes (least recently used first). If memory is still low and every warm process is busy, that turn fails over instead of starting another process, and a channel reply says: "⚠️ This host is low on memory, so it could not start another session. Try again after active conversations finish." (Before, any such failure would have shown the generic "AI service needs a short break" rate-limit copy.) Hosts with enough free memory behave as before; turns that reuse their own warm process are unaffected; busy turns are never closed.

## Why This Change Was Made

Before a turn starts a new warm process, the live-session registry reads host free memory through the existing `readHostFreeMemoryBytes()` helper (`os.freemem()`, which is `MemAvailable` on Linux; `process.availableMemory()` on macOS). It walks the warm processes once in least-recently-used order: while memory is below 1 GiB, it closes each idle process and waits for it to exit before the next reading. If memory is still below the floor after that pass, the turn fails over with the `rate_limit` category the 16-session cap already uses, plus a distinct `cli_live_session_host_memory` code. The existing failover-code copy (`renderFailoverCodeUserCopy`) owns its user text, and the rate-limit reply renderer now returns a host-authored code's copy before generic rate-limit text (auth-profile cooldown keeps its expiry-aware copy). The registry map is now kept in least-recently-used order, so both the memory path and the existing count cap close the conversation that has waited longest.

The 1 GiB floor comes from measurements of one warm session:

| Measurement | RSS |
| --- | --- |
| Claude Code 2.1.314, Linux arm64 container, stream-json, idle after start | ~180 MiB |
| Same, after one Haiku turn / three concurrent Sonnet turns | ~195–198 MiB each |
| Full warm session under a Gateway (macOS): Claude Code + two Node supervisor helpers | ~490 MiB (264 + 138 + 87) |

1 GiB leaves room for about two more warm sessions before the kernel has to reclaim. The 16-session cap stays as the upper bound. No config key is added.

## Evidence

- Two `executePluginOwnedProcess` tests (an entry point on both `main` and this branch), with host memory simulated at `readHostFreeMemoryBytes`:
  - Low memory, new conversation: the least recently used idle process closes; the busy one and the recently used one stay. On `main` this fails on behavior (`recent.close` not called).
  - Low memory, only a busy process: the turn rejects with `rate_limit` / `cli_live_session_host_memory` before the plugin runs, the busy process stays, and `resolveReplyFailureSummary` returns the host-memory copy. On `main` this fails on behavior (the turn runs: `reason: "exit"`).
- `src/agents/cli-runner/`, `extensions/anthropic`, and the CLI attempt-execution tests: 1479 passed on the candidate; the registry and `execute-plugin` tests pass on the exact head (108). One failure, `extensions/anthropic/session-catalog.test.ts` ("reports the discovery frontier…"), also fails alone on this host and does not touch the changed files.
- Real path on the previous head `a646b6b8` (the repair batch after it adds the failover code and copy and makes eviction one bounded pass; the tests above cover both): isolated Gateway (own state, config and Claude config dir, test API key from env only), `anthropic/claude-haiku-4-5` with `agentRuntime.id: "claude-cli"`, turns sent with `openclaw agent`. Memory pressure was simulated at the same seam the code reads (`os.freemem` / `process.availableMemory`), with each live Claude process under the Gateway counted as 700 MiB, so closing a process really raises the reading.
  - Real memory: 4 concurrent sessions start (`activeSessions=1…4`), no closures.
  - Low memory, new 5th session: `free-memory read: live claude processes=4 reported=424MiB` → `memory pressure: closing idle session activeSessions=4` → `processes=3 reported=1124MiB` → `cli live session start … activeSessions=4`; the turn replied.
  - Low memory, existing session: reused its warm process, no memory read, no closure; replied.
  - Low memory, all four warm sessions busy with long turns, new session: failed over in 54 ms (`Host memory is too low for another CLI live session.`); all four busy turns completed.

## Limits

- Admission only. A warm process that grows during a long turn after it started is not limited here.
- `readHostFreeMemoryBytes()` reads host memory on Linux, not a container cgroup limit; that helper is shared and unchanged.
- Turns that start at the same instant can each read the same free-memory value before any process exists; the floor's headroom covers a small burst, and the 16-session cap still holds.
- The failover category stays `rate_limit`, as the existing count cap uses; the distinct code carries the cause.
- The live check ran on macOS with a simulated reading; the Linux numbers come from an isolated Claude Code container run.

## Merge danger

Two-way door: a revert restores the previous behavior. No config, schema, stored state or published contract changes.

Blast radius: Gateways using a CLI runtime with warm live sessions (today Claude CLI). If the floor is wrong for a host, the effect is more closed idle sessions (a cold start on the next turn) or a failover when memory is below 1 GiB and every warm session is busy. Other runtimes and channels are not affected.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa pushed a commit that referenced this pull request Nov 17, 2026
…ns start at once (#192534)

## What Problem This Solves

Fixes: a Gateway using the Claude CLI runtime can push its host into memory exhaustion when several conversations start new Claude processes close together.

On an 8 GB Linux VM without swap, several Slack/Teams turns arrived within about 3 minutes. The Gateway went from 3 to 7 warm Claude CLI processes, available memory fell from ~3.8 GB to ~250 MB and stayed there, and the VM thrashed (no OOM kill, CPU ~5%) until a reboot about 2 hours later. The only limit on warm processes was a fixed count of 16; idle warm processes were kept even while the host ran out of memory.

## User Impact

User impact: when host memory is low, a new Claude CLI conversation first closes idle warm processes (least recently used first). If memory is still low and every warm process is busy, that turn fails over instead of starting another process, and a channel reply says: "⚠️ This host is low on memory, so it could not start another session. Try again after active conversations finish." (Before, any such failure would have shown the generic "AI service needs a short break" rate-limit copy.) Hosts with enough free memory behave as before; turns that reuse their own warm process are unaffected; busy turns are never closed.

## Why This Change Was Made

Before a turn starts a new warm process, the live-session registry reads host free memory through the existing `readHostFreeMemoryBytes()` helper (`os.freemem()`, which is `MemAvailable` on Linux; `process.availableMemory()` on macOS). It walks the warm processes once in least-recently-used order: while memory is below 1 GiB, it closes each idle process and waits for it to exit before the next reading. If memory is still below the floor after that pass, the turn fails over with the `rate_limit` category the 16-session cap already uses, plus a distinct `cli_live_session_host_memory` code. The existing failover-code copy (`renderFailoverCodeUserCopy`) owns its user text, and the rate-limit reply renderer now returns a host-authored code's copy before generic rate-limit text (auth-profile cooldown keeps its expiry-aware copy). The registry map is now kept in least-recently-used order, so both the memory path and the existing count cap close the conversation that has waited longest.

The 1 GiB floor comes from measurements of one warm session:

| Measurement | RSS |
| --- | --- |
| Claude Code 2.1.314, Linux arm64 container, stream-json, idle after start | ~180 MiB |
| Same, after one Haiku turn / three concurrent Sonnet turns | ~195–198 MiB each |
| Full warm session under a Gateway (macOS): Claude Code + two Node supervisor helpers | ~490 MiB (264 + 138 + 87) |

1 GiB leaves room for about two more warm sessions before the kernel has to reclaim. The 16-session cap stays as the upper bound. No config key is added.

## Evidence

- Two `executePluginOwnedProcess` tests (an entry point on both `main` and this branch), with host memory simulated at `readHostFreeMemoryBytes`:
  - Low memory, new conversation: the least recently used idle process closes; the busy one and the recently used one stay. On `main` this fails on behavior (`recent.close` not called).
  - Low memory, only a busy process: the turn rejects with `rate_limit` / `cli_live_session_host_memory` before the plugin runs, the busy process stays, and `resolveReplyFailureSummary` returns the host-memory copy. On `main` this fails on behavior (the turn runs: `reason: "exit"`).
- `src/agents/cli-runner/`, `extensions/anthropic`, and the CLI attempt-execution tests: 1479 passed on the candidate; the registry and `execute-plugin` tests pass on the exact head (108). One failure, `extensions/anthropic/session-catalog.test.ts` ("reports the discovery frontier…"), also fails alone on this host and does not touch the changed files.
- Real path on the previous head `a646b6b8` (the repair batch after it adds the failover code and copy and makes eviction one bounded pass; the tests above cover both): isolated Gateway (own state, config and Claude config dir, test API key from env only), `anthropic/claude-haiku-4-5` with `agentRuntime.id: "claude-cli"`, turns sent with `openclaw agent`. Memory pressure was simulated at the same seam the code reads (`os.freemem` / `process.availableMemory`), with each live Claude process under the Gateway counted as 700 MiB, so closing a process really raises the reading.
  - Real memory: 4 concurrent sessions start (`activeSessions=1…4`), no closures.
  - Low memory, new 5th session: `free-memory read: live claude processes=4 reported=424MiB` → `memory pressure: closing idle session activeSessions=4` → `processes=3 reported=1124MiB` → `cli live session start … activeSessions=4`; the turn replied.
  - Low memory, existing session: reused its warm process, no memory read, no closure; replied.
  - Low memory, all four warm sessions busy with long turns, new session: failed over in 54 ms (`Host memory is too low for another CLI live session.`); all four busy turns completed.

## Limits

- Admission only. A warm process that grows during a long turn after it started is not limited here.
- `readHostFreeMemoryBytes()` reads host memory on Linux, not a container cgroup limit; that helper is shared and unchanged.
- Turns that start at the same instant can each read the same free-memory value before any process exists; the floor's headroom covers a small burst, and the 16-session cap still holds.
- The failover category stays `rate_limit`, as the existing count cap uses; the distinct code carries the cause.
- The live check ran on macOS with a simulated reading; the Linux numbers come from an isolated Claude Code container run.

## Merge danger

Two-way door: a revert restores the previous behavior. No config, schema, stored state or published contract changes.

Blast radius: Gateways using a CLI runtime with warm live sessions (today Claude CLI). If the floor is wrong for a host, the effect is more closed idle sessions (a cold start on the next turn) or a failover when memory is below 1 GiB and every warm session is busy. Other runtimes and channels are not affected.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit de07e00)

Release adaptation: revalidate the existing current-run authority between awaited idle-process cleanup and before capability creation; use the abort-race lazy factory so an already-aborted request starts no close. Preserve baseline cleanup-finally repair. Add one execution-boundary regression for revoked requester authority; no unrelated follow-ups.

# #192534 companion dispositions

Signed baseline e13cf15; audit bd692e9. Working base 8b3ca5d lacks the memory floor and activation LRU refresh; 16-count limit exists. Mechanical probe: clean, six touched files. Exact merged source de07e00.

Later same-path commits, each reviewed in saved relevant-followups.patch / other-followups.patch:
- 30e9d3e #200073: not-applicable, listed model chat rejection code/copy independent of host memory.
- 3a3eed8 #199591: not-applicable, tool loop policy refactor independent of memory admission.
- 8fc58f8 #199226: not-applicable, app naming copy independent of memory.
- 8ccba17 #198426: not-applicable to this admission change, warm callback async-context repair independent; do not silently absorb. Existing requestToolPermission is bound; no callback change required by memory.
- 2110db5 #198288: not-applicable, model chat eligibility and code/copy independent.
- 4527846 #198324: not-applicable, provider rate-limit reset deadlines; host-local memory refusal has no provider deadline.
- 4f8df80 #198224: present-equivalent, baseline registry remove already uses finally and releases retired map after failed cleanup.
- 8cd7d87 #197655: not-applicable, main test allocation pruning; retain this release allocation.
- 5dc6683 #197163: present-equivalent, buildHarnessHostRequester used in baseline; separate tool hook metadata.
- 7786960 #197051: not-applicable, managed WebSearch availability, independent tool policy.
- ac7e941 #196677: not-applicable, expired API-key copy independent of host admission.
- 4d6205c #194439: not-applicable, provider failure/tool warning handling independent of pre-execution host refusal.
- 4845a0f #193508: not-applicable, native credential removal propagation; no new credentials accessed by memory policy. Existing live assertion retained/rechecked.
- 6f69195 #193250: not-applicable, exhausted upstream credit failover category independent of local resource refusal.
No later #192534 mentions.

Prerequisites: readHostFreeMemoryBytes exists unchanged in baseline; @openclaw/retry abort race accepts lazy factory; createCliFailoverError preserves explicit code; FailoverError carries code; existing rate-limit reply renderer consumes it; registry closeRecord joins process exit and owned cleanup. These are present-equivalent.

Neighbor tests: cli-live-session-registry.test.ts, execute-plugin.test.ts, execute-plugin.policy.test.ts, execute-plugin.steering.test.ts, failover/user-copy.test.ts are existing consumers, not missing implementation companions. execute-plugin.warm-context.test.ts exists only after the independent #198426 change and is not applicable to this baseline or memory fix. Run focused registry/execution/copy siblings. Selected-file references: broad generic filename inventory is mostly incidental error/execute references; traced actual owners/imports above. Docs and allocation are non-runtime references; no generated exports or workflow changes needed.

Focused proof: baseline 2 failed/36 passed (LRU eviction missing; busy-only admission incorrectly exits successfully). Green 135 passed across five existing owner/consumer files, including host-memory failure copy and revoked-requester preservation. Format and diff checks clean. Type-aware lint blocked by the established shared TypeScript declaration-confinement boundary; no bypass/install. Parent owns integration and broad release qualification.

Co-authored-by: RomneyDa <[email protected]>

Parent qualification: corrected the authority regression's required braces and matching test allocation (102 lines); no production change from worker. Combined 145/145 tests across seven files passed; post-braces changed suite 39/39 passed. Supported parent type-aware lint and formatting passed six files, executable syntax and diff checks passed. Worker dependency-layout lint limitation resolved. Parent self-review and source/companion comparison recorded in cli-resources-parent-review.md. Full stable/FRV remains pending; publication held.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant