Skip to content

feat(hooks): make session-memory message count configurable#2732

Merged
obviyus merged 4 commits intoopenclaw:mainfrom
rnijhara:feat/session-memory-configurable
Jan 28, 2026
Merged

feat(hooks): make session-memory message count configurable#2732
obviyus merged 4 commits intoopenclaw:mainfrom
rnijhara:feat/session-memory-configurable

Conversation

@rnijhara
Copy link

Summary

Fixes #2681

Adds messages config option to session-memory hook (default: 15).

Changes

  1. handler.ts — Added messages config option, fixed filter order bug (now filters user/assistant messages FIRST, then slices)
  2. HOOK.md — Added configuration section with example
  3. handler.test.ts — 9 new tests covering all functionality

Testing

  • ✅ All 9 new tests pass
  • ✅ All 86 hooks tests pass (no regressions)
  • ✅ Lint passes
  • ✅ Build passes

Config Example

{
  "hooks": {
    "internal": {
      "entries": {
        "session-memory": {
          "enabled": true,
          "messages": 100
        }
      }
    }
  }
}

AI-assisted: Built with Claude Code (Opus 4.5). Fully tested locally.

@rnijhara
Copy link
Author

CI Failures - Upstream Issue

The CI failures are not related to this PR's changes. They're caused by a lockfile mismatch on main:

ERR_PNPM_OUTDATED_LOCKFILE
extensions/memory-core/package.json requires clawdbot >=2026.1.26
but pnpm-lock.yaml still has >=2026.1.24-3

This was introduced by commit 72fea5e30 (version bump to 2026.1.26) which updated package.json but didn't regenerate the lockfile.

To fix: Someone with write access needs to run pnpm install on main and commit the updated lockfile.

Happy to rebase once that's fixed! 🦞

…#2681)

Adds `messages` config option to session-memory hook (default: 15).
Fixes filter order bug - now filters user/assistant messages first,
then slices to get exactly N messages. Previously sliced first which
could result in fewer messages when non-message entries were present.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rnijhara rnijhara force-pushed the feat/session-memory-configurable branch from 4914556 to e9590eb Compare January 27, 2026 15:30
@rnijhara
Copy link
Author

This PR includes a fix for Windows path handling in session-memory.ts by using fileURLToPath instead of manually stripping file://.

The previous approach (import.meta.url.replace('file://', '')) produces invalid paths on Windows like /C:/...C:\C:\....

CI Status: The Windows test failure is pre-existing and unrelated to this change — it's in config/paths.test.ts (CONFIG_PATH legacy filename handling), not the session-memory hook.

@obviyus obviyus self-assigned this Jan 28, 2026
@obviyus obviyus added the agents Agent runtime and tooling label Jan 28, 2026
@obviyus obviyus merged commit d93f8ff into openclaw:main Jan 28, 2026
19 of 24 checks passed
@obviyus
Copy link
Contributor

obviyus commented Jan 28, 2026

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: d93f8ff
  • Merge commit: d93f8ff

Thanks @rnijhara!

@rnijhara
Copy link
Author

Thanks for merging @obviyus !

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

Labels

agents Agent runtime and tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(hooks): Make session-memory message count configurable

2 participants