Skip to content

feat(memory): integrate fusion-memory long-term memory adapter #150

Closed

Description

@dahai80

Background

fusion-memory (dahai80/fusion-memory) is the Fusion ecosystem's system-level long/short-term memory and cognitive graph hub. It provides cross-session memory: episodic commit, semantic retrieve, and forgetting-curve consolidation. fm-server exposes an HTTP JSON-RPC 2.0 API on 127.0.0.1.

fusion-code currently lacks cross-session long-term memory. Each session is stateless — the agent re-asks known preferences, loses context across sessions, and cannot recall prior interactions. This PR integrates fusion-memory to close that gap.

Proposal

Add a memory adapter that:

  1. Retrieves relevant memory context at turn start and injects it into the system prompt (alongside git context and chub hints).
  2. Commits each completed turn to long-term memory at session end (fire-and-forget, never blocks the main loop).
  3. Degrades gracefully — if fm-server is down or FUSION_MEMORY_API_KEY is unset, memory is skipped with a debug log, never thrown.

Wire contract

JSON-RPC 2.0 envelope {jsonrpc, method, params, id} -> {result|error, id}:

  • commit -> string[] (turn-level memory ids)
  • retrieve -> {blocks: ContextBlock[], total_tokens: number}
  • consolidate -> {dropped, promoted, merged, summarized, reextracted, reconciled}

HTTP routes: POST /v1/memory/{method} (Bearer auth), GET /healthz.

Integration seams

  • Retrieve inject: src/tools/AgentTool/AgentTool.tsx — between git-context append and chub-hint append in enhancedSystemPrompt.
  • Turn commit: src/query/stopHooks.ts — alongside extractMemories, guarded by !toolUseContext.agentId (main agent only).

Config (operator env)

Env Default Purpose
FUSION_MEMORY_BASE_URL http://127.0.0.1:11440 fm-server base URL (11440 to avoid fusion-kb 11435 collision)
FUSION_MEMORY_API_KEY (none) Bearer token; if unset, memory is skipped

Scope

  • New: src/services/memory/fusionMemoryClient.ts, src/services/memory/commitTurn.ts, src/services/memory/fusionMemoryClient.test.ts
  • Edit: src/tools/AgentTool/AgentTool.tsx (inject retrieve), src/query/stopHooks.ts (commit turn)
  • No changes to existing session memory, extract-memories, or KB logic.

100% offline — HTTP only to 127.0.0.1. No cloud calls.

Activity

  1. dahai80 commented on Aug 27, 2026

    @dahai80
    OwnerAuthor

    Closed by #151 (merge 5311b00), which landed the commit half (turn-end commit to fusion-memory). The retrieve-inject half proposed here is tracked in #154 — #151 deferred it because the subagent prompt seam () is the wrong injection point; #154 asks the maintainer to confirm the main-agent system-prompt assembly seam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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