Skip to content

gateway restart from agent session causes self-decapitation on macOS (launchd) #43311

@mcooks-cmd

Description

@mcooks-cmd

Bug type

Behavior bug (incorrect output/state without crash)

Summary

When an agent session calls openclaw gateway restart on macOS, the gateway process dies (via launchctl bootout) but never comes back — because bootout unloads the service definition, preventing launchd from respawning it despite KeepAlive: true. The user must manually run openclaw gateway install to recover.

Steps to reproduce

  1. Install OpenClaw on macOS with LaunchAgent (openclaw gateway install)
  2. Verify gateway is running as a LaunchAgent with KeepAlive: true
  3. From an active agent session (e.g., Telegram chat or cron job), trigger openclaw gateway restart (either directly via exec tool, or indirectly through agent logic)
  4. Gateway performs launchctl bootout gui/$UID/ai.openclaw.gateway
  5. Process dies — the agent session dies with it
  6. Gateway stays down indefinitely

Expected behavior

gateway restart should survive self-invocation. The gateway should come back up automatically after the restart, whether called from an agent session or externally.

Actual behavior

Gateway process is killed and never restarts. launchctl list | grep openclaw shows exit code -15 (SIGTERM). The LaunchAgent plist is unloaded by bootout, so launchd doesn't know to respawn it. User must run openclaw gateway install from a separate terminal to re-register the service.

OpenClaw version

2026.3.8 (3caab92)

Operating system

macOS 15.3 (arm64, Apple Silicon M4)

Install method

pnpm global

Model

anthropic/claude-opus-4-6 (not model-specific — affects any model)

Provider / routing chain

openclaw -> anthropic (direct)

Config file / key location

No response

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

  • Affected: Any macOS user whose agent calls openclaw gateway restart (e.g., to clear stale cron locks)
  • Severity: High — gateway goes down completely, all channels (Telegram, Slack, etc.) stop receiving/sending messages
  • Frequency: 100% reproducible on macOS with LaunchAgent install
  • Consequence: Complete agent downtime until user manually intervenes with openclaw gateway install. Cron jobs stop, heartbeats stop, all channel connectivity lost.

Additional information

Suggested fix: Use launchctl kickstart -k gui/$UID/ai.openclaw.gateway instead of bootout + bootstrap. This sends SIGTERM while keeping the service loaded, so launchd respawns it via KeepAlive: true.

Alternatively, gateway restart could:

  1. Detect it's being called from within an active agent session and warn/refuse (with instructions to restart externally)
  2. Fork a detached process to perform the bootstrap after bootout

Workaround: Don't call openclaw gateway restart from within agent sessions. Use openclaw gateway install from a separate terminal instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions