Skip to content

[Bug]: /status reply breaks transcript tree structure, causing apparent context loss #10821

@bichxdmwnghia3609-commits

Description

GitHub Issue — Ready to Submit

Repo: https://github.com/openclaw/openclaw/issues/new


Title

/status reply breaks transcript tree structure, causing apparent context loss

Body

Description

After sending /status in webchat, the entire conversation context appears to be lost. The agent no longer remembers any prior conversation, and /status itself reports very low token counts (e.g., 15k/1M at 2%) despite having had hundreds of thousands of tokens in context moments before.

This has been reproduced twice in the same session within ~10 minutes.

Root Cause (from source code analysis)

When /status is processed, it correctly does NOT create an agent run (shouldContinue: false). However, the gateway's chat.send handler then appends the status reply to the transcript via appendAssistantTranscriptMessage (gateway-cli-D_8miTjF.js:6344-6355):

if (!agentRunStarted) {
    const combinedReply = finalReplyParts.map(part => part.trim()).filter(Boolean).join("\n\n").trim();
    if (combinedReply) {
        const appended = appendAssistantTranscriptMessage({
            message: combinedReply,
            sessionId: latestEntry?.sessionId ?? entry?.sessionId ?? clientRunId,
            ...
        });
    }
}

The problem: appendAssistantTranscriptMessage (gateway-cli-D_8miTjF.js:5998-6050) creates transcript entries without a parentId field:

const transcriptEntry = {
    type: "message",
    id: messageId,
    // No parentId!
    timestamp: new Date(now).toISOString(),
    message: messageBody
};

This creates a new root node in the transcript's tree structure. When the next agent run starts, buildSessionContext may follow this orphaned root instead of the actual conversation chain, resulting in a near-empty context.

Evidence

  • Session ID remained the same throughout (bf575334) — not a session replacement
  • /status entries in the transcript at L557 and L587 both have parentId=NONE
  • Token count dropped from hundreds of thousands to ~15k immediately after /status
  • Compaction count reset to 0
  • Both incidents coincided with webchat reconnection events

Steps to Reproduce

  1. Have a long-running webchat session with significant context (100k+ tokens)
  2. Send /status
  3. Send a normal message
  4. Observe that the agent has lost all prior context

Expected Behavior

/status should not affect conversation context in any way.

Suggested Fix

Either:

  1. Don't write /status replies to the transcript at all (preferred — it's metadata, not conversation)
  2. Set parentId on the appended message to link it to the current leaf entry, preserving the tree structure

Environment

  • OpenClaw 2026.2.3-1 (d84eb46)
  • Model: claude-opus-4-6
  • Channel: webchat
  • OS: Linux 6.14.0-37-generic (x64)

Labels

bug, transcript, webchat

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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