openclaw - 💡(How to fix) Fix Control UI sends duplicate chat.send requests causing double messages [2 comments, 2 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#72974Fetched 2026-04-28 06:29:13
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Timeline (top)
commented ×2cross-referenced ×1

Root Cause

Root Cause Analysis (from Control UI source code)

Fix Action

Fix / Workaround

Workarounds Attempted

Code Example

# Only 1 Chrome/Firefox connection to Gateway - NOT a double-connection issue
ss -tnp | grep 18789
ESTAB 0  0  127.0.0.1:54744  127.0.0.1:18789  users:(("firefox",pid=4548,fd=20))
ESTAB 0  0  127.0.0.1:18789  127.0.0.1:54744  users:(("openclaw-gatewa",pid=1499,fd=27))

---

seq 639: role=user, "我换了浏览器..." (first)
seq 643: role=user, "我换了浏览器..." (duplicate - same timestamp!)

---

async function Sc(e, t) {
  await e.client.request(`chat.send`, {
    sessionKey: e.sessionKey,
    message: t.message,
    deliver: false,
    idempotencyKey: t.runId,
    attachments: xc(t.attachments)
  })
}
RAW_BUFFERClick to expand / collapse

Bug Description

Control UI sends duplicate chat.send WebSocket requests, causing every user message to appear twice in the session history, resulting in duplicate AI responses.

Steps to Reproduce

  1. Open Control UI in browser: http://localhost:18789/
  2. Send any message (e.g., "你好")
  3. Observe: message appears once in my session history (confirmed via sessions_history API)
  4. But the AI receives and processes the message twice, causing duplicate replies
  5. User sees their question appear twice, followed by two identical AI responses

Environment

  • Gateway: OpenClaw Gateway v2026.4.15
  • OS: Ubuntu 24.04.1 LTS (Linux 6.17.0-22-generic)
  • Node: v22.22.2
  • Browser: Chrome and Firefox both affected (1 WebSocket connection only)
  • Gateway Port: 18789 (loopback)
  • Token: Bearer token auth

Network Investigation

# Only 1 Chrome/Firefox connection to Gateway - NOT a double-connection issue
ss -tnp | grep 18789
ESTAB 0  0  127.0.0.1:54744  127.0.0.1:18789  users:(("firefox",pid=4548,fd=20))
ESTAB 0  0  127.0.0.1:18789  127.0.0.1:54744  users:(("openclaw-gatewa",pid=1499,fd=27))

Only 1 Gateway process running (pid=1499). Not a process duplication issue.

Session History Evidence

Using sessions_history API confirms messages ARE stored twice:

seq 639: role=user, "我换了浏览器..." (first)
seq 643: role=user, "我换了浏览器..." (duplicate - same timestamp!)

Both messages have identical timestamp and identical __openclaw.id, proving they came from the same original send that was duplicated at the WebSocket layer.

Root Cause Analysis (from Control UI source code)

File: dist/control-ui/assets/index-ckUmEo1l.js

The Sc function is called with identical parameters twice:

async function Sc(e, t) {
  await e.client.request(`chat.send`, {
    sessionKey: e.sessionKey,
    message: t.message,
    deliver: false,
    idempotencyKey: t.runId,
    attachments: xc(t.attachments)
  })
}

Three functions call Sc: Ec, Dc, Oc - one of these is being invoked twice for each send action. The idempotencyKey (runId) is generated via pn() and should be unique per send, but since the request itself is sent twice, the idempotency mechanism does not prevent the duplication.

Impact

  • Every message sent via Control UI results in duplicate AI response
  • Double token usage / API costs
  • Confusing user experience
  • Affects BOTH Chrome and Firefox (not browser-specific)

Workarounds Attempted

  1. Restart Chrome/Firefox - issue persists
  2. Restart Gateway - issue persists
  3. Single tab only - confirmed 1 WebSocket connection, issue persists
  4. Canvas mode - may work but not fully tested

Suggested Fix

The Control UI's send handler invokes Sc() twice for each message send. Investigate which of Ec/Dc/Oc is being called twice, and add a guard to prevent duplicate sends.

extent analysis

TL;DR

The most likely fix is to add a guard in the Control UI's send handler to prevent duplicate invocations of the Sc() function.

Guidance

  • Investigate the Ec, Dc, and Oc functions to determine which one is being called twice, causing the duplicate Sc() invocations.
  • Add a unique identifier or a flag to track whether the Sc() function has already been called for a given message, and skip the second invocation if it has.
  • Verify that the idempotencyKey (runId) is being generated correctly and uniquely for each message send.
  • Test the fix by sending messages via Control UI and verifying that the messages are no longer duplicated in the session history.

Example

let scInvoked = false;
async function Sc(e, t) {
  if (scInvoked) return;
  scInvoked = true;
  await e.client.request(`chat.send`, {
    sessionKey: e.sessionKey,
    message: t.message,
    deliver: false,
    idempotencyKey: t.runId,
    attachments: xc(t.attachments)
  })
}

Note: This example is a simplified illustration and may need to be adapted to the actual implementation.

Notes

The fix may require modifying the Control UI's source code, specifically the Ec, Dc, and Oc functions. It is essential to thoroughly test the fix to ensure that it resolves the issue without introducing new problems.

Recommendation

Apply the workaround by adding a guard to prevent duplicate Sc() invocations, as this is the most direct and effective solution to the problem.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Control UI sends duplicate chat.send requests causing double messages [2 comments, 2 participants]