openclaw - 💡(How to fix) Fix [Feature]: `session-memory` hook does not comply with AGENTS.md workspace directory convention [1 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#60034Fetched 2026-04-08 02:37:12
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
commented ×1labeled ×1

The built-in session-memory hook hardcodes output to memory/<YYYY-MM-DD-slug>.md, and does not comply with the directory structure defined in AGENTS.md. It is recommended to add outputPath + filename configuration options to the hook to make the output path fully customizable.

Root Cause

The root cause is in the hook source code — the path is hardcoded:

Code Example

const memoryDir = path.join(workspaceDir, "memory");
const filename = `${dateStr}-${slug}.md`;  // YYYY-MM-DD-slug.md — not configurable

---

"hooks": {
  "internal": {
    "entries": {
      "session-memory": {
        "enabled": true,
        "sessions": {
          "outputPath": "memory/sessions/<yyyy>/<MM>/<dd>/",
          "filename": "<HHmm>_<Slug>.md"
        },
        "daily": {
          "outputPath": "memory/daily/",
          "filename": "<yyyyMMdd>_<Slug>.md"
        }
      }
    }
  }
}

---

const memoryDir = path.join(workspaceDir, "memory");
const filename = `${dateStr}-${slug}.md`;  // Hardcoded — not configurable
const memoryFilePath = path.join(memoryDir, filename);

---

memory/
└── 2026-04-02-1514.md

---

memory/
├── daily/
│   └── 20260402_AgentBrowser.md
└── sessions/
    └── 2026/
        └── 04/
            └── 02/
                └── 1514_AgentBrowser.md
RAW_BUFFERClick to expand / collapse

Summary

The built-in session-memory hook hardcodes output to memory/<YYYY-MM-DD-slug>.md, and does not comply with the directory structure defined in AGENTS.md. It is recommended to add outputPath + filename configuration options to the hook to make the output path fully customizable.

Problem to solve

The memory/ root directory is getting increasingly cluttered, with files like memory/2026-04-02-1514.md that are impossible to distinguish. Users defined a canonical directory structure through AGENTS.md (e.g., memory/sessions/<YYYY>/<MM>/<DD>/<HHmm>_<Slug>.md), but the hook completely ignores the convention and stubbornly writes flat files.

The root cause is in the hook source code — the path is hardcoded:

const memoryDir = path.join(workspaceDir, "memory");
const filename = `${dateStr}-${slug}.md`;  // YYYY-MM-DD-slug.md — not configurable

There are no configuration options to customize the directory path or filename format.

Proposed solution

Introduce two independent configuration options in the session-memory hook:

"hooks": {
  "internal": {
    "entries": {
      "session-memory": {
        "enabled": true,
        "sessions": {
          "outputPath": "memory/sessions/<yyyy>/<MM>/<dd>/",
          "filename": "<HHmm>_<Slug>.md"
        },
        "daily": {
          "outputPath": "memory/daily/",
          "filename": "<yyyyMMdd>_<Slug>.md"
        }
      }
    }
  }
}

Supported placeholders:

PlaceholderMeaningExample
<yyyy>4-digit year2026
<MM>2-digit month04
<dd>2-digit day02
<HH>2-digit hour (24-hour)23
<HHmm>4-digit time (no separator)1514
<HH-mm>Time (with - separator)15-14
<yyyyMMdd>8-digit date (no separator)20260402
<yyyy-MM-dd>Date (with - separator)2026-04-02
<Slug>slug (CamelCase, no separator)AgentBrowser
<slug>slug (all lowercase, - word separator)agent-browser

Naming styles (2×2 = 4 combinations):

sessions filenames:

StylefilenameOutput file
HHmm_slug1514_agent-browser.md
HHmm_Slug1514_AgentBrowser.md
HH-mm_slug15-14_agent-browser.md
HH-mm_Slug15-14_AgentBrowser.md

daily filenames:

StylefilenameOutput file
yyyyMMdd_slug20260402_agent-browser.md
yyyyMMdd_Slug20260402_AgentBrowser.md
yyyy-MM-dd_slug2026-04-02_agent-browser.md
yyyy-MM-dd_Slug2026-04-02_AgentBrowser.md

Backward compatibility: Both outputPath and filename default to empty string "", preserving current behavior (writes to memory/ root).

Alternatives considered

No response

Impact

  • Affected users: All OpenClaw users who rely on the session-memory hook and have defined workspace conventions in AGENTS.md
  • Severity: Annoying / workspace integrity — not blocking, but undermines the value of documented conventions
  • Frequency: Every time /new or /reset is used
  • Consequence: memory/ root accumulates unstructured files; users lose the ability to organize memory files predictably

Additional issue — empty folders: When outputPath contains multi-level date structures (e.g., memory/sessions/<yyyy>/<MM>/<dd>/), if a day has no sessions, or files are migrated/deleted, the directory structure remains but is empty (e.g., memory/sessions/2026/04/05/). It is recommended that the hook supports auto-cleaning empty parent directories under the write path when writing.

Evidence/examples

Hook source (dist/bundled/session-memory/handler.js):

const memoryDir = path.join(workspaceDir, "memory");
const filename = `${dateStr}-${slug}.md`;  // Hardcoded — not configurable
const memoryFilePath = path.join(memoryDir, filename);

Current (incorrect) output:

memory/
└── 2026-04-02-1514.md

Expected (AGENTS.md convention):

memory/
├── daily/
│   └── 20260402_AgentBrowser.md
└── sessions/
    └── 2026/
        └── 04/
            └── 02/
                └── 1514_AgentBrowser.md

Hook documentation (dist/bundled/session-memory/HOOK.md) states that the hook creates files at <workspace>/memory/YYYY-MM-DD-slug.md, with no mention of configuration options or AGENTS.md convention compliance.

Additional information

  • Hook implementation: dist/bundled/session-memory/handler.js
  • Hook documentation: dist/bundled/session-memory/HOOK.md
  • Workspace convention: AGENTS.md Session Startup section
  • Current config: openclaw.jsonhooks.internal.entries.session-memory
  • OpenClaw version: 2026.3.24
  • Platform: Linux 6.12.41-trim (arm64), Channel: Feishu

⚠️ Disclaimer: This Issue was submitted without updating to the latest OpenClaw version. It is not certain whether this issue has been fixed in the latest version. Please verify before taking action.

extent analysis

TL;DR

Introduce outputPath and filename configuration options to the session-memory hook to make the output path fully customizable and compliant with the directory structure defined in AGENTS.md.

Guidance

  • Update the session-memory hook configuration in openclaw.json to include outputPath and filename options, following the proposed solution format.
  • Verify that the hook supports the desired directory structure and filename format by checking the memory/ directory after running the hook.
  • Consider implementing auto-cleaning of empty parent directories under the write path when writing to prevent accumulation of empty folders.
  • Review the hook documentation (dist/bundled/session-memory/HOOK.md) to ensure it reflects the new configuration options and compliance with AGENTS.md convention.

Example

"hooks": {
  "internal": {
    "entries": {
      "session-memory": {
        "enabled": true,
        "sessions": {
          "outputPath": "memory/sessions/<yyyy>/<MM>/<dd>/",
          "filename": "<HHmm>_<Slug>.md"
        },
        "daily": {
          "outputPath": "memory/daily/",
          "filename": "<yyyyMMdd>_<Slug>.md"
        }
      }
    }
  }
}

Notes

The proposed solution assumes that the session-memory hook can be updated to support the new configuration options. However, as the issue was submitted without updating to the latest OpenClaw version, it is uncertain whether this issue has been fixed in the latest version. Verification is recommended before taking action.

Recommendation

Apply the proposed workaround by introducing outputPath and filename configuration options to the session-memory hook, as it provides a flexible solution to customize the output path and comply with the directory structure defined in AGENTS.md.

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-memory` hook does not comply with AGENTS.md workspace directory convention [1 comments, 2 participants]