Skip to content

[Bug]: Control UI chat can stay stuck on "Stop" after embedded run timeout on Windows #42011

Closed

Description

@lost-abadan

Bug type

Crash (process/app exits or hangs)

Summary

In Gateway Dashboard / Control UI chat, an embedded run can appear to finish its tool/file work, but the UI remains stuck in a running state:

  • Stop remains visible
  • clicking Stop does nothing
  • gateway health still shows normal
  • the affected chat session never returns to idle

This looks like a missing terminal lifecycle event (end / error) reaching the webchat/control-ui path after timeout/abort

Steps to reproduce

A chat run started normally and performed tool/file operations. The UI showed those operations as completed, but the chat remained stuck in a running state.

Observed behavior:

  • Stop remained visible
  • clicking Stop had no effect
  • gateway health still showed normal
  • the chat content already showed completed tool/edit actions

Observed log entry:

embedded run timeout: runId=<...> sessionId=<...> timeoutMs=600000

There were also timeout-related entries such as LLM request timeouts around the same period.

### Investigation notes

From tracing the bundled code in 2026.3.8, this does not look like a simple frontend-only issue.

What I found:

- Control UI chat finalization appears to depend on lifecycle terminal events (phase === "end" or "error")
- the embedded timeout path appears to call abortRun(true) / activeSession.abort()
- that timeout path does not appear to directly emit a terminal lifecycle event itself
- terminal lifecycle emission seems to depend on the embedded subscription path receiving agent_end
- once agentRunStarted === true in webchat/control-ui, the UI path appears to rely on lifecycle terminal events and does not seem to have a fallback finalization path if those events never arrive

### Current hypothesis

There is an edge case where an embedded run times out or aborts after startup, but no terminal lifecycle event reaches Control UI.

That leaves the webchat/control-ui run stuck in a running state even though the run has already ended internally.

### What this does NOT look like

Based on local tracing, this does not currently look like:

- a simple early-return bug in dispatchInboundMessage()
- a frontend-only rendering issue
- an indefinitely blocked cleanup in flushPendingToolResultsAfterIdle() (that cleanup appears bounded)

### Possible areas to inspect

- embedded timeout/abort path in runEmbeddedAttempt(...) / runEmbeddedPiAgent(...)
- whether activeSession.abort() can bypass agent_end
- whether subscribeEmbeddedPiSession(...) can unsubscribe before terminal lifecycle is emitted
- whether webchat/control-ui should defensively finalize a started run when dispatchInboundMessage() settles but no terminal lifecycle event was observed

### Repro hints

In my case this happened in Gateway Dashboard chat after a long-running embedded run that eventually timed out. The UI had already shown completed tool/edit actions, but the run never left the Stop state.


### Expected behavior

After a timeout or abort, the Control UI should always receive a terminal state and the run should finalize as one of:

- completed
- aborted
- error

The UI should leave the `Stop` state.

### Actual behavior

After timeout:

- the run can stay stuck on `Stop`
- clicking `Stop` may do nothing
- the gateway can remain otherwise healthy
- the specific run/session appears zombied in the UI

### OpenClaw version

2026.3.8

### Operating system

Windows 11

### Install method

npm

### Model

openai-codex/gpt-5.3-codex

### Provider / routing chain

chat

### Config file / key location

_No response_

### Additional provider/model setup details

From tracing the bundled code in 2026.3.8, this does not look like a simple frontend-only issue.

What I found:

- Control UI chat finalization appears to depend on lifecycle terminal events (phase === "end" or "error")
- the embedded timeout path appears to call abortRun(true) / activeSession.abort()
- that timeout path does not appear to directly emit a terminal lifecycle event itself
- terminal lifecycle emission seems to depend on the embedded subscription path receiving agent_end
- once agentRunStarted === true in webchat/control-ui, the UI path appears to rely on lifecycle terminal events and does not seem to have a fallback finalization path if those events never arrive

### Logs, screenshots, and evidence

```shell

Impact and severity

No response

Additional information

Image

Activity

  1. added
    bug
    on Mar 10, 2026
  2. added
    bug:crash
    on Mar 10, 2026
  3. lost-abadan commented on Mar 10, 2026

    @lost-abadan
    Author

    From E:\tmp\openclaw\openclaw-2026-03-10.log:

    • 2026-03-10 16:45:33 +08:00
      gateway/ws responded to node.list in 413ms

    • 2026-03-10 16:45:37 +08:00
      gateway/ws responded to chat.history in 1165ms

    • 2026-03-10 16:45:38 +08:00
      gateway/ws responded to chat.history in 429ms

    • 2026-03-10 16:46:08 +08:00
      gateway/ws responded to node.list in 229ms

    • 2026-03-10 16:46:13 +08:00
      gateway/ws responded to node.list in 391ms

    • 2026-03-10 16:49:58 +08:00
      gateway/ws responded to chat.history in 1044ms

    • 2026-03-10 16:50:56 +08:00
      embedded run timeout: runId=c746332e-7e4d-4904-8d48-9df939abf504 sessionId=d7d69323-7b5b-49db-88fc-0508d407e70d timeoutMs=600000

    • 2026-03-10 17:00:54 +08:00
      RPC probe: ok

  4. openclaw-barnacle commented on Apr 27, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  5. added
    stale
    on Apr 27, 2026
  6. clawsweeper commented on Apr 27, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Close as implemented: current main ships the embedded lifecycle terminal backstop that emits a terminal lifecycle event when an embedded timeout/error turn returns without agent_end, and that fix is included in v2026.4.29 and later releases.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the shipped runner-level lifecycle backstop; handle distinct remaining stuck-chat cases in their narrower tracking items instead of reopening this timeout lifecycle issue.

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

    Yes. The original bug has a high-confidence source-level reproduction: an embedded timeout/error turn can return without agent_end; current regression coverage now simulates that missing-terminal path and verifies the synthesized terminal event.

    Is this the best way to solve the issue?

    Yes. The shipped runner-level backstop is the narrow maintainable solution because it emits one terminal lifecycle event from the owner path and reuses the existing gateway chat finalization contract.

    Security review:

    Security review: No patch is under review for this issue, and the implemented fix is ordinary lifecycle state handling.

    What I checked:

    • Current source implements terminal backstop: createEmbeddedLifecycleTerminalBackstop tracks lifecycle start/end/error and synthesizes a terminal lifecycle event with endedAt, aborted, stopReason, livenessState, and replayInvalid metadata when the embedded runner returns without one. (src/auto-reply/reply/agent-runner-execution.ts:998, e87966434818)
    • Backstop wraps embedded runner return/error exits: The auto-reply embedded runner path creates the backstop, notes every embedded onAgentEvent, emits end after runEmbeddedPiAgent returns, and emits error if the runner throws. (src/auto-reply/reply/agent-runner-execution.ts:1695, e87966434818)
    • Gateway consumes terminal lifecycle into chat finalization: Gateway chat finalization still keys off lifecycle end/error events and emits chat final/error payloads, so the backstop reaches the same Control UI clearing path as a normal agent_end. (src/gateway/server-chat.ts:284, e87966434818)
    • Regression coverage exists: The test suite now covers the missing-terminal case by making runEmbeddedPiAgent emit only lifecycle start and return a timeout/error result, then asserting a synthesized terminal lifecycle event is emitted; adjacent coverage asserts no duplicate when the runner already emitted one. (src/auto-reply/reply/agent-runner-execution.test.ts:1644, e87966434818)
    • Fix provenance: The implementing commit is ebff12e84f32de8fcd454e0833f7016894aaa948, committed 2026-04-29T21:29:07Z with subject fix(agents): finalize embedded lifecycle backstop. (src/auto-reply/reply/agent-runner-execution.ts:998, ebff12e84f32)
    • Release provenance: GitHub compare reports v2026.4.29 is ahead of the fix with merge base equal to ebff12e84f32de8fcd454e0833f7016894aaa948; v2026.5.7 also contains the fix. Release metadata shows v2026.4.29 was published 2026-04-30T21:01:08Z. (ebff12e84f32)

    Likely related people:

    • steipete: Authored the shipped lifecycle backstop fix and closed the closely related session-stuck report with validation details. (role: fix author and recent area contributor; confidence: high; commits: ebff12e84f32; files: src/auto-reply/reply/agent-runner-execution.ts, src/auto-reply/reply/agent-runner-execution.test.ts, CHANGELOG.md)
    • obviyus: Authored adjacent fix(agents): always emit terminal lifecycle events work in the embedded lifecycle handler that owns normal terminal emission. (role: introduced related lifecycle contract behavior; confidence: medium; commits: 2f84e73c18c9; files: src/agents/pi-embedded-subscribe.handlers.lifecycle.ts)
    • amknight: Authored the nearby clear embedded runs before lifecycle end change that added the before-terminal lifecycle hook around this path. (role: recent adjacent lifecycle contributor; confidence: medium; commits: d75725e658f8; files: src/agents/pi-embedded-subscribe.handlers.lifecycle.ts, src/agents/pi-embedded-runner/run/attempt.ts)

    Codex review notes: model gpt-5.5, reasoning high; reviewed against e87966434818; fix evidence: release v2026.4.29, commit ebff12e84f32.

  7. removed
    stale
    on Apr 28, 2026
  8. locked as resolved and limited conversation to collaborators on May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbug:crash

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions