Skip to content

fix(imessage): stop dropping user text that collides with recent outbound sends - #120260

Merged
steipete merged 2 commits into
mainfrom
steipete/imessage-echo-guards
Aug 7, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/imessage-echo-guards

Conversation

@steipete

@steipete steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes two message-loss paths in the iMessage monitor:

  1. Text echo false positives. The persisted 12-hour echo cache matched inbound user text against previously sent outbound text even when the message GUIDs conflicted. A user replying "ok" or "done" within 12 hours of the agent sending the same short text in that conversation was silently classified as a reconnect echo and dropped — permanently. The media branch directly below already had the hasConflictingMessageIds guard (added in 0ac7b24); the text branch was missing it.
  2. Loop limiter tripped by normal sends. Every is_from_me row fed the echo-loop rate limiter, so an ordinary outbound burst — agent replies, multi-chunk sends, the operator texting from their own phone — could trip the limiter, which then silently suppressed the next legitimate inbound messages (verbose-only log).

Why This Change Was Made

Genuine reconnect echoes match via the messageId branch (same GUID) or via id-less pending entries, so the id-conflict guard is a no-op for every legitimate echo — its absence protected nothing and violated the in-memory cache's documented "never message loss" contract. For the limiter, own-send rows are expected transport traffic, not amplification signal; only echo/self-chat echo/reflected assistant content remain loop signals. A tripped limiter now also logs a default-level warning once per conversation, so suppression is never invisible.

User Impact

iMessage users can send short replies that collide with recent agent output without losing them, and busy conversations no longer silently mute after outbound bursts.

Evidence

…nds stop feeding the loop limiter

Two silent-drop paths in the iMessage monitor:
1. The persisted 12h echo cache matched inbound user text against old
outbound text even when the GUIDs conflicted — a user sending 'ok' within
12h of the agent sending 'ok' was dropped as an echo. The text branch now
applies the same hasConflictingMessageIds guard the media branch has;
genuine reconnect echoes still match by id or id-less entries.
2. Every from-me row fed the echo loop rate limiter, so a normal outbound
burst (agent replies, multi-chunk sends, operator phone traffic) could trip
the limiter and silently suppress the next legitimate inbound message.
'from me' is no longer counted as a loop signal, and a tripped limiter now
logs a default-level warning once per conversation instead of verbose-only.
@openclaw-barnacle openclaw-barnacle Bot added channel: imessage Channel integration: imessage size: XS maintainer Maintainer-authored PR labels Aug 7, 2026
@steipete
steipete marked this pull request as ready for review August 7, 2026 15:51
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 7, 2026, 12:39 PM ET / 16:39 UTC.

ClawSweeper review

What this changes

The PR changes iMessage echo matching and loop-limit accounting so same-text inbound messages and ordinary outbound bursts are not silently discarded.

Merge readiness

⛔ Blocked by patch quality or review findings - 9 items remain

Keep this maintainer PR open: its no-GUID self-chat path still dispatches delayed agent echoes after the in-memory cache expires, and its new default warning logs raw DM sender identifiers.

Priority: P1
Reviewed head: 00a823a6040a66aca561f1d72349837001fe94b5

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The intended fixes are focused, but two previously reported exact-head defects still block correctness.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its focused test claim remains supplemental to the required exact-head repair.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its focused test claim remains supplemental to the required exact-head repair.
Evidence reviewed 5 items Persisted self-chat regression: The new conflicting-ID text guard rejects a persisted GUID-backed outbound entry when a no-GUID self-chat row supplies its numeric SQLite ID, despite the caller's explicit text-fallback exception.
Caller contract: The self-chat owner passes skipIdShortCircuit when the inbound row has no GUID, but the cache does not forward that option to persisted matching; after the four-second memory TTL, the later self-chat dedupe is deliberately bypassed.
Default-log data exposure: The added warning interpolates conversationKey, whose DM form includes the unredacted message sender; existing drop diagnostics intentionally omit that field.
Findings 2 actionable findings [P1] Preserve no-GUID self-chat echo matching
[P2] Redact the conversation identifier before warning
Security Needs attention Raw sender identifier in default warning: The warning interpolates the DM conversation key, which is constructed from the inbound sender and can expose a phone number or address in normal logs.

How this fits together

The iMessage monitor converts bridge database rows into inbound agent events. Echo caches and the loop limiter suppress reflected messages before the monitor either dispatches an event or records an intentional drop.

flowchart LR
  A[iMessage bridge rows] --> B[Inbound decision]
  B --> C[In-memory and persisted echo caches]
  B --> D[Loop limiter]
  C --> E[Dispatch or echo drop]
  D --> E
  E --> F[Agent conversation]
Loading

Before merge

  • Preserve no-GUID self-chat echo matching (P1) - The self-chat caller intentionally enables skipIdShortCircuit for numeric SQLite IDs, but persisted matching cannot receive it. This new conflicting-ID guard therefore rejects the persisted GUID-backed text after the four-second memory TTL; self-chat dedupe is then bypassed and the agent echo dispatches. Forward the option and add a persisted-cache expiry regression.
  • Redact the conversation identifier before warning (P2) - For DMs, conversationKey contains message.sender, so this newly default-level warning writes the sender identifier to logs. Use an opaque or redacted diagnostic value instead.
  • Resolve security concern: Raw sender identifier in default warning - The warning interpolates the DM conversation key, which is constructed from the inbound sender and can expose a phone number or address in normal logs.
  • Resolve merge risk (P1) - A delayed no-GUID self-chat echo can bypass both cache layers and dispatch back into the agent after the four-second in-memory TTL.
  • Resolve merge risk (P1) - The new default-level limiter warning exposes a DM sender identifier in logs.
  • Complete next step (P2) - This protected maintainer PR needs the two exact-head corrections and a fresh review; current main does not supersede it.
  • Improve patch quality - Carry skipIdShortCircuit through persisted matching and add the delayed no-GUID self-chat regression.
  • Improve patch quality - Redact the new limiter warning's conversation identifier.
  • Improve patch quality - Request one exact-head re-review after pushing the repairs.

Findings

  • [P1] Preserve no-GUID self-chat echo matching — extensions/imessage/src/monitor/persisted-echo-cache.ts:225-237
  • [P2] Redact the conversation identifier before warning — extensions/imessage/src/monitor/monitor-provider.ts:875-880
  • [medium] Raw sender identifier in default warning — extensions/imessage/src/monitor/monitor-provider.ts:878
Agent review details

Security

Needs attention: The new default-level limiter warning records a raw DM sender identifier.

PR surface

Source +34. Total +34 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 3 39 5 +34
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 39 5 +34

Review metrics

Metric Value Why it matters
Production vs test delta production +23/-5 (net +18), tests +16/-0 The production growth is tied to delivery suppression and diagnostics, so the two remaining behavior defects must be resolved before it is justified.

Stored data model

Persistent data-model change detected: serialized state: extensions/imessage/src/monitor/monitor-provider.echo-cache.test-support.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair both exact-head regressions (recommended)
    Forward the self-chat fallback option through persisted matching, cover the post-TTL owner path, and replace the raw conversation identifier with a redacted diagnostic value.
  2. Pause this branch
    Do not merge the delivery and logging changes until the exact-head behavior is repaired and reviewed again.

Technical review

Best possible solution:

Propagate the existing no-GUID self-chat exception through persisted echo matching, add the expiry-boundary regression, and redact the limiter-warning conversation identifier.

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

Yes, source-reproducible: persist a GUID-backed self-chat echo, advance beyond the four-second memory TTL, then process its no-GUID numeric-row reflection; current code dispatches it.

Is this the best way to solve the issue?

No. The conflicting-ID guard is the right owner boundary for normal inbound text, but it must retain the existing no-GUID self-chat exception and avoid adding unredacted default logs.

Full review comments:

  • [P1] Preserve no-GUID self-chat echo matching — extensions/imessage/src/monitor/persisted-echo-cache.ts:225-237
    The self-chat caller intentionally enables skipIdShortCircuit for numeric SQLite IDs, but persisted matching cannot receive it. This new conflicting-ID guard therefore rejects the persisted GUID-backed text after the four-second memory TTL; self-chat dedupe is then bypassed and the agent echo dispatches. Forward the option and add a persisted-cache expiry regression.
    Confidence: 0.99
  • [P2] Redact the conversation identifier before warning — extensions/imessage/src/monitor/monitor-provider.ts:875-880
    For DMs, conversationKey contains message.sender, so this newly default-level warning writes the sender identifier to logs. Use an opaque or redacted diagnostic value instead.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b738e2578087.

Labels

Label changes:

  • add P1: The remaining defect can dispatch a reflected self-chat message into the agent instead of suppressing it.
  • add merge-risk: 🚨 message-delivery: The changed persisted echo guard alters whether delayed self-chat rows are dropped or dispatched.
  • add merge-risk: 🚨 security-boundary: The new default-level warning includes the raw DM sender through the conversation key.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its focused test claim remains supplemental to the required exact-head repair.

Label justifications:

  • P1: The remaining defect can dispatch a reflected self-chat message into the agent instead of suppressing it.
  • merge-risk: 🚨 message-delivery: The changed persisted echo guard alters whether delayed self-chat rows are dropped or dispatched.
  • merge-risk: 🚨 security-boundary: The new default-level warning includes the raw DM sender through the conversation key.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its focused test claim remains supplemental to the required exact-head repair.

Evidence

Security concerns:

  • [medium] Raw sender identifier in default warning — extensions/imessage/src/monitor/monitor-provider.ts:878
    The warning interpolates the DM conversation key, which is constructed from the inbound sender and can expose a phone number or address in normal logs.
    Confidence: 0.99

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the current head and the surrounding iMessage echo-cache and limiter history available in this checkout. (role: feature and recent area contributor; confidence: high; commits: 00a823a6040a, 0ac7b24d56ca, cbe131996918; files: extensions/imessage/src/monitor/persisted-echo-cache.ts, extensions/imessage/src/monitor/echo-cache.ts, extensions/imessage/src/monitor/monitor-provider.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-07T15:29:38.336Z sha 00a823a :: needs changes before merge. :: [P1] Preserve no-GUID self-chat echo matching | [P2] Redact sender data in the new warning

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 7, 2026
@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete merged commit c25671c into main Aug 7, 2026
98 checks passed
@steipete
steipete deleted the steipete/imessage-echo-guards branch August 7, 2026 18:17
@steipete

steipete commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 8, 2026
…ound sends (openclaw#120260)

* fix(imessage): text echo matching honors message-id conflicts; own sends stop feeding the loop limiter

Two silent-drop paths in the iMessage monitor:
1. The persisted 12h echo cache matched inbound user text against old
outbound text even when the GUIDs conflicted — a user sending 'ok' within
12h of the agent sending 'ok' was dropped as an echo. The text branch now
applies the same hasConflictingMessageIds guard the media branch has;
genuine reconnect echoes still match by id or id-less entries.
2. Every from-me row fed the echo loop rate limiter, so a normal outbound
burst (agent replies, multi-chunk sends, operator phone traffic) could trip
the limiter and silently suppress the next legitimate inbound message.
'from me' is no longer counted as a loop signal, and a tripped limiter now
logs a default-level warning once per conversation instead of verbose-only.

* fix(imessage): preserve delayed echo guards
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant