openclaw - ✅(Solved) Fix iMessage duplicate replies when both channels.imessage.accounts.default and a named account exist [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#65141Fetched 2026-04-12 13:25:21
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

OpenClaw may start two iMessage watchers for the same local Messages source when channels.imessage.accounts contains both:

  • a named account, for example swang430-gmail-com
  • default

This can cause one inbound iMessage to be processed twice, resulting in duplicate replies.

In my case, sending one ping resulted in two pong replies.

Root Cause

Likely root cause

Fix Action

Workaround

Setting the default iMessage account to disabled fixed it:

"default": {
  "enabled": false,
  "dmPolicy": "pairing",
  "groupPolicy": "allowlist"
}

After restarting the gateway, only one imsg rpc process remained:

29183     1 openclaw-gateway
29278 29183 /usr/local/Cellar/imsg/0.4.0/libexec/imsg rpc

And ping -> pong returned to normal, with only one reply.

PR fix notes

PR #65194: fix(imessage): avoid duplicate default monitor startup

Description (problem / solution / changelog)

Summary

This PR prevents duplicate iMessage monitor startup when channels.imessage.accounts contains both:

  • a named account
  • default used only as fallback config

Before this change, both could be treated as enabled monitor accounts, which could start two imsg rpc watcher processes for the same local Messages backend and cause duplicate inbound handling.

What changed

  • Skip default in listEnabledIMessageAccounts() when:
    • at least one named iMessage account exists, and
    • default does not define its own distinct runtime/backend config
  • Keep default enabled when it really represents a separate runtime, for example a distinct cliPath or dbPath
  • Add tests for both cases

Reproduction

A real-world configuration shape that triggered the bug:

{
  "channels": {
    "imessage": {
      "enabled": true,
      "accounts": {
        "swang430-gmail-com": {
          "enabled": true,
          "cliPath": "imsg",
          "dmPolicy": "pairing",
          "groupPolicy": "allowlist"
        },
        "default": {
          "dmPolicy": "pairing",
          "groupPolicy": "allowlist"
        }
      }
    }
  }
}

This produced two imsg rpc processes under one openclaw-gateway parent and one inbound ping resulted in two outbound pong replies.

Validation

Targeted test run passed:

npm test -- --run extensions/imessage/src/accounts.test.ts

Notes

I used --no-verify for the local commit because this checkout hit unrelated repository-wide check failures in the current environment, including existing type/dependency errors outside the changed files. The targeted iMessage test for this patch passed.

Closes #65141

Changed files

  • extensions/imessage/src/accounts.test.ts (modified, +75/-1)
  • extensions/imessage/src/accounts.ts (modified, +23/-1)

Code Example

{
  "bindings": [
    {
      "agentId": "main",
      "match": {
        "channel": "imessage",
        "accountId": "swang430-gmail-com"
      }
    }
  ],
  "channels": {
    "imessage": {
      "enabled": true,
      "accounts": {
        "swang430-gmail-com": {
          "enabled": true,
          "cliPath": "imsg",
          "dmPolicy": "pairing",
          "groupPolicy": "allowlist"
        },
        "default": {
          "dmPolicy": "pairing",
          "groupPolicy": "allowlist"
        }
      }
    }
  }
}

---

ps -o pid,ppid,command -ax | grep -i '[i]msg rpc\|[o]penclaw-gateway'

---

28321     1 openclaw-gateway
28454 28321 /usr/local/Cellar/imsg/0.4.0/libexec/imsg rpc
28470 28321 /usr/local/Cellar/imsg/0.4.0/libexec/imsg rpc

---

id: 562, text: "ping", is_from_me: false
id: 563, text: "pong", is_from_me: true
id: 564, text: "pong", is_from_me: true

---

"default": {
  "enabled": false,
  "dmPolicy": "pairing",
  "groupPolicy": "allowlist"
}

---

29183     1 openclaw-gateway
29278 29183 /usr/local/Cellar/imsg/0.4.0/libexec/imsg rpc
RAW_BUFFERClick to expand / collapse

Summary

OpenClaw may start two iMessage watchers for the same local Messages source when channels.imessage.accounts contains both:

  • a named account, for example swang430-gmail-com
  • default

This can cause one inbound iMessage to be processed twice, resulting in duplicate replies.

In my case, sending one ping resulted in two pong replies.

Environment

  • OpenClaw version: 2026.4.9
  • macOS: Darwin 24.6.0
  • iMessage CLI: imsg 0.4.0

Config shape

{
  "bindings": [
    {
      "agentId": "main",
      "match": {
        "channel": "imessage",
        "accountId": "swang430-gmail-com"
      }
    }
  ],
  "channels": {
    "imessage": {
      "enabled": true,
      "accounts": {
        "swang430-gmail-com": {
          "enabled": true,
          "cliPath": "imsg",
          "dmPolicy": "pairing",
          "groupPolicy": "allowlist"
        },
        "default": {
          "dmPolicy": "pairing",
          "groupPolicy": "allowlist"
        }
      }
    }
  }
}

Actual behavior

After gateway start, there were two imsg rpc processes under one openclaw-gateway parent.

Example process list:

ps -o pid,ppid,command -ax | grep -i '[i]msg rpc\|[o]penclaw-gateway'

Observed output before workaround:

28321     1 openclaw-gateway
28454 28321 /usr/local/Cellar/imsg/0.4.0/libexec/imsg rpc
28470 28321 /usr/local/Cellar/imsg/0.4.0/libexec/imsg rpc

Message history also showed one inbound message followed by two outbound replies:

id: 562, text: "ping", is_from_me: false
id: 563, text: "pong", is_from_me: true
id: 564, text: "pong", is_from_me: true

Expected behavior

Only one iMessage watcher should be started for a single local iMessage source, and one inbound message should only be handled once.

Workaround

Setting the default iMessage account to disabled fixed it:

"default": {
  "enabled": false,
  "dmPolicy": "pairing",
  "groupPolicy": "allowlist"
}

After restarting the gateway, only one imsg rpc process remained:

29183     1 openclaw-gateway
29278 29183 /usr/local/Cellar/imsg/0.4.0/libexec/imsg rpc

And ping -> pong returned to normal, with only one reply.

Likely root cause

It looks like iMessage account enumeration or monitor startup is treating both:

  • channels.imessage.accounts.default
  • the explicitly named iMessage account

as active monitor targets, even though they point to the same local iMessage backend.

This creates duplicate watch.subscribe consumers for the same source.

Suggested fix

Possible fixes:

  1. Do not start a monitor for default when it is only acting as fallback config and a concrete bound account is already used.
  2. Respect enabled: false consistently during iMessage monitor enumeration.
  3. Deduplicate iMessage monitor startup when multiple account configs resolve to the same effective local backend, for example cliPath, dbPath, and account identity.

Notes

This does not appear to be caused by missing self-message filtering alone. The key symptom was duplicate inbound handling caused by duplicate watchers.

extent analysis

TL;DR

Disabling the default iMessage account or ensuring that only one iMessage watcher is started for a single local iMessage source can prevent duplicate replies.

Guidance

  • Verify that the channels.imessage.accounts configuration does not contain both a named account and default enabled, as this can cause duplicate iMessage watchers.
  • Check the process list to ensure only one imsg rpc process is running under the openclaw-gateway parent.
  • Consider implementing a fix to deduplicate iMessage monitor startup when multiple account configs resolve to the same effective local backend.
  • Review the iMessage account enumeration or monitor startup logic to ensure it correctly handles default and named accounts.

Example

No code snippet is provided as the issue is related to configuration and process management.

Notes

The provided workaround of disabling the default iMessage account fixes the issue, but a more robust solution would involve modifying the iMessage account enumeration or monitor startup logic to handle duplicate accounts correctly.

Recommendation

Apply the workaround by disabling the default iMessage account, as it is a simple and effective solution to prevent duplicate replies. A more permanent fix would require modifying the OpenClaw code to correctly handle iMessage account enumeration and monitor startup.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Only one iMessage watcher should be started for a single local iMessage source, and one inbound message should only be handled once.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING