openclaw - 💡(How to fix) Fix Feature: session:start hook with automatic memory injection for new sessions

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

  • Current workaround requires users to manually re-explain context after /new
  • Memory saved by session-memory is effectively orphaned — saved but never used
  • Breaks continuity for long-running agents that handle multiple topics
  • This is a highly requested feature from users who have tried session-memory

Fix Action

Fix / Workaround

  • Current workaround requires users to manually re-explain context after /new
  • Memory saved by session-memory is effectively orphaned — saved but never used
  • Breaks continuity for long-running agents that handle multiple topics
  • This is a highly requested feature from users who have tried session-memory

Code Example

{ "events": ["session:start"], "always": true }

---

{
  "hooks": {
    "internal": {
      "entries": {
        "session-memory": {
          "enabled": true,
          "llmSlug": true,
          "autoInject": {
            "enabled": true,
            "daysToLoad": 7,
            "maxMemories": 3,
            "maxTokens": 4000,
            "relevanceThreshold": 0.3
          }
        }
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Feature Request: session:start hook with automatic memory injection

Problem

OpenClaw currently lacks a session:start event hook. This creates two documented gaps:

  1. session-memory saves but never recalls (#32905 — CLOSED stale) — session-memory hook saves context to workspace/memory/YYYY-MM-DD-slug.md on /new or /reset, but there is no corresponding recall mechanism. New sessions start with zero recollection of saved memories.

  2. No memory-inject on session start (#11618 — CLOSED) — proposed memory-inject hook to load relevant memory files at session start was never implemented.

Current Memory Architecture (Working)

For reference, OpenClaw has working mechanisms:

MechanismTriggerStatus
memoryFlush (compaction)Before compactionImplemented
autoRecallBefore each agent responseImplemented
session-memory hook/new or /resetSaves, but no auto-inject
gateway:startup hookGateway restartWorks

However, none of these provide memory injection when a new session naturally starts — only when compaction fires or when user manually issues /new.

Proposed Solution

Add a session:start internal hook event triggered when a session's first user message arrives (detected by transcript having only system prompt + no user messages).

Implementation approach:

Option A — session:start event (recommended)

Hook catalog entry:

{ "events": ["session:start"], "always": true }

Handler behavior:

  1. Detect first message: transcript lines == system prompt only
  2. Scan workspace/memory/*.md for memories from last N days
  3. Inject relevant memories into bootstrap context via context.bootstrapFiles

Option B — Extend existing command:new hook

Add auto-inject logic to session-memory hook on command:new, injecting memories back into the new session context.

Option C — Bootstrap-based injection

Use agent:bootstrap event to scan for and inject recent memory files, since bootstrap fires on each session initialization.

Configuration Example

{
  "hooks": {
    "internal": {
      "entries": {
        "session-memory": {
          "enabled": true,
          "llmSlug": true,
          "autoInject": {
            "enabled": true,
            "daysToLoad": 7,
            "maxMemories": 3,
            "maxTokens": 4000,
            "relevanceThreshold": 0.3
          }
        }
      }
    }
  }
}

Why This Matters

  • Current workaround requires users to manually re-explain context after /new
  • Memory saved by session-memory is effectively orphaned — saved but never used
  • Breaks continuity for long-running agents that handle multiple topics
  • This is a highly requested feature from users who have tried session-memory

References

  • Original feature request: #11618 (closed, unimplemented)
  • Complementary issue: #32905 (closed, stale)

Priority: High
Use case: Persistent memory across independently-started sessions for daily-driver agents

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature: session:start hook with automatic memory injection for new sessions