Skip to content

Project-scoped memories saved to .llxprt/LLXPRT.md are not loaded by memory discovery #985

@acoliver

Description

@acoliver

Summary

When using save_memory with scope: 'project', memories are saved to ./.llxprt/LLXPRT.md, but the memory discovery system's upward scan does not look for files in .llxprt/ subdirectories, causing project-scoped memories to not be loaded.

Root Cause

Where save_memory writes (project scope):

In packages/core/src/tools/memoryTool.ts line 120-122:

function getProjectMemoryFilePath(workingDir: string): string {
  return path.join(workingDir, LLXPRT_CONFIG_DIR, getCurrentLlxprtMdFilename());
}
// Results in: ./.llxprt/LLXPRT.md

Where memory discovery looks:

In packages/core/src/utils/memoryDiscovery.ts:

  1. Global path (lines 150-154) - checks ~/.llxprt/LLXPRT.md

  2. Upward scan (line 192):

const potentialPath = path.join(currentDir, geminiMdFilename);

This looks for ./LLXPRT.md, ../LLXPRT.md, etc. - NOT ./.llxprt/LLXPRT.md

  1. Downward BFS search (lines 215-221) - searches subdirectories, might find .llxprt/LLXPRT.md but is unreliable

The Mismatch

The upward scan looks for LLXPRT.md directly in directories, not inside .llxprt/ subdirectories. But save_memory with project scope saves to .llxprt/LLXPRT.md.

The only way project-scoped memories get found is via the BFS downward search, which might fail if:

  1. .llxprt directory is being ignored (by .gitignore or .llxprtignore)
  2. The maxDirs limit is reached before scanning .llxprt/
  3. The search starts from a subdirectory

Expected Behavior

Project-scoped memories saved to ./.llxprt/LLXPRT.md should be reliably loaded when the CLI starts.

Suggested Fix

The upward scan should also check for LLXPRT.md inside .llxprt/ directories:

// In addition to checking path.join(currentDir, geminiMdFilename)
// Also check:
const llxprtDirPath = path.join(currentDir, GEMINI_DIR, geminiMdFilename);
try {
  await fs.access(llxprtDirPath, fsSync.constants.R_OK);
  if (llxprtDirPath !== globalMemoryPath) {
    upwardPaths.unshift(llxprtDirPath);
  }
} catch {
  // Not found, continue.
}

Affected Files

  • packages/core/src/utils/memoryDiscovery.ts (lines 186-208)
  • packages/core/src/tools/memoryTool.ts (lines 120-122)

Reproduction

  1. Run save_memory with a fact using scope: 'project'
  2. Verify the file is created at ./.llxprt/LLXPRT.md
  3. Restart the CLI
  4. The saved memory is not loaded into context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions