Skip to content

Memory lost on gateway restart: agent_end hook never fires #435

@zmlgit

Description

@zmlgit

Problem

When the OpenClaw gateway restarts (SIGTERM), the agent_end hook never fires for active sessions. Since auto-capture only persists memories in agent_end, all conversation content from those sessions is lost.

Reproduction

  1. Have a conversation with the bot
  2. Restart gateway (openclaw gateway restart or SIGTERM)
  3. Check LanceDB — no new memories from that session

Root Cause

In index.ts, user messages are queued in autoCapturePendingIngressTexts via the message_received hook, but only processed (smart extraction + regex capture) in agent_end. If agent_end never fires (crash, restart, kill), the queue is lost.

Suggested Fix

  1. Eager capture option: Add a config like eagerCapture: true that does lightweight regex-based ingestion in message_received (no smart extraction needed), so at least raw facts are persisted immediately.
  2. Graceful shutdown: Have the gateway flush pending ingest queues on SIGTERM before exiting.

Environment

  • memory-lancedb-pro@1.1.0-beta.9
  • OpenClaw gateway v2026.3.28

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions