Skip to content

fix: preserve conversation history on gateway restart#10060

Closed
openperf wants to merge 72 commits intoopenclaw:mainfrom
openperf:fix-boot-message-injection
Closed

fix: preserve conversation history on gateway restart#10060
openperf wants to merge 72 commits intoopenclaw:mainfrom
openperf:fix-boot-message-injection

Conversation

@openperf
Copy link
Copy Markdown
Contributor

@openperf openperf commented Feb 6, 2026

This PR fixes issue #10018, where a boot message injected after a gateway restart would create a new session branch, orphaning the previous conversation history.

Problem

When the gateway restarts, it sends a notification message (e.g., "Gateway restarted"). This message was being delivered to external channels (like Slack/Telegram) via deliverOutboundPayloads but was not being written to the session transcript. This caused a gap in the conversation history.

An earlier attempt to fix this involved replacing deliverOutboundPayloads with a full agentCommand run. However, this was an incorrect approach as it introduced significant overhead and unintended side effects (like triggering a full AI agent run for a simple notification).

Solution

This PR implements a lightweight and safe solution by separating the concerns:

  1. Keep deliverOutboundPayloads: The original function for sending external notifications remains unchanged, preserving its low-overhead behavior.
  2. Inject into Transcript: A new, dedicated function writeAssistantMessageToTranscript is introduced. This function is called right before deliverOutboundPayloads and is responsible for writing the restart message directly to the session transcript.

This new function leverages the existing SessionManager to ensure the message is appended correctly to the conversation tree, automatically handling the parentId and preserving the history chain.

This approach cleanly fixes the bug without altering the original notification behavior, ensuring both safety and correctness.

Greptile Overview

Greptile Summary

This PR threads an optional parentId through the restart-sentinel → agentCommand → embedded agent execution path, and adds readSessionLeafId() to read the last transcript entry ID so the gateway’s injected boot message is appended to the existing conversation branch rather than starting a new root after restart.

The new helper mirrors existing transcript tail-reading utilities (readLastMessagePreviewFromTranscript) by scanning a bounded window at the end of the JSONL transcript and returning the last parseable entry with an id.

Confidence Score: 4/5

  • This PR is close to safe to merge but has a failing/newly-invalid unit test that should be fixed first.
  • The runtime change is localized and follows existing transcript-reading patterns, but the added test uses the helper with an incorrect storePath argument type, which will make the test unreliable or fail in CI.
  • src/gateway/session-transcript-leaf.test.ts

@openclaw-barnacle openclaw-barnacle bot added gateway Gateway runtime commands Command implementations agents Agent runtime and tooling labels Feb 6, 2026
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@openperf openperf force-pushed the fix-boot-message-injection branch 2 times, most recently from cdeb69f to cfe7b73 Compare February 6, 2026 02:58
@openperf
Copy link
Copy Markdown
Contributor Author

openperf commented Feb 7, 2026

Hi! This PR is ready for review.
@steipete @Takhoffman Could you help review this when you have time? Thanks!

@openperf openperf force-pushed the fix-boot-message-injection branch from cfe7b73 to e465f23 Compare February 14, 2026 16:11
@openclaw-barnacle openclaw-barnacle bot added size: M and removed commands Command implementations labels Feb 14, 2026
@openperf openperf force-pushed the fix-boot-message-injection branch 3 times, most recently from 9c56667 to 944ea89 Compare February 14, 2026 16:29
steipete and others added 16 commits February 15, 2026 00:34
Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 8ed13fb
Co-authored-by: nicholascyh <[email protected]>
Co-authored-by: steipete <[email protected]>
Reviewed-by: @steipete
- Add 'minimax-api-key-cn' auth choice for Chinese users
- Reuse existing --minimax-api-key CLI option
- Use MINIMAX_CN_API_BASE_URL (https://api.minimaxi.com/anthropic)
- Similar to how moonshot supports moonshot-api-key-cn

Tested: build ✅, check ✅, test ✅
@openclaw-barnacle openclaw-barnacle bot added scripts Repository scripts commands Command implementations docker Docker and sandbox tooling channel: feishu Channel integration: feishu channel: irc size: XL and removed size: M labels Feb 14, 2026
@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

2 similar comments
@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

17 similar comments
@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

@openclaw-barnacle
Copy link
Copy Markdown

Closing this PR because it has more than 20 labels, which usually means the branch is too noisy. Please recreate the PR from a clean branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: ios App: ios app: macos App: macos channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: irc channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: nextcloud-talk Channel integration: nextcloud-talk channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.