Skip to content

memory_save accepts project parameter but iii engine serialization drops it — memory-project-coverage diagnose perpetually fails #751

@mikeExit

Description

@mikeExit

Summary

memory_save MCP tool defines project in its input schema and the handler (src/mcp/server.ts:175-185) correctly forwards it to mem::remember. The remember function (src/functions/remember.ts:121) spreads project onto the Memory object before kv.set(). However, the iii engine's serialization layer drops the field — it is never persisted to the binary store.

Evidence

  1. Unit test passestest/remember-project-scope.test.ts mocks the KV store and verifies the field is written. This confirms the agentmemory code does the right thing.

  2. Real engine drops it — All memories saved via memory_save(project="juice") show project=<missing> when read back from:

    • The GET /agentmemory/memories REST endpoint
    • The binary file (mem%3Amemories.bin at ./data/state_store.db/)
    • The MCP memory_recall tool
  3. Direct binary file edit confirms engine rejects unknown fields — Adding project to each memory in the .bin file caused the engine to start with 0 memories (silently recreating the file from scratch).

Impact

  • memory_diagnose check memory-project-coverage permanently shows failure
  • POST /agentmemory/migrate {"step":"infer-memory-projects"} returns ambiguous: 256, updated: 0
  • Sessions CAN be created with project scope (confirmed via POST /agentmemory/session/start), but the project never flows down to memories saved through any external API
  • Cross-project isolation and inferMemoryProjects() backfill are both broken in production

Root Cause

The Memory type (src/types.ts) defines project?: string and remember.ts sets it. The inferMemoryProjects() function in src/functions/migrate.ts also writes project via the same kv.set() path. This suggests the issue is in the iii engine's state::set implementation — it serializes memories using a fixed schema that rejects unknown keys.

To Reproduce

npx @agentmemory/agentmemory  # start engine
# Save with project
npx @agentmemory/agentmemory mcp  # then call memory_save with project="test"
# Read back — project field is missing
curl http://localhost:3111/agentmemory/memories?limit=1 | jq '.memories[0].project'
# Output: null

Or directly via MCP tool:

  • Call memory_save with project: "juice"
  • Response object has no project field
  • Binary file at ./data/state_store.db/mem%3Amemories.bin confirms it's absent

Expected Behavior

memory_save(project="juice") should persist the project field on the memory, and the diagnose check should pass after running infer-memory-projects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions