Skip to content

feat(memory): replace MemoryTool to use MempalaceAdapter (config-gated) [phase-5] #357

@quangdang46

Description

@quangdang46

Problem

jcode's MemoryTool (the LLM-callable tool exposing remember/recall/search/list/forget/tag/link/related actions) currently calls MemoryManager directly. It needs to use MempalaceAdapter when memory_backend = "mempalace" config is set, without changing the tool's external API.

Scope

Files: crates/jcode-app-core/src/tool/memory.rs, crates/jcode-config-types/src/lib.rs

  1. Add config option:

    // In AgentsConfig:
    pub memory_backend: MemoryBackend,  // default: MemoryBackend::Native
    pub enum MemoryBackend {
        Native,      // current JSON-based MemoryManager
        Mempalace,   // mempalace MemoryProvider via MempalaceAdapter
    }
  2. Backend dispatch in MemoryTool:

    enum MemoryBackend {
        Native(MemoryManager),
        Mempalace(MempalaceAdapter),
    }

    The execute() method dispatches based on which variant is active. Same 8 actions (remember, recall, search, list, forget, tag, link, related) — only the backend changes.

  3. Construction: When memory_backend = "mempalace", construct MempalaceAdapter instead of MemoryManager at the tool initialization site in the tool registry.

  4. TUI activity events: Wire PalaceBuilder::activity_sink() to emit jcode's MemoryActivity events so the TUI info widget continues working.

  5. Feature flag: #[cfg(feature = "mempalace-backend")] gates the mempalace path.

Acceptance Criteria

  • memory_backend = "native" (default) works exactly as before
  • memory_backend = "mempalace" delegates all 8 tool actions to MempalaceAdapter
  • No change to the tool's schema or external behavior
  • TUI shows memory activity for both backends
  • Config can be set in .jcode/config.json or env var JCODE_MEMORY_BACKEND
  • cargo test --workspace passes

Dependencies

Reference

jcode MemoryTool: crates/jcode-app-core/src/tool/memory.rs lines 10-428
jcode MemoryInput: lines 45-78
jcode action dispatch: lines 117-428
jcode tool registry: crates/jcode-app-core/src/tool/mod.rs line 245

Metadata

Metadata

Assignees

No one assigned

    Labels

    mp-migrationjcode → mempalace memory migrationphase-5Migration Phase 5 (jcode adapter)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions