openclaw - 💡(How to fix) Fix [Bug]: Control UI webchat re-sends image messages 4–9× causing 413 overflow and permanent session freeze [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#70959Fetched 2026-04-24 10:37:24
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

When pasting/uploading an image in the Control UI (webchat), the frontend repeatedly re-sends the same message (containing ~2MB base64 image data) 4–9 times. Each duplicate is persisted into the session JSONL, quickly exceeding the provider's request body limit (HTTP 413). Auto-compaction cannot shrink base64 image data, so the session enters a fatal compaction loop and becomes permanently unresponsive.

Error Message

Gateway error log (two separate incidents, same session day):

2026-04-24T12:17:08.578+08:00 [agent/embedded] [context-overflow-diag] sessionKey=agent:main:main messages=68 error=413 Failed to buffer the request body: length limit exceeded 2026-04-24T13:28:54.720+08:00 [agent/embedded] ... messages=17 error=413 Failed to buffer the request body: length limit exceeded 2. Don't retry 413: HTTP 413 is a permanent error — retrying with the same payload will always fail

  • #3477 — Webchat image paste causes sequence gap error (different symptom, possibly related frontend code path)

Root Cause

Two issues combine to create the crash:

Fix Action

Workaround

  • Avoid pasting large images directly in webchat
  • Instead, save images to disk and tell the agent to read them via the read or image tool
  • Or compress images to <500KB before pasting

Code Example

2026-04-24T12:17:08.578+08:00 [agent/embedded] [context-overflow-diag] sessionKey=agent:main:main messages=68 error=413 Failed to buffer the request body: length limit exceeded
2026-04-24T12:17:08.578+08:00 [agent/embedded] context overflow detected (attempt 1/3); attempting auto-compaction
... (attempts 2/3, 3/3 all fail with same 413)
2026-04-24T12:17:24.859+08:00 [agent/embedded] [context-overflow-recovery] Attempting tool result truncation (contextWindow=1000000 tokens)
2026-04-24T12:17:26.311+08:00 ... still 413

---

2026-04-24T13:28:54.720+08:00 [agent/embedded] ... messages=17 error=413 Failed to buffer the request body: length limit exceeded
... (same compaction loop, same outcome)
RAW_BUFFERClick to expand / collapse

Summary

When pasting/uploading an image in the Control UI (webchat), the frontend repeatedly re-sends the same message (containing ~2MB base64 image data) 4–9 times. Each duplicate is persisted into the session JSONL, quickly exceeding the provider's request body limit (HTTP 413). Auto-compaction cannot shrink base64 image data, so the session enters a fatal compaction loop and becomes permanently unresponsive.

Steps to reproduce

  1. Open Control UI webchat (localhost:19000)
  2. Start a conversation (a few exchanges to build some context)
  3. Paste a screenshot (Cmd+V) — typical PNG ~1.5–2MB
  4. Send the message

Expected behavior

  • The image message is sent once
  • Gateway resizes the image if needed and forwards to the model
  • Session continues normally

Actual behavior

  • The webchat frontend sends the same message 4–9 times within seconds (observed timestamps show ~5s intervals)
  • Each message carries the full base64-encoded image (~2.2MB per message in session JSONL)
  • The session file grows to 8–9MB from just one user action
  • Provider returns 413 Failed to buffer the request body: length limit exceeded
  • Gateway attempts auto-compaction 3 times, all fail (base64 data is incompressible)
  • Gateway then attempts tool-result truncation, also fails
  • Session is permanently stuck — no further messages can be processed

Evidence from logs

Gateway error log (two separate incidents, same session day):

Incident 1 — 12:17 (9 duplicates):

2026-04-24T12:17:08.578+08:00 [agent/embedded] [context-overflow-diag] sessionKey=agent:main:main messages=68 error=413 Failed to buffer the request body: length limit exceeded
2026-04-24T12:17:08.578+08:00 [agent/embedded] context overflow detected (attempt 1/3); attempting auto-compaction
... (attempts 2/3, 3/3 all fail with same 413)
2026-04-24T12:17:24.859+08:00 [agent/embedded] [context-overflow-recovery] Attempting tool result truncation (contextWindow=1000000 tokens)
2026-04-24T12:17:26.311+08:00 ... still 413

Incident 2 — 13:28 (4 duplicates, fresh session after /new):

2026-04-24T13:28:54.720+08:00 [agent/embedded] ... messages=17 error=413 Failed to buffer the request body: length limit exceeded
... (same compaction loop, same outcome)

Session JSONL analysis (Incident 2):

LineTimestamp (UTC)TypeSizeContent
L2205:28:54user message + image2,186 KBScreenshot paste
L25compactionAuto-compaction attempt
L2605:29:01user message + image2,186 KBSame message, duplicate #2
L29compactionAuto-compaction attempt
L3005:29:05user message + image2,186 KBSame message, duplicate #3
L33compactionAuto-compaction attempt
L3405:29:10user message + image2,186 KBSame message, duplicate #4
  • Session file total: 8.7MB (70 lines, only 17 messages before the image)
  • Image data per message: 2,238,656 chars base64 (~1,639 KB decoded PNG)

Root cause analysis

Two issues combine to create the crash:

1. Frontend duplicate submission (primary bug)

The webchat frontend re-sends the same image message multiple times. Possible causes:

  • No client-side message deduplication (idempotency key)
  • Retry logic triggered by the backend failing to respond (413 → timeout → retry with same payload)
  • No backoff or max-retry limit for large payloads

2. No server-side dedup or size guard (secondary)

  • Gateway accepts and persists each duplicate into the session JSONL without deduplication
  • No per-message size limit or image pre-processing before session injection
  • Compaction cannot reduce base64 image data, making recovery impossible once oversized

Suggested fixes

  1. Client-side dedup: Assign a unique message ID on send; reject re-sends of the same ID
  2. Don't retry 413: HTTP 413 is a permanent error — retrying with the same payload will always fail
  3. Server-side dedup: Gateway should reject messages with duplicate content/timestamp within a short window
  4. Image size guard: Resize/compress images before injecting base64 into the session (the [agents/tool-images] Image resized pipeline exists but doesn't apply to webchat inbound images)
  5. Compaction awareness: When compaction fails and the oversized content is image data, consider dropping image content blocks from older messages rather than failing the entire session

Environment

  • OpenClaw: 2026.4.22 (00bd2cf)
  • OS: macOS 15.7.6 (Darwin arm64, Apple Silicon)
  • Node.js: v22.17.0
  • Install method: npm (global)
  • Channel/UI: Control UI webchat (localhost)
  • Model: claude-opus-4-6 via IdeaLab proxy
  • Browser: Chrome (Chromium-based)

Workaround

  • Avoid pasting large images directly in webchat
  • Instead, save images to disk and tell the agent to read them via the read or image tool
  • Or compress images to <500KB before pasting

Related issues

  • #3477 — Webchat image paste causes sequence gap error (different symptom, possibly related frontend code path)
  • #49328 — Control UI duplicate messages on AI reply (duplicate direction is reversed but may share retry logic)
  • #53271 — Webchat images not uploaded (opposite problem — images lost vs duplicated)
  • #69448 — Agent runner retries full turns on tool errors (server-side duplication, different layer)

extent analysis

TL;DR

Implement client-side deduplication by assigning a unique message ID to prevent the webchat frontend from re-sending the same image message multiple times.

Guidance

  • Identify and address the retry logic in the frontend that triggers re-sends upon receiving a 413 error, as this error is permanent and retrying with the same payload will always fail.
  • Consider implementing server-side deduplication to reject messages with duplicate content or timestamps within a short window.
  • Explore image size guards, such as resizing or compressing images before injecting them into the session, to prevent oversized content.
  • Review the compaction process to handle image data differently, potentially by dropping image content blocks from older messages when compaction fails.

Example

No specific code example is provided due to the lack of explicit code in the issue description. However, the concept of assigning a unique message ID could be implemented using a UUID library in the frontend code.

Notes

The provided analysis suggests that a combination of client-side and server-side fixes is necessary to fully address the issue. The environment and related issues suggest that this problem may be part of a larger set of issues related to message handling and deduplication in the webchat application.

Recommendation

Apply the suggested fixes, starting with client-side deduplication and adjusting the retry logic to handle 413 errors appropriately, as these changes directly address the primary cause of the issue.

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

  • The image message is sent once
  • Gateway resizes the image if needed and forwards to the model
  • Session continues normally

Still need to ship something?

×6

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

Back to top recommendations

TRENDING