openclaw - 💡(How to fix) Fix Webchat long-running task completions often don't surface until refresh; embedded agent WS stream falls back with HTTP 500 [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#58569Fetched 2026-04-08 02:00:56
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

In OpenClaw 2026.3.28, long-running subagent / embedded-agent task completions are successfully persisted server-side, but the webchat UI often does not surface the completion live. Refreshing the webchat immediately causes the completed result to appear, suggesting backend persistence is fine but live event delivery or frontend subscription/reconciliation is broken.

The strongest correlated backend signal is repeated embedded agent websocket stream failures:

  • agent/embedded [ws-stream] WebSocket connect failed ... falling back to HTTP
  • Error: Unexpected server response: 500

At the same time, webchat disconnect/reconnect events occur, and on reconnect the UI issues chat.history, after which the missing completion becomes visible.

Error Message

When launching a long-running task from webchat:

  1. task runs successfully
  2. backend stores completion
  3. webchat often appears stale / “stuck”
  4. no live completion appears in the chat window
  5. refresh or reconnect causes chat.history
  6. completion becomes visible immediately

Root Cause

Likely root cause

Most likely there are two related issues:

Fix Action

Fix / Workaround

Practical workaround

Current workaround:

  • refresh/reopen the webchat when a long-running task appears stuck
  • completion often appears immediately after chat.history reloads

Code Example

warn agent/embedded [ws-stream] WebSocket connect failed for session=...; falling back to HTTP. error=Error: Unexpected server response: 500

---

info gateway/ws webchat disconnected code=1001
info gateway/ws webchat connected ...
info gateway/ws ⇄ res ✓ chat.history ...
RAW_BUFFERClick to expand / collapse

Summary

In OpenClaw 2026.3.28, long-running subagent / embedded-agent task completions are successfully persisted server-side, but the webchat UI often does not surface the completion live. Refreshing the webchat immediately causes the completed result to appear, suggesting backend persistence is fine but live event delivery or frontend subscription/reconciliation is broken.

The strongest correlated backend signal is repeated embedded agent websocket stream failures:

  • agent/embedded [ws-stream] WebSocket connect failed ... falling back to HTTP
  • Error: Unexpected server response: 500

At the same time, webchat disconnect/reconnect events occur, and on reconnect the UI issues chat.history, after which the missing completion becomes visible.

Version / Environment

  • OpenClaw version: 2026.3.28
  • Commit: f9b1079283a8ee25a7cee77c8f8225d5c813bc30
  • Surface: local webchat / control UI
  • Gateway mode: local loopback
  • Gateway port: 18789

Observed behavior

When launching a long-running task from webchat:

  1. task runs successfully
  2. backend stores completion
  3. webchat often appears stale / “stuck”
  4. no live completion appears in the chat window
  5. refresh or reconnect causes chat.history
  6. completion becomes visible immediately

This creates the impression that the task is still running even though it already finished.

Expected behavior

When a long-running task completes:

  • webchat should surface the completion live without requiring a manual refresh
  • if WS streaming is degraded, frontend should reconcile automatically through fallback history/session refresh

Key log evidence

Observed repeatedly in gateway logs:

warn agent/embedded [ws-stream] WebSocket connect failed for session=...; falling back to HTTP. error=Error: Unexpected server response: 500

Also observed:

info gateway/ws webchat disconnected code=1001
info gateway/ws webchat connected ...
info gateway/ws ⇄ res ✓ chat.history ...

This pattern matches the user-facing symptom exactly:

  • result exists
  • live surfacing fails
  • refresh/reconnect reloads history and reveals completion

Why this appears to be a live delivery / UI issue rather than task failure

  • task completions are successfully persisted
  • agent.wait completes successfully
  • refresh recovers the “missing” completion
  • therefore backend execution is not the primary failure
  • the likely failure is:
    • embedded-agent websocket stream path
    • frontend live subscription/reconciliation
    • or both

Likely root cause

Most likely there are two related issues:

1. Embedded agent websocket stream upgrade failure

The embedded agent WS stream appears to be attempting a websocket connection and receiving HTTP 500 instead of a valid upgrade.

2. Webchat fallback / resubscribe weakness

When WS streaming fails or the chat reconnects, the webchat UI does not robustly reconcile long-running task completion state unless a full refresh/reconnect triggers chat.history.

Suggested areas to inspect

Backend

  • embedded agent websocket route / upgrade handler
  • why the route returns HTTP 500 on stream connect
  • whether fallback-to-HTTP mode still emits completion events that webchat is expected to consume

Frontend / control UI

  • live stream client for embedded/subagent events
  • reconnection behavior after WS degradation
  • whether webchat should trigger history/session refresh automatically after:
    • stream failure
    • agent.wait completion
    • reconnect after disconnect

Suggested fixes

Backend

  • fix embedded-agent WS stream upgrade path so it does not 500
  • improve logging to identify exact route / cause of failure

Frontend

  • if stream degrades/fails, automatically reconcile via:
    • session refresh
    • chat history refresh
    • or lightweight polling while a run is active
  • improve resubscription after reconnect
  • optionally surface a “live updates degraded” banner instead of appearing stuck

Practical workaround

Current workaround:

  • refresh/reopen the webchat when a long-running task appears stuck
  • completion often appears immediately after chat.history reloads

Repro steps

  1. Open local OpenClaw webchat/control UI
  2. Launch a long-running subagent or other embedded-agent task
  3. Leave the chat open while the task runs
  4. Observe task completion may not appear live
  5. Refresh the page
  6. Observe the completion appears immediately
  7. Check gateway logs for:
    • ws-stream ... Unexpected server response: 500
    • webchat disconnect/reconnect
    • chat.history immediately after reconnect

extent analysis

TL;DR

The most likely fix involves addressing the embedded agent websocket stream upgrade failure and improving the webchat fallback and resubscribe mechanisms to robustly reconcile long-running task completion state.

Guidance

  • Investigate the embedded agent websocket route and upgrade handler to determine why it returns an HTTP 500 error on stream connect, and fix this issue to prevent fallback to HTTP.
  • Enhance the webchat UI to automatically trigger a history or session refresh after stream failure or reconnect, ensuring that long-running task completions are surfaced live without requiring a manual refresh.
  • Improve logging on the backend to identify the exact route and cause of the websocket stream upgrade failure.
  • Consider implementing a "live updates degraded" banner in the webchat UI to indicate when live updates are not functioning correctly.

Example

No specific code example is provided due to the lack of detailed implementation details in the issue description. However, the fix would likely involve modifying the websocket connection handling in the embedded agent and the webchat UI's reconciliation logic.

Notes

The suggested fixes and workarounds assume that the issue is primarily related to the websocket stream upgrade failure and the webchat UI's handling of stream failures and reconnects. Further investigation may be necessary to confirm these assumptions and identify any additional contributing factors.

Recommendation

Apply a workaround by automatically reconciling long-running task completion state via session refresh or chat history refresh when the websocket stream degrades or fails, and improve the resubscription behavior after reconnect. This should help mitigate the issue until a more permanent fix can be implemented.

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

When a long-running task completes:

  • webchat should surface the completion live without requiring a manual refresh
  • if WS streaming is degraded, frontend should reconcile automatically through fallback history/session refresh

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 Webchat long-running task completions often don't surface until refresh; embedded agent WS stream falls back with HTTP 500 [1 participants]