Skip to content

fix(imessage): prevent duplicate messages after delayed sends - #110853

Merged
omarshahine merged 5 commits into
openclaw:mainfrom
omarshahine:agent/imessage-send-timeout
Aug 1, 2026
Merged

omarshahine merged 5 commits into
openclaw:mainfrom
omarshahine:agent/imessage-send-timeout

Conversation

@omarshahine

@omarshahine omarshahine commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where an iMessage send could complete through imsg's AppleScript fallback after a private-bridge stall, while OpenClaw reported a timeout to the calling agent. The agent then retried the apparently failed send, producing duplicate messages.

Why This Change Was Made

The dedicated send timeout is increased from 150 seconds to 180 seconds. This lets the outer RPC outlive imsg's 150-second bridge deadline plus its fallback verification window, while leaving the 10-second probe timeout unchanged.

This is intentionally a boundary fix rather than a second delivery-verification implementation in OpenClaw. In the observed incident, the delivered rows stored their text in attributedBody, so OpenClaw's plain message.text recovery path could not reliably identify them. imsg already owns that verification.

User Impact

Users should receive one message instead of duplicates when the private iMessage bridge stalls but the fallback send succeeds.

Evidence

Redacted live failure timeline before the fix

One cron session issued three sends of the same text to the same chat:

09:00:33  send request 1 started
09:03:14  OpenClaw reported imsg rpc timeout (send); outgoing row 7080 persisted
09:03:19  calling agent retried
09:05:57  OpenClaw reported imsg rpc timeout (send); outgoing row 7081 persisted
09:06:19  calling agent used direct imsg send; outgoing row 7082 persisted

Recipient and message text are omitted. The matching timeout and persistence timestamps show that the first two sends completed at the point the 150-second outer timer rejected them.

Dependency and caller contract

Deterministic delayed-boundary proof

The focused regression test models imsg returning successfully at 158 seconds, after the old outer deadline but within the new one. It asserts that the send resolves with the fallback message GUID and that OpenClaw makes exactly one RPC request.

Test Files  1 passed (1)
Tests       52 passed (52)

Command: pnpm exec vitest run extensions/imessage/src/send.test.ts

Live patched-build proof

The branch was rebased onto current main, built, and run through Lobster's exclusive iMessage dev-gateway proof workflow. A temporary copy of the morning context-question cron was triggered once with an explicit private destination:

status:          ok
duration:        5207 ms
deliveryStatus:  delivered
database rows:   1
row:             7086 at 10:58:38 local time

The recipient, message text, and GUID are omitted. The unique output persisted as exactly one outgoing row. This live run completed through the normal fast bridge path; the 158-second fallback boundary is covered deterministically above because forcing a real bridge stall would require restarting Messages with a stale readiness marker and would introduce an avoidable delivery race.

After proof, the temporary dev cron was removed, the dev gateway stopped, and production was restored healthy on port 18789 with exactly one imsg rpc process.

Additional validation:

  • Full branch build passed on current main.
  • oxfmt --check and git diff --check pass.
  • Final Codex branch autoreview: no findings; patch rated correct with 0.94 confidence.

AI-assisted: diagnosis, implementation, test updates, and independent review were performed with Codex under maintainer supervision.

@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added channel: imessage Channel integration: imessage size: XS maintainer Maintainer-authored PR labels Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 1:22 PM ET / 17:22 UTC.

ClawSweeper review

What this changes

Raises the iMessage outbound RPC timeout floor to 180 seconds and prevents a configured probe timeout from shortening an ordinary send below that floor.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this PR open for the protected maintainer review: current main still applies a short configured probe timeout to outbound sends, while the proposed floor removes the timeout/result ambiguity that can prompt a duplicate retry. The patch is technically sound from the inspected OpenClaw path and the supplied real-process proof, but merging intentionally changes failure latency for installations that configured a value below 180 seconds.

Priority: P1
Reviewed head: a7dce5ad5fbf3d4b1a579b27f534b728219a7cf1
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong real-process boundary proof, a focused owner-boundary repair, and targeted regression coverage support a high-confidence patch, with only an intentional compatibility tradeoff left for maintainer approval.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR includes a redacted live patched-build delivery with one persisted outgoing row and a real-process, real-wall-clock delayed-reply transcript that demonstrates the exact OpenClaw timeout boundary; no private recipient data is exposed.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR includes a redacted live patched-build delivery with one persisted outgoing row and a real-process, real-wall-clock delayed-reply transcript that demonstrates the exact OpenClaw timeout boundary; no private recipient data is exposed.
Evidence reviewed 6 items Current-main timeout path: Current main resolves an outbound send timeout from an explicit call override, then channels.imessage.probeTimeoutMs, then the 150-second send default. A configured 10-second probe timeout therefore causes the send RPC to time out at 10 seconds rather than at the dedicated send timeout.
Probe setting has a separate owner role: The same account setting is used for private-API probing, confirming that it is ordinarily a health/probe control rather than a reliable lower outbound-send deadline.
Patch enforces the intended boundary: The PR changes timeout selection to retain an explicit per-call override but floor account-configured probe values at the new 180-second send timeout; its focused delayed-reply regression test covers a 158-second successful response and one RPC request.
Findings None None.
Security None None.

How this fits together

The bundled iMessage plugin sends outbound messages through the imsg JSON-RPC helper and reports the result back to agent and channel callers. Its chosen RPC timeout also controls how long a pending persisted-echo marker survives, affecting retry behavior and duplicate-message suppression.

flowchart LR
  A[Agent or channel send] --> B[iMessage send path]
  B --> C[Resolve account and timeout]
  C --> D[imsg RPC helper]
  D --> E[Bridge or AppleScript fallback]
  E --> F[Delivery result]
  F --> G[Caller retry decision]
  C --> H[Pending echo lifetime]
Loading

Decision needed

Question Recommendation
Should iMessage configurations with probeTimeoutMs below 180 seconds stop using that value as their outbound-send deadline so successful delayed fallback sends are returned rather than reported as timeouts? Accept the delivery-first timeout floor: Merge the 180-second floor and preserve explicit per-call timeout overrides for exceptional callers that need a shorter send deadline.

Why: This is a deliberate compatibility and operator-latency tradeoff, not a mechanical correctness choice: the fix removes a duplicate-delivery trigger but changes the failure deadline for existing configured installations.

Before merge

  • Resolve merge risk (P1) - Existing installations with channels.imessage.probeTimeoutMs below 180 seconds will no longer use that short value as their outbound-send deadline; a genuinely stuck send can take up to 180 seconds to fail instead of the configured shorter duration.
  • Resolve merge risk (P2) - The pinned imsg deadline/fallback source cited in the PR could not be independently fetched during this review because GitHub DNS resolution failed; the maintainer decision should rely on the already-posted pinned source evidence and real-process delayed-reply proof.
  • Complete next step (P2) - No mechanical repair remains: this protected PR needs a maintainer to accept or reject the existing configured-timeout compatibility tradeoff before merge.
Agent review details

Security

None.

PR surface

Source -2, Tests +29. Total +27 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 10 12 -2
Tests 1 36 7 +29
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 46 19 +27

Review metrics

Metric Value Why it matters
Configured timeout semantics 1 existing setting behavior changed channels.imessage.probeTimeoutMs values below 180 seconds stop shortening outbound sends, which is the compatibility tradeoff maintainers must accept before merge.

Merge-risk options

Maintainer options:

  1. Merge with the delivery-first compatibility tradeoff (recommended)
    Accept the 180-second send floor so a successful delayed helper response is not handed to callers as a timeout that can trigger a duplicate retry.
  2. Pause for a dedicated timeout policy
    Do not merge until maintainers decide whether short configured send deadlines require a distinct documented configuration contract.

Technical review

Best possible solution:

Merge the timeout floor only if maintainers accept delivery certainty over the changed short-timeout behavior for configured installs; retain explicit per-call timeouts as the opt-in route for callers that genuinely need a shorter send deadline.

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

Yes. The supplied current-main real-process helper-boundary transcript reports a 158-second successful reply as an imsg rpc timeout (send) at the 150-second default and at 10 seconds when probeTimeoutMs is configured; current source establishes the same timeout selection.

Is this the best way to solve the issue?

Yes, subject to the stated compatibility decision. Flooring the timeout at the OpenClaw RPC owner boundary is narrower and safer than duplicating imsg delivery verification in OpenClaw, while explicit per-call overrides preserve a deliberate short-timeout escape hatch.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: A successful iMessage send can currently be reported as a timeout, inviting agents to retry and produce duplicate user-visible messages.
  • merge-risk: 🚨 compatibility: Existing installations with a configured probe timeout below 180 seconds receive a longer outbound-send failure deadline after merge.
  • merge-risk: 🚨 message-delivery: The change directly controls whether a delayed successful send is returned as success or as an ambiguous timeout that can lead to a duplicate retry.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR includes a redacted live patched-build delivery with one persisted outgoing row and a real-process, real-wall-clock delayed-reply transcript that demonstrates the exact OpenClaw timeout boundary; no private recipient data is exposed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes a redacted live patched-build delivery with one persisted outgoing row and a real-process, real-wall-clock delayed-reply transcript that demonstrates the exact OpenClaw timeout boundary; no private recipient data is exposed.

Evidence

What I checked:

  • Current-main timeout path: Current main resolves an outbound send timeout from an explicit call override, then channels.imessage.probeTimeoutMs, then the 150-second send default. A configured 10-second probe timeout therefore causes the send RPC to time out at 10 seconds rather than at the dedicated send timeout. (extensions/imessage/src/send.ts:775, 8b994fc9e170)
  • Probe setting has a separate owner role: The same account setting is used for private-API probing, confirming that it is ordinarily a health/probe control rather than a reliable lower outbound-send deadline. (extensions/imessage/src/actions.ts:462, 8b994fc9e170)
  • Patch enforces the intended boundary: The PR changes timeout selection to retain an explicit per-call override but floor account-configured probe values at the new 180-second send timeout; its focused delayed-reply regression test covers a 158-second successful response and one RPC request. (extensions/imessage/src/send.ts:775, a7dce5ad5fbf)
  • Current-head continuity: The latest branch commit is a merge of current main into the already-reviewed PR head, so it adds base synchronization rather than a new implementation approach; the prior review cycle had no remaining code findings. (extensions/imessage/src/send.ts:775, a7dce5ad5fbf)
  • Release and current-main status: The latest shipped release is v2026.7.1 from July 13, 2026; current main at the reviewed checkout still contains the 150-second/default-or-probe selection, so this bug fix is neither merged nor shipped. (extensions/imessage/src/constants.ts:11, 8b994fc9e170)
  • Dependency-contract inspection gap: The PR body links a pinned imsg source revision for the 150-second bridge deadline and fallback verifier, but this review could not independently retrieve that dependency because GitHub DNS resolution failed. The supplied real-process delayed-reply transcript still directly demonstrates the OpenClaw timeout boundary that this diff changes. (a7dce5ad5fbf)

Likely related people:

  • Omar Shahine: Has prior merged iMessage RPC work and the related merged BlueBubbles send-timeout repair, in addition to the proposed boundary fix. (role: prior iMessage and timeout-area contributor; confidence: high; commits: 37aaa5cc2b81, 9434228cdcb8, e89b41fce716; files: extensions/imessage/src/client.ts, extensions/imessage/src/send.ts, extensions/imessage/src/constants.ts)
  • Peter Steinberger: Recent current-main work changed the iMessage send path, and earlier iMessage refactors establish adjacent ownership of this extension surface. (role: recent iMessage area contributor; confidence: medium; commits: ed5d046a5861, 834810b3d6e3; files: extensions/imessage/src/send.ts, extensions/imessage/src/constants.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 (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-18T18:06:52.324Z sha fce7399 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T18:36:21.685Z sha fce7399 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T19:05:07.812Z sha fce7399 :: needs real behavior proof before merge. :: [P1] Guarantee the configured send timeout floor
  • reviewed 2026-07-18T19:20:58.413Z sha 256d9c3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T20:10:43.420Z sha 256d9c3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T22:52:34.935Z sha 256d9c3 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-31T08:04:31.532Z sha 256d9c3 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T17:10:47.913Z sha e8405e5 :: needs maintainer review before merge. :: none

@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@omarshahine
omarshahine force-pushed the agent/imessage-send-timeout branch from bfc7851 to fce7399 Compare July 18, 2026 18:02
@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@omarshahine omarshahine self-assigned this Jul 18, 2026
@omarshahine
omarshahine marked this pull request as ready for review July 18, 2026 18:33

@Yigtwxx Yigtwxx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 150 → 180 bump reads correct to me, and I checked the new test is load-bearing rather than just asserting the literal: on revert to 150_000 the mock's reject timer fires at 150s before the 158s resolve, and since "hello" carries no approval binding, shouldRecoverApprovalPromptGuid is false and the error rethrows — so it fails on behavior. Two notes on the comment rewrite.

Also verified as non-issues while I was in here, in case it saves you the check: the echo-dedup store is bounded and pruned (IMESSAGE_SENT_ECHOES_MAX_ENTRIES = 256 plus a 12h TTL with isLiveEntry filtering on every read/write), so the indirect 155s → 185s TTL bump via resolvePendingPersistedEchoTtlMs doesn't grow anything unboundedly; and the failure path still calls forgetPersistedIMessageEchoKey, so a timed-out send won't leave a stale pending echo suppressing a real inbound.

Comment thread extensions/imessage/src/constants.ts Resolved
// back to AppleScript and spend up to 8s verifying the persisted row. The outer
// RPC timeout must outlive both stages; matching imsg's 150s deadline turns a
// successful fallback into an ambiguous timeout that callers may retry.
export const DEFAULT_IMESSAGE_SEND_TIMEOUT_MS = 180_000;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rewrite drops two facts the old comment was carrying: the observed ~124s macOS 26 stall upper bound, and the #69193 BlueBubbles cross-reference. The new text only justifies why 180 > 150, so a future reader could reasonably conclude "imsg's deadline is 150s plus an 8s verify, 160s is plenty" and ratchet it back below the stall headroom this constant originally existed for.

It has now been tuned twice; one clause preserving the observed stall bound would keep both reasons visible to whoever tunes it third.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open as of 256d9c3 — the constant's comment carries the two-stage 150s + 8s derivation, but not the ~124s observed stall bound or the #69193 cross-reference that the 150s number originally came from. Not a blocker, and it may well be deliberate now that the deadline is derived from imsg's contract rather than from the stall measurement. Flagging only because the floor added in 256d9c3 gives the value a second reason to exist, and neither reason is written down next to it.

@omarshahine

Copy link
Copy Markdown
Contributor Author

Maintainer proof decision: I accept ClawSweeper option 2, the bounded dependency-contract risk, for this PR. The production incident establishes the 150-second collision, direct imsg source establishes the 150-second bridge deadline plus verifier window, and the deterministic 158-second regression proves the OpenClaw-owned boundary. I am deliberately not forcing a live Messages stall because that fault injection can create real duplicate deliveries. The additional 30-second failure latency is an accepted delivery-versus-latency tradeoff.

@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 18, 2026
@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@omarshahine

Copy link
Copy Markdown
Contributor Author

@clawsweeper approve

@clawsweeper

clawsweeper Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@Yigtwxx

Yigtwxx commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@omarshahine The review's remaining blocker assumes the delayed-fallback path can only be proven with fake timers, because forcing a real bridge stall risks duplicate delivery. That assumption doesn't hold here: IMessageRpcClient spawns imsg as a child process and speaks line-delimited JSON-RPC over its stdio pipes, so the stall can be injected at the helper boundary — real process, real pipes, real wall clock, and no contact with iMessage at all, so there is no delivery to duplicate.

I ran it against your head and the pre-PR base. The only stand-in is the imsg binary itself; sendMessageIMessage, IMessageRpcClient, the timeout selection, and the timers are all the real ones.

Helper holds the send reply for 158s (inside imsg's 150s bridge deadline + AppleScript fallback + persistence verification window):

scenario base c2431dfcd25 head 256d9c3
probeTimeoutMs: 10_000 configured rejected @ 10.0s — imsg rpc timeout (send) resolved @ 158.0s — p:0/imsg-delayed-fallback
no probeTimeoutMs (default floor) rejected @ 150.0s — imsg rpc timeout (send) resolved @ 158.1s — p:0/imsg-delayed-fallback

The second row is the PR's actual thesis measured end to end: on base, a fallback that succeeds at 158s is reported to the caller as a timeout at exactly 150.0s — the ambiguous outcome that invites the retry. On head the same successful fallback is returned as a success. The first row is the Math.max precedence fix: a configured probe timeout no longer shortens the send below the floor.

Scope, to be explicit about what this does and does not show: the helper models imsg's timing contract (a late reply), not macOS's private-bridge internals. It proves the OpenClaw-side deadline arithmetic and RPC plumbing behave as claimed across the boundary at real time — which is the part this diff changes. Whether ~124s/150s is the right characterization of the bridge stall still rests on your incident data.

Harness (two files, both dropped after the run)

rpc — stand-in helper. The client appends ["rpc", "--json"] to cliPath, so pointing cliPath at the node binary runs this file with the same argv shape as real imsg:

import { createInterface } from "node:readline";

const delayMs = Number(process.env.IMSG_PROOF_DELAY_MS ?? "158000");
const guid = process.env.IMSG_PROOF_GUID ?? "p:0/imsg-delayed-fallback";
const reply = (payload) => process.stdout.write(`${JSON.stringify(payload)}\n`);

createInterface({ input: process.stdin }).on("line", (line) => {
  const trimmed = line.trim();
  if (!trimmed) return;
  const req = JSON.parse(trimmed);
  if (req.method !== "send") {
    reply({ jsonrpc: "2.0", id: req.id, result: {} });
    return;
  }
  // Models the private-bridge stall: the send does succeed, just late.
  setTimeout(() => reply({ jsonrpc: "2.0", id: req.id, result: { guid } }), delayMs);
});

imessage-delayed-fallback.proof.mts — driver:

import { IMessageRpcClient } from "./extensions/imessage/src/client.js";
import { sendMessageIMessage } from "./extensions/imessage/src/send.js";

const delayMs = Number(process.env.IMSG_PROOF_DELAY_MS ?? "158000");
const probeTimeoutMs = process.env.IMSG_PROOF_PROBE_TIMEOUT_MS
  ? Number(process.env.IMSG_PROOF_PROBE_TIMEOUT_MS)
  : undefined;

const cfg = {
  channels: {
    imessage: {
      accounts: { default: probeTimeoutMs === undefined ? {} : { probeTimeoutMs } },
    },
  },
};

const client = new IMessageRpcClient({ cliPath: process.execPath });
await client.start();

const started = Date.now();
const elapsed = () => `${((Date.now() - started) / 1000).toFixed(1)}s`;

try {
  const result = await sendMessageIMessage("chat_id:42", "delayed fallback proof", {
    config: cfg as never,
    client,
  });
  console.log(`[harness] RESOLVED after ${elapsed()} messageId=${result.messageId}`);
} catch (error) {
  console.log(`[harness] REJECTED after ${elapsed()} error=${String(error)}`);
} finally {
  await client.stop();
}

Run:

IMSG_PROOF_DELAY_MS=158000 IMSG_PROOF_PROBE_TIMEOUT_MS=10000 ./node_modules/.bin/tsx imessage-delayed-fallback.proof.mts
IMSG_PROOF_DELAY_MS=158000 ./node_modules/.bin/tsx imessage-delayed-fallback.proof.mts

Transcript:

=== TRUE BASE (pre-PR main, 150s default) c2431dfcd25 ===
[harness] probeTimeoutMs=10000 helper replies after 158000ms
[harness] REJECTED after 10.0s error=Error: imsg rpc timeout (send)
[harness] probeTimeoutMs=(unset) helper replies after 158000ms
[harness] REJECTED after 150.0s error=Error: imsg rpc timeout (send)

=== PR HEAD 256d9c3c7a6 ===
[harness] probeTimeoutMs=10000 helper replies after 158000ms
[harness] RESOLVED after 158.0s messageId=p:0/imsg-delayed-fallback
[harness] probeTimeoutMs=(unset) helper replies after 158000ms
[harness] RESOLVED after 158.1s messageId=p:0/imsg-delayed-fallback

Note: IMessageRpcClient.start() refuses to run under NODE_ENV=test/VITEST, so this has to run outside vitest — which is also why it can't be landed as a unit test.

Happy to turn this into a committable test-support helper if you'd rather have it in the tree than in a comment.

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 31, 2026
@Yigtwxx

Yigtwxx commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@omarshahine The one rank-up item still standing is "rebase onto current main and rerun the delayed-reply terminal proof on the resulting head". I ran that for you, since I still had the helper-boundary harness from the earlier run.

Merge is clean, and the drift under the patch is real but unrelated. Merging current main (5fc976571e5) into 256d9c3 produces no conflicts. Since the merge base (c2431dfcd25) main landed 5 commits across the three touched files — send.ts moved ±91 lines (media placeholder facts, resultChatGuidService, outbound markdown ranges) and send.test.ts ±45 — but none of them touch the deadline resolution, which is still the single expression at send.ts:726.

Unit suite on the merged tree: extensions/imessage/src/send.test.ts → 51 passed, 2 failed. Both failures are uses the default local chat.db path for …, and the control case says they aren't yours: the same two fail identically on plain origin/main in this environment, because they assert a POSIX /Users/me/Library/Messages/chat.db against a path this host joins with \. Your new floors a configured probe timeout so one delayed imsg fallback can resolve passes on the merged tree.

Delayed-fallback proof, rerun on the merged head. Same setup as before: real IMessageRpcClient, real child process, real stdio pipes, real wall clock; the only stand-in is the imsg binary, which speaks line-delimited JSON-RPC and holds the send reply for 158s — inside imsg's 150s bridge deadline plus its AppleScript fallback and persistence-verification window. Nothing touches Messages, so there is no delivery to duplicate.

scenario merged head (256d9c3 + 5fc976571e5) current main
default, no probeTimeoutMs resolved @ 158.1s — p:0/imsg-delayed-fallback rejected @ 150.0s — imsg rpc timeout (send)
probeTimeoutMs: 10_000 configured resolved @ 158.1s — p:0/imsg-delayed-fallback rejected @ 10.0s — imsg rpc timeout (send)

The right-hand column is the control, and it is the current shipping behavior measured through the same harness, not the pre-PR base I measured on July 18 — so the 13 days of drift changed neither the failure nor the fix. Row one is the PR's thesis end to end: a fallback that succeeds at 158s is still handed to the caller as a timeout at exactly 150.0s, which is the ambiguity that invites the retry. Row two is the Math.max floor, which is what makes the fix reach installs that tuned probeTimeoutMs down.

@omarshahine
omarshahine merged commit b67fa6a into openclaw:main Aug 1, 2026
94 checks passed
@omarshahine

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@omarshahine
omarshahine deleted the agent/imessage-send-timeout branch August 1, 2026 17:51
vincentkoc added a commit that referenced this pull request Aug 1, 2026
* origin/main: (26 commits)
  fix(update): return failure when dirty checkout blocks update (#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (#117542)
  refactor(ui): unify channel status and setup controls (#117499)
  fix(doctor): preserve surviving lint selections (#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464)
  refactor(channels): consolidate lightweight plugin discovery (#117541)
  fix(imessage): prevent duplicate messages after delayed sends (#110853)
  refactor(memory): unify authoritative dreaming state and presentation (#117538)
  refactor(agents): consolidate main-session recovery ownership (#117383)
  fix(proxy-capture): make path-based session cleanup atomic (#98852)
  refactor(agents): consolidate compaction and context-engine ownership (#117482)
  fix(gateway): preserve Responses usage details (#117533)
  perf(gateway): skip empty session recovery stores (#117498)
  fix(ci): update canonical Kova performance pin (#117508)
  fix(system-agent): emit the wizard cancel hint once per message (#113731)
  refactor: dedupe secrets runtime snapshot fixtures (#117502)
  test(google): cover ready callback close precedence
  test(openai): dedupe realtime voice fixtures (#117503)
  fix(google): flush lazy prompts on provider readiness
  fix(gateway): keep canonical hooks on pristine startup path (#117493)
  ...
abdulrahman305 pushed a commit to qenex-ai/openclaw that referenced this pull request Aug 1, 2026
* origin/main: (35 commits)
  fix(update): return failure when dirty checkout blocks update (openclaw#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542)
  refactor(ui): unify channel status and setup controls (openclaw#117499)
  fix(doctor): preserve surviving lint selections (openclaw#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464)
  refactor(channels): consolidate lightweight plugin discovery (openclaw#117541)
  fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853)
  refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538)
  refactor(agents): consolidate main-session recovery ownership (openclaw#117383)
  fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852)
  refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482)
  fix(gateway): preserve Responses usage details (openclaw#117533)
  perf(gateway): skip empty session recovery stores (openclaw#117498)
  fix(ci): update canonical Kova performance pin (openclaw#117508)
  fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731)
  refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502)
  test(google): cover ready callback close precedence
  test(openai): dedupe realtime voice fixtures (openclaw#117503)
  fix(google): flush lazy prompts on provider readiness
  fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493)
  ...
vincentkoc added a commit that referenced this pull request Aug 1, 2026
* origin/main: (491 commits)
  feat(gateway): advertise chat attachment limits on hello-ok (#116188)
  fix(ui): preserve full graphemes in session owner initials (#117350)
  refactor(tui): consolidate runtime ownership (#117368)
  fix(update): return failure when dirty checkout blocks update (#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (#117542)
  refactor(ui): unify channel status and setup controls (#117499)
  fix(doctor): preserve surviving lint selections (#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464)
  refactor(channels): consolidate lightweight plugin discovery (#117541)
  fix(imessage): prevent duplicate messages after delayed sends (#110853)
  refactor(memory): unify authoritative dreaming state and presentation (#117538)
  refactor(agents): consolidate main-session recovery ownership (#117383)
  fix(proxy-capture): make path-based session cleanup atomic (#98852)
  refactor(agents): consolidate compaction and context-engine ownership (#117482)
  fix(gateway): preserve Responses usage details (#117533)
  perf(gateway): skip empty session recovery stores (#117498)
  fix(ci): update canonical Kova performance pin (#117508)
  fix(system-agent): emit the wizard cancel hint once per message (#113731)
  refactor: dedupe secrets runtime snapshot fixtures (#117502)
  test(google): cover ready callback close precedence
  ...
vincentkoc added a commit that referenced this pull request Aug 1, 2026
* origin/main: (325 commits)
  fix(skills): preserve profile in ClawHub command hints (#117555)
  fix(cli): explain filtered plugin policy without unsafe recovery (#117556)
  fix(irc): strip markdown from outbound text (#112961)
  refactor(plugins): consolidate registry snapshots (#117561)
  fix(plugins): fail blocked enable commands (#117536)
  test(secrets): dedupe runtime state fixtures (#117563)
  feat(gateway): advertise chat attachment limits on hello-ok (#116188)
  fix(ui): preserve full graphemes in session owner initials (#117350)
  refactor(tui): consolidate runtime ownership (#117368)
  fix(update): return failure when dirty checkout blocks update (#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (#117542)
  refactor(ui): unify channel status and setup controls (#117499)
  fix(doctor): preserve surviving lint selections (#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464)
  refactor(channels): consolidate lightweight plugin discovery (#117541)
  fix(imessage): prevent duplicate messages after delayed sends (#110853)
  refactor(memory): unify authoritative dreaming state and presentation (#117538)
  refactor(agents): consolidate main-session recovery ownership (#117383)
  fix(proxy-capture): make path-based session cleanup atomic (#98852)
  refactor(agents): consolidate compaction and context-engine ownership (#117482)
  ...

# Conflicts:
#	extensions/xai/realtime-voice-bridge.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
…aw#110853)

* fix(imessage): outlive imsg send fallback

* test(imessage): prove delayed fallback resolves once

* fix(imessage): preserve the send timeout floor

---------

Co-authored-by: Omar Shahine <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main: (26 commits)
  fix(update): return failure when dirty checkout blocks update (openclaw#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542)
  refactor(ui): unify channel status and setup controls (openclaw#117499)
  fix(doctor): preserve surviving lint selections (openclaw#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464)
  refactor(channels): consolidate lightweight plugin discovery (openclaw#117541)
  fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853)
  refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538)
  refactor(agents): consolidate main-session recovery ownership (openclaw#117383)
  fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852)
  refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482)
  fix(gateway): preserve Responses usage details (openclaw#117533)
  perf(gateway): skip empty session recovery stores (openclaw#117498)
  fix(ci): update canonical Kova performance pin (openclaw#117508)
  fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731)
  refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502)
  test(google): cover ready callback close precedence
  test(openai): dedupe realtime voice fixtures (openclaw#117503)
  fix(google): flush lazy prompts on provider readiness
  fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main: (35 commits)
  fix(update): return failure when dirty checkout blocks update (openclaw#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542)
  refactor(ui): unify channel status and setup controls (openclaw#117499)
  fix(doctor): preserve surviving lint selections (openclaw#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464)
  refactor(channels): consolidate lightweight plugin discovery (openclaw#117541)
  fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853)
  refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538)
  refactor(agents): consolidate main-session recovery ownership (openclaw#117383)
  fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852)
  refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482)
  fix(gateway): preserve Responses usage details (openclaw#117533)
  perf(gateway): skip empty session recovery stores (openclaw#117498)
  fix(ci): update canonical Kova performance pin (openclaw#117508)
  fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731)
  refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502)
  test(google): cover ready callback close precedence
  test(openai): dedupe realtime voice fixtures (openclaw#117503)
  fix(google): flush lazy prompts on provider readiness
  fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main: (491 commits)
  feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188)
  fix(ui): preserve full graphemes in session owner initials (openclaw#117350)
  refactor(tui): consolidate runtime ownership (openclaw#117368)
  fix(update): return failure when dirty checkout blocks update (openclaw#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542)
  refactor(ui): unify channel status and setup controls (openclaw#117499)
  fix(doctor): preserve surviving lint selections (openclaw#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464)
  refactor(channels): consolidate lightweight plugin discovery (openclaw#117541)
  fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853)
  refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538)
  refactor(agents): consolidate main-session recovery ownership (openclaw#117383)
  fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852)
  refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482)
  fix(gateway): preserve Responses usage details (openclaw#117533)
  perf(gateway): skip empty session recovery stores (openclaw#117498)
  fix(ci): update canonical Kova performance pin (openclaw#117508)
  fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731)
  refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502)
  test(google): cover ready callback close precedence
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* origin/main: (325 commits)
  fix(skills): preserve profile in ClawHub command hints (openclaw#117555)
  fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556)
  fix(irc): strip markdown from outbound text (openclaw#112961)
  refactor(plugins): consolidate registry snapshots (openclaw#117561)
  fix(plugins): fail blocked enable commands (openclaw#117536)
  test(secrets): dedupe runtime state fixtures (openclaw#117563)
  feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188)
  fix(ui): preserve full graphemes in session owner initials (openclaw#117350)
  refactor(tui): consolidate runtime ownership (openclaw#117368)
  fix(update): return failure when dirty checkout blocks update (openclaw#117452)
  fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542)
  refactor(ui): unify channel status and setup controls (openclaw#117499)
  fix(doctor): preserve surviving lint selections (openclaw#117543)
  fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464)
  refactor(channels): consolidate lightweight plugin discovery (openclaw#117541)
  fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853)
  refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538)
  refactor(agents): consolidate main-session recovery ownership (openclaw#117383)
  fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852)
  refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482)
  ...

# Conflicts:
#	extensions/xai/realtime-voice-bridge.ts
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants