Skip to content

[Bug]: macOS app's first message fails with false "host is low on memory" because Bun's process.availableMemory() is free pages only #200340

Closed

Description

@jalehman

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

In the macOS app on current main, the first chat message after a fresh onboarding fails with "This host is low on memory, so it could not start another session." The Mac has plenty of memory. The packaged Gateway runs on Bun, and under Bun process.availableMemory() returns only truly free pages, so the 1 GiB Claude CLI live-session guard trips on a healthy Mac.

Steps to reproduce

  1. Build the macOS app from main at d29fad4 (scripts/package-mac-app.sh, debug, arm64) and launch it on a fresh profile (OPENCLAW_PROFILE=onboarding).
  2. Complete onboarding with a local Gateway, using Claude Code (claude-cli/claude-opus-5-5) as the AI.
  3. Choose Talk to my agent and send hi.

Expected behavior

The agent replies. The host was a 48 GB Apple silicon MacBook Pro, and memory_pressure reported "System-wide memory free percentage: 70%" at the time.

Actual behavior

The turn fails before any model call. The chat shows "This host is low on memory, so it could not start another session. Try again after active conversations finish." with Try again / Report a bug.

Gateway log (~/.openclaw-onboarding/logs/openclaw-onboarding-2026-11-16.log):

lane task error: lane=cli:claude-cli:owner:… durationMs=5 error="Host memory is too low for another CLI live session."
cli terminal failure: provider=claude-cli model=claude-opus-5-5 durationMs=344 … error=Host memory is too low for another CLI live session.
model fallback decision: … reason=rate_limit status=429 code=cli_live_session_host_memory … fallbackStepFinalOutcome=chain_exhausted fallbackConfigured=false
Embedded agent failed before reply: Host memory is too low for another CLI live session.

The same Mac, measured with the bundled runtime and with Node at the same moment:

Runtime process.availableMemory() os.freemem() os.totalmem()
Bundled Bun 1.4.4 (~/.openclaw-onboarding/runtime/…/bin/bun) 548,831,232 (0.55 GB) 548,831,232 51,539,607,552
Node 26.12.1 19,644,563,456 (19.6 GB) 548,831,232 —

Under Bun on macOS, process.availableMemory() is identical to os.freemem(). macOS keeps truly free pages low, so most Macs in normal use read below 1 GiB.

OpenClaw version

main d29fad4 (2026.11.4, app build 2611160101)

Operating system

macOS 26.5.1 (arm64)

Install method

mac app (locally packaged from main, isolated OPENCLAW_PROFILE)

Model

claude-cli/claude-opus-5-5 (shown in the UI as anthropic/claude-opus-5-5)

Provider / routing chain

openclaw (mac app, local Gateway on Bun) -> claude-cli live session -> Anthropic

Additional provider/model setup details

No fallback model configured (fresh onboarding default).

Logs

See Actual behavior.

Screenshots, recordings, and evidence

Code at the tested commit:

Impact and severity

  • Who: every macOS app user whose first agent runs through the Claude CLI live session. The packaged Gateway always runs on Bun.
  • Severity: blocks the first message after onboarding. The user is told their Mac is out of memory when it is not. The error is categorized as rate_limit/429, so it is retried or reported as capacity instead of a bug.
  • Release exposure: the guard is on main only. It is not in v2026.11.1–v2026.11.3 or v2026.11.5-beta.1. It will ship in the next release cut from main unless fixed.

Additional information

Contributing changes. Each change was reasonable on its own; the failure is in how they combine.

  1. feat(macos): run the private app runtime on the OpenClaw Bun fork #161603 (merged 2026-09-30, first shipped in v2026.10.1) moved the macOS app's private runtime, including the local Gateway, to the OpenClaw Bun fork.
  2. fix(devices): report available host memory #144535 (merged 2026-10-10, shipped in v2026.10.10) added readHostFreeMemoryBytes() with a macOS branch that relies on Node's process.availableMemory(). The app had already been running on Bun for ten days. At that point the only effect was understated free memory in device/host stats.
  3. fix(cli): host runs out of memory when several Claude CLI conversations start at once #192534 (merged 2026-11-04, unreleased) added the blocking 1 GiB guard on top of that helper. Its description states the helper reads process.availableMemory() on macOS. Its proof simulated memory at the helper/os.freemem seam, so the packaged macOS app on Bun was never exercised.

Process gaps:

  • Nothing tests the host-memory helper under the runtime the macOS app actually ships (Bun). Unit tests mock the reading.
  • No packaged-app smoke test sends a first message after a fresh onboarding. A single "fresh install → first reply" check would have caught this before merge.
  • The failure maps to rate_limit, which hides a local guard decision behind a provider-capacity category.

Other callers with the same Bun-on-macOS assumption. These are not user-blocking but read too low under Bun:

  • src/infra/worker-pool-sizing.ts resolveUpdateHashWorkerCount() (process.availableMemory(); only Bun on Linux is special-cased).
  • src/commands/doctor-database-port-memory-concurrency.ts (readHostFreeMemoryBytes() → undersized rebuild concurrency).
  • src/gateway/server-methods/system.ts and src/node-host/host-stats.ts (reported free memory).
  • isConstrainedProcessLowOnMemory() uses process.constrainedMemory(); verify its Bun/macOS behavior while fixing.

Suggested direction: on darwin, compute reclaimable memory independently of the JS runtime (Mach VM statistics: free + inactive + purgeable + speculative) or detect a Bun-equivalent reading. Cover it with a test that simulates Bun's availableMemory == freemem behavior. Optionally, stop classifying this guard as rate_limit.

Found during a fresh-install onboarding walkthrough of the macOS app.

Activity

  1. added
    bug
    on Nov 17, 2026
  2. added
    clawsweeper:intake:bug
    P0
    clawsweeper:source-repro
    impact:ux-release-blocker
    issue-rating: 🦞 diamond lobster
    and removed
    clawsweeper:intake:bug
    on Nov 17, 2026
  3. clawsweeper commented on Nov 17, 2026

    @clawsweeper
    Contributor

    Codex review: this still needs some work.

    Summary
    This issue identifies a current first-message blocker: the packaged Bun runtime reports only free pages, and OpenClaw treats that reading as available memory when admitting a new Claude CLI session.

    Reproducibility: The reporter's 548,831,232-byte Bun reading necessarily fails the current 1 GiB guard, and the pinned runtime source confirms that reading excludes reclaimable memory; no reviewer-run macOS reproduction is claimed.

    Regression provenance
    Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

    Next step
    A maintainer should authorize the supported-runtime repair, establish a failing Darwin regression and packaged-app first-reply proof, and provide inline recovery for affected users.

    Review details

    Best possible solution:

    Correct the supported Bun runtime's memory semantics while retaining genuine pressure protection, and offer inline recovery for users already blocked.

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

    The reporter's 548,831,232-byte Bun reading necessarily fails the current 1 GiB guard, and the pinned runtime source confirms that reading excludes reclaimable memory; no reviewer-run macOS reproduction is claimed.

    Is this the best way to solve the issue?

    Repairing the supported runtime contract avoids duplicating native memory accounting in OpenClaw; lowering or removing the guard would weaken protection against the independently documented exhaustion incident.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • A corrected runtime has not been exercised through fresh macOS onboarding and a first reply in this review.
    • The pinned Bun constrainedMemory implementation also changes the shared background-pressure predicate's meaning and needs validation alongside available-memory semantics.
    • A runtime-fork repair and dependency-pin update require explicit maintainer authorization under repository policy.

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

    Label changes

    Label changes:

    No label changes.

    Label justifications:

    • P0: The reported fresh-onboarding path cannot complete its first useful turn, and retrying cannot correct the runtime's memory reading.
    • impact:ux-release-blocker: A first-time macOS app user receives a false low-memory error without an effective in-product recovery path.
    Evidence reviewed

    What I checked:

    • Current memory reader assumes Node semantics: On Darwin, readHostFreeMemoryBytes returns any positive process.availableMemory reading without accounting for the packaged runtime's different semantics. (src/infra/host-memory.ts:12, d46027380a18)
    • First session can fail before execution: With no registered sessions, ensureCliLiveSessionMemory reaches the final comparison directly and throws below 1 GiB; execute-plugin invokes it before starting the backend. (src/agents/cli-runner/cli-live-session-registry.ts:217, d46027380a18)
    • Packaged runtime is an affirmative dependency: Mac packaging stages the private Bun runtime, whose manifest pins openclaw/bun commit 191755ec115ece3dd642eba3cb0143cecb5e5d7a; inspecting that runtime's contract is necessary to assess this issue. (scripts/lib/openclaw-bun.json:3, d46027380a18)
    • Pinned available-memory implementation: Process_availableMemory calls Bun__Os__getFreeMemory, the same function used by os.freemem; constrainedMemory separately returns WTF::ramSize rather than an absent-limit sentinel. (src/jsc/bindings/BunProcess.cpp:3673, 191755ec115e)
    • Darwin implementation counts only free pages: Bun__Os__getFreeMemory returns info.free_count multiplied by the page size, excluding reclaimable pages and confirming the reported semantic mismatch directly in the pinned source. (src/jsc/bindings/OsBinding.cpp:20, 191755ec115e)
    • Existing tests bypass the broken runtime boundary: CLI execution tests replace readHostFreeMemoryBytes, while node-host tests mock process.availableMemory; neither establishes the packaged Bun reading on Darwin. (src/agents/cli-runner/execute-plugin.test.ts:33, d46027380a18)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed November 16, 2026, 8:26 PM ET / November 17, 2026, 01:26 UTC.

  4. orinkepler commented on Nov 21, 2026

    @orinkepler

    This still reproduces on the latest stable release, v2026.11.6 (macOS app, packaged Bun gateway, claude-cli/claude-opus-5-5), with the same cli_live_session_host_memory failure on every turn.

    It looks like the fix in #200373 was merged to main but hasn't been picked into any release yet. src/infra/host-memory.ts at both v2026.11.6 and v2026.11.10-beta.1 still calls process.availableMemory() directly in readHostFreeMemoryBytes(), and the merge commit 71d835b isn't an ancestor of either tag.

    Numbers from a 24 GB Mac mini at the time of failure:

    Backporting the #200373 host-memory.ts change onto the v2026.11.6 dist resolved it locally. Could this be reopened, or the fix cherry-picked into the next stable/beta?

  5. towler73 commented on Nov 24, 2026

    @towler73

    Confirmed this still affects the packaged 2026.11.6 (da6d981) macOS Gateway with Bun 1.4.4, using Claude Sonnet 4.6.

    The new-live-session guard repeatedly rejects turns with cli_live_session_host_memory and classifies them as rate_limit / 429, causing configured model fallback.

    Reproduction measurements on a 48 GiB Mac:

    • Bundled runtime process.availableMemory() matched os.freemem(): approximately 400–500 MiB.
    • Installed readHostFreeMemoryBytes() returned approximately 403 MiB, below the unchanged 1 GiB admission threshold.
    • macOS VM counters showed roughly 14 GiB inactive memory.

    Locally backported the src/infra/host-memory.ts implementation from 71d835b / #200373, transpiled with the bundled Bun and preserving the installed module export aliases. No guard threshold or model configuration changes.

    Verification:

    • Patched helper reads approximately 15.5 GiB available.
    • Synthetic low-memory, healthy-memory, and kernel-query-failure/fallback checks pass.
    • A fresh isolated openclaw agent exec --model anthropic/claude-sonnet-4-6 run starts a Claude CLI live session and returns the expected smoke-test response; result identifies Anthropic / Claude Sonnet 4.6, not the fallback model.

    The running service restart was deferred until active work drains; the successful end-to-end smoke test used a new embedded process loading the patched module.

    Please include this fix in a supported stable release/backport. This corroborates the existing report that the source fix has not reached the 2026.11.6 packaged release. Local dist patches are overwritten by runtime updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0bugclawsweeper:source-reproimpact:ux-release-blockerissue-rating: 🦞 diamond lobster

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions