tinyhumansai/openhuman · warning

memory file not found: ${path}

Error message

memory file not found: ${path}

What it means

localCoreAiMemory.ts implements an in-memory mock/local implementation of the ai.* memory-file API (list/read/write) used when the local core AI harness runs without the full memory store. The 'ai.read_memory_file' handler looks up params.relative_path in a Map; a miss throws 'memory file not found: <path>'. This is a key-error on the virtual memory filesystem.

Source

Thrown at app/src/lib/ai/localCoreAiMemory.ts:96

  params: Record<string, unknown>
): Promise<unknown> {
  switch (method) {
    case 'ai.list_memory_files': {
      const dir = (params.relative_dir as string | undefined) ?? 'memory';
      const prefix = dir.endsWith('/') ? dir : `${dir}/`;
      const names: string[] = [];
      for (const k of memoryFiles.keys()) {
        if (k === dir || k.startsWith(prefix)) {
          const rest = k.startsWith(prefix) ? k.slice(prefix.length) : k;
          if (rest && !rest.includes('/')) names.push(rest);
        }
      }
      return names;
    }
    case 'ai.read_memory_file': {
      const path = params.relative_path as string;
      const v = memoryFiles.get(path);
      if (v === undefined) throw new Error(`memory file not found: ${path}`);
      return v;
    }
    case 'ai.write_memory_file': {
      const path = params.relative_path as string;
      const content = params.content as string;
      memoryFiles.set(path, content);
      return true;
    }
    case 'ai.memory_init':
      return true;
    case 'ai.memory_get_file': {
      const path = params.path as string;
      return fileRecords.get(path) ?? null;
    }
    case 'ai.memory_delete_chunks_by_path': {
      const path = params.path as string;
      const ids = chunksByPath.get(path);
      if (!ids) return 0;

View on GitHub (pinned to 7491200858)

Solutions

  1. Call ai.list_memory_files for the enclosing directory first and use the exact returned names.
  2. Normalize paths (strip leading './', lowercase consistently if the impl is case-sensitive) before read/write.
  3. Treat read as best-effort: catch 'memory file not found' and fall back to empty/default content rather than failing the turn.
  4. For persistence across sessions, ensure files are written through the durable memory store, not only the in-memory map.

Example fix

// before
const content = await callAi('ai.read_memory_file', { relative_path: path });

// after
const names = await callAi('ai.list_memory_files', { directory: dirname(path) });
if (!names.includes(basename(path))) return defaultContent;
const content = await callAi('ai.read_memory_file', { relative_path: path });
Defensive patterns

Strategy: type-guard

Validate before calling

const names = await callAi('ai.list_memory_files', { directory: dir });
if (!names.includes(name)) return defaultContent;
const content = await callAi('ai.read_memory_file', { relative_path: `${dir}/${name}` });

Type guard

function hasMemoryFile(map: Map<string, string>, path: string): boolean {
  return map.has(path.replace(/^\.\//, ''));
}

Try / catch

try {
  return await callAi('ai.read_memory_file', { relative_path: path });
} catch (err) {
  if (err instanceof Error && err.message.startsWith('memory file not found')) {
    return ''; // treat as empty memory, not a failure
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling the ai.read_memory_file method with a relative_path that was never written via ai.write_memory_file, or that was listed from a different directory prefix (path mismatch, leading './', case difference). Also after the in-memory map is reset (page reload / new session) while a caller retries an old path.

Common situations: Agent harness resuming a session whose memory files were only in the previous page lifetime; path normalization mismatch between list (keys) and read (lookup); tests exercising read before write.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/8e78177bee485ebc. Report an issue: GitHub.