Skip to content

[Bug]: Boot message injection uses parentId: null, orphaning conversation history after gateway restartΒ #10018

@hostiefofostie

Description

@hostiefofostie

Summary

After a gateway restart (SIGTERM β†’ launchd respawn), the conversation history is loaded from the JSONL transcript (confirmed: first API call uses ~193k tokens). However, the boot message injection (e.g., the subagent summary "🧭 Subagents: none") is written with parentId: null, which starts a new tree root in the transcript.

On the next turn, the tree walker follows the new root and ignores the entire previous conversation history. Context drops from ~193k to ~27k (just system prompt + boot message + new user message).

Steps to Reproduce

  1. Run a long main session with significant conversation history (~150k+ tokens)
  2. Restart the gateway (openclaw gateway restart or SIGTERM β†’ launchd KeepAlive)
  3. Send a message to the main session
  4. Observe: first API call uses full history (correct), but the injected boot message has parentId: null
  5. Next message only includes context from the boot message forward β€” all history orphaned

Evidence from transcript JSONL

ddf4f375 parent:b8422f94 | assistant | stop     ← old branch (193k, full history loaded)
7e475cea parent:null      | assistant | injected ← boot message (NEW ROOT - this is the bug)
042df08f parent:7e475cea  | user                 ← follows new root only
4f749f6f parent:042df08f  | assistant | toolUse  ← 27k tokens (history orphaned)

Expected Behavior

The boot message should set parentId to the ID of the last entry in the current conversation branch, preserving the full history chain across gateway restarts.

Actual Behavior

Boot message sets parentId: null, creating a new tree root that orphans all previous conversation history.

Environment

  • OpenClaw version: 2026.2.2-3
  • OS: macOS Tahoe 26.2
  • Install method: npm (global)
  • Model: anthropic/claude-opus-4-6
  • Gateway managed by launchd with KeepAlive=true

Workaround

Setting gateway.reload.mode: "hot" prevents accidental config-change-triggered restarts but doesn't fix the root cause for manual restarts.

Additional Context

The relevant code appears to be in the boot message injection function around line 5693 of gateway-cli-CHghbhEZ.js, where the injected message is created without looking up the current branch tip:

const messageBody = {
  role: "assistant",
  content: [{ type: "text", text: ... }],
  timestamp: now,
  stopReason: "injected",
  // parentId is NOT set here β€” defaults to null
};

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