Skip to content

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

@rnijhara

Description

@rnijhara

Summary

The session-memory hook currently captures the last 15 JSONL lines from a session. This can be insufficient for longer conversations, and the count should be configurable.

Proposed Changes

  1. Add messages config option to hook entry:
{
  "hooks": {
    "internal": {
      "entries": {
        "session-memory": {
          "enabled": true,
          "messages": 100
        }
      }
    }
  }
}
  1. Fix message filtering order: Currently the code does slice(-15) first, then filters for user/assistant messages. This means if those 15 lines contain tool calls, you get fewer actual messages.

    Proposed: Filter user/assistant messages first, then slice to guarantee N actual conversation messages.

  2. Default: Keep 15 for backward compatibility.

Use Case

Power users with long sessions want to capture more context when running /new. I've been running a local override with messages: 100 and it works great.

Implementation Notes

  • Config schema update for hook entry type
  • Handler reads messages from config
  • HOOK.md documentation update
  • Will include tests

Happy to submit a PR for this! 🦞

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions