Skip to content

[BUG] openclaw gateway restart command fails and Gateway does not restart automatically (macOS LaunchAgent) #40932

@Suidge

Description

@Suidge

Bug Description

When running openclaw gateway restart via OpenClaw tool call (exec) after upgrading to v2026.3.8, the command fails with "missing tool result" error, and the Gateway does not restart automatically. Manual intervention is required to restart the Gateway.

Important:

  • This issue started after upgrading from v2026.3.7 to v2026.3.8
  • Running the same command directly in terminal works correctly
  • Issue only occurs when executed via tool call/API

Observed Behavior

When executed via OpenClaw tool call:

  1. Run openclaw gateway restart via exec tool
  2. Command returns error: [openclaw] missing tool result in session history
  3. Gateway process stops but does not restart
  4. openclaw status shows Gateway as offline
  5. User must manually restart Gateway (via openclaw doctor or launchctl)

When executed directly in terminal:

  1. Run openclaw gateway restart in terminal
  2. Command completes successfully
  3. Gateway restarts automatically
  4. No error message

Expected Behavior

The gateway restart command should work consistently regardless of execution method:

  • Stop the current Gateway process
  • Automatically start a new Gateway process
  • Return success confirmation after restart completes

Logs

Command output (via tool call):

[openclaw] missing tool result in session history; inserted synthetic error result for transcript repair.

Gateway logs show shutdown but NO automatic restart:

20:55:34.315 [gateway] signal SIGTERM received
20:55:34.316 [gateway] received SIGTERM; shutting down
20:55:34.330 [feishu] feishu[default]: abort signal received, stopping
20:55:34.332 [ws] webchat disconnected code=1012 reason=service restart
# ... 1 minute 34 seconds of SILENCE (Gateway completely offline) ...
# Gateway only started after manual intervention at 20:57:08
20:57:08.724 [gateway] feishu_doc: Registered feishu_doc, feishu_app_scopes
20:57:09.013 [gateway] listening on ws://127.0.0.1:18789

Key observations:

  1. SIGTERM signal was correctly sent and received
  2. Gateway shut down gracefully
  3. LaunchAgent KeepAlive did NOT trigger automatic restart
  4. Gateway remained offline for 1 minute 34 seconds
  5. Only restarted after user manually ran openclaw doctor

Environment

  • OpenClaw version: v2026.3.8 (upgraded from v2026.3.7)
  • Node.js: v25.8.0
  • OS: macOS (Apple Silicon)
  • Gateway mode: LaunchAgent (KeepAlive: true)
  • LaunchAgent plist: ~/Library/LaunchAgents/ai.openclaw.gateway.plist
  • Execution method: OpenClaw exec tool vs direct terminal
  • Issue started: After upgrading to v2026.3.8 on 2026-03-09

Workaround

Manually restart Gateway:

# Option 1: Using launchctl
launchctl bootout gui/$UID/ai.openclaw.gateway
sleep 2
launchctl bootstrap gui/$UID/ai.openclaw.gateway

# Option 2: Direct terminal execution
openclaw gateway restart  # Works when run directly in terminal

# Option 3: Reinstall service
openclaw doctor  # Reinstalls LaunchAgent service

Additional Context

  • Gateway is configured with LaunchAgent KeepAlive=true
  • Expected LaunchAgent to automatically restart the process
  • Issue only occurs when executed via OpenClaw tool call (exec)
  • Direct terminal execution works correctly
  • This is a regression in v2026.3.8 - worked correctly in v2026.3.7
  • Possible causes:
    • exec tool execution environment differs from interactive shell
    • Missing environment variables in tool execution context
    • LaunchAgent cannot detect process termination from tool-spawned processes
    • Signal handling issue when SIGTERM is sent from tool-spawned process
    • Gateway exits with code 0 (success) when stopped via tool call, so LaunchAgent doesn't consider it a failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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