-
-
Notifications
You must be signed in to change notification settings - Fork 69.1k
[Bug]: Boot message injection uses parentId: null, orphaning conversation history after gateway restartΒ #10018
Description
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
- Run a long main session with significant conversation history (~150k+ tokens)
- Restart the gateway (
openclaw gateway restartor SIGTERM β launchd KeepAlive) - Send a message to the main session
- Observe: first API call uses full history (correct), but the injected boot message has
parentId: null - 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
};