Skip to content

self-improvement beforeResetNote injects visible message to user on /new — should use prependContext instead #615

@eightHundreds

Description

@eightHundreds

Problem

When selfImprovement.beforeResetNote is enabled (default: true), the command:new / command:reset hook injects a /note self-improvement (before reset): ... string via event.messages.push() (index.ts:3041-3050).

This message is visible to the end user in the conversation, and triggers an Unknown skill: note error because note is not a registered skill — the raw parameter text is then exposed verbatim:

Unknown skill: note
Args from unknown skill: note self-improvement (before reset):
  If anything was learned/corrected, log it now:
  .learnings/LEARNINGS.md (corrections/best practices)
  .learnings/ERRORS.md (failures/root causes)
  Distill reusable rules to AGENTS.md / SOUL.md / TOOLS.md.
  If reusable across tasks, extract a new skill from the learning.
  Then proceed with the new session.

Root Cause

event.messages.push() in command:new / command:reset hooks injects content as a user-visible conversation message, not as silent system context.

Suggested Fix

The same codebase already has a better pattern — the before_prompt_build event handler supports a prependContext return value that injects content into the system context without exposing it to the user (index.ts:3157-3163):

api.on("before_prompt_build", async (_event, ctx) => {
  return {
    prependContext: [
      "<self-improvement-reminder>",
      "If anything was learned/corrected in the previous session, log it now:",
      "  - .learnings/LEARNINGS.md (corrections/best practices)",
      "  - .learnings/ERRORS.md (failures/root causes)",
      "Distill reusable rules to AGENTS.md / SOUL.md / TOOLS.md.",
      "</self-improvement-reminder>",
    ].join("\n"),
  };
});

Alternatively, the agent:bootstrap hook with bootstrapFiles.push() (already used at index.ts:2988) could also work.

Available injection points in the codebase

Method Code location Visible to user?
api.registerHook("command:new") + event.messages.push() index.ts:3060 Yes (current, problematic)
api.registerHook("agent:bootstrap") + bootstrapFiles.push() index.ts:2959 No
api.on("before_prompt_build") + return { prependContext } index.ts:3143, 3170 No

Since agent:bootstrap already injects SELF_IMPROVEMENT_REMINDER.md as a virtual bootstrap file, the command:new event.messages.push() injection may be redundant and could simply be removed.

Environment

  • memory-lancedb-pro v1.1.0-beta.10

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