Skip to content

[Bug]: Queued/orphaned user-message merge can produce stale reply #76888

@hoyanhan

Description

@hoyanhan

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

A queued/merged user message run used the latest prompt text, but the model answered an earlier unresolved user turn from the same session, producing a stale visible reply.

Steps to reproduce

  1. In a channel-backed session, send a short user message that can be answered immediately.
  2. Before/while a later longer task is active and a subagent/internal announcement is queued, send a new user instruction.
  3. Observe a gateway log line indicating an orphaned user message was merged to prevent consecutive user turns.
  4. Inspect the trajectory for the new run: the final prompt is the latest user instruction, but the assistant output answers the earlier unresolved user message.

Expected behavior

The assistant should answer the latest triggering user instruction for the run. If session repair/merge removes an orphaned user message, earlier unresolved user turns should not remain capable of steering the next model response over the latest prompt.

Actual behavior

The trajectory for the affected run showed the final prompt was the latest instruction, but the assistant output answered an earlier user message. The message snapshot still contained the older user turn before the latest instruction, and the gateway logged an orphaned user-message merge immediately before the run.

OpenClaw version

OpenClaw 2026.5.2 (8b2a6e5)

Operating system

Ubuntu 24.04, Linux 6.17.0-23-generic x86_64

Install method

npm global, gateway launched under systemd/supervisor with loopback gateway

Model

openai-codex/gpt-5.5

Provider / routing chain

OpenClaw -> openai-codex provider

Additional provider/model setup details

Discord channel-backed main agent session. A subagent announcement/inter-session message was queued around the same time as the latest user instruction. Private channel IDs, session IDs, and user content have been redacted from this report.

Logs, screenshots, and evidence

Sanitized evidence from the affected run:

```shell
OpenClaw 2026.5.2 (8b2a6e5)
Linux 6.17.0-23-generic #23~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 14 16:11:48 UTC 2 x86_64 GNU/Linux

[agent/embedded] Merged and removed orphaned user message to prevent consecutive user turns. runId=<redacted> sessionId=<redacted> trigger=user

trajectory: context.compiled run=<redacted> prompt=<latest user instruction>
trajectory: prompt.submitted run=<redacted> prompt=<latest user instruction>
trajectory: model.completed run=<redacted> finalPromptText=<latest user instruction> assistantTexts=[<reply to earlier user message>]

messagesSnapshot, simplified:
0 user <earlier short user message>
...
N user <latest user instruction>
N+1 assistant <reply to earlier short user message>

### Impact and severity

Affected: channel-backed sessions with queued/orphaned user-message merge behavior.
Severity: High for affected runs because the agent can visibly answer the wrong user instruction.
Frequency: Observed once; deterministic frequency is NOT_ENOUGH_INFO.
Consequence: User instructions can be ignored or replaced by stale context after session repair/queue merging, which is confusing and can derail operational workflows.

### Additional information

Duplicate search for open issues containing orphaned/queued/stale reply keywords returned no open matches. The report intentionally omits private channel IDs, session IDs, exact user content, screenshots, and local file paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions