Skip to content

[Feature] Persistent cross-run memory for agents — integrate Dakera to remember prior codebase decisions #2087

Description

@ferhimedamine

Problem

MetaGPT agents (ProductManager, Architect, Engineer, QA) do excellent work on software tasks — but every new run starts from scratch. When MetaGPT works on the same codebase across multiple runs, it has no memory of:

  • Architectural decisions made in previous runs
  • Which modules were determined to need refactoring and why
  • Bug patterns found and fixes applied
  • Test coverage gaps identified in previous analysis

This matters especially for long-horizon development: if I run MetaGPT on a project on Monday, then again on Tuesday with a different task, Tuesday's agents have zero context from Monday.

Proposed: Dakera as a persistent memory backend

Dakera is a self-hosted vector memory server with decay weighting. Integration in metagpt/memory/ would let agents store and recall relevant observations across runs.

Integration pointmetagpt/memory/longterm_memory.py or a new DakeraMemory:

from dakera import DakeraClient
from metagpt.schema import Message

class DakeraLongTermMemory:
    """Persistent cross-run memory backed by Dakera."""
    
    def __init__(self, agent_name: str, project_name: str):
        self.client = DakeraClient(base_url="http://localhost:3300")
        self.agent_id = f"{project_name}/{agent_name}"
    
    def remember(self, msg: Message) -> None:
        self.client.store_memory(
            agent_id=self.agent_id,
            content=msg.content,
            metadata={"role": msg.role, "cause_by": str(msg.cause_by)},
        )
    
    def recall(self, query: str, k: int = 5) -> list[Message]:
        response = self.client.recall(agent_id=self.agent_id, query=query, top_k=k)
        return [
            Message(content=m.content, role=m.metadata.get("role", "assistant"))
            for m in (response.memories or [])
        ]

Usage in a MetaGPT role (e.g., metagpt/roles/engineer.py):

class Engineer(Role):
    def __init__(self, ...):
        super().__init__(...)
        self.lt_memory = DakeraLongTermMemory("Engineer", self.config.project_name)
    
    async def _act(self):
        # Recall relevant prior engineering decisions
        prior = self.lt_memory.recall(self.rc.important_memory[-1].content)
        # Inject as context
        ...
        # After acting, store the outcome
        self.lt_memory.remember(result_msg)

Relationship to existing MetaGPT memory

MetaGPT already has ShortTermMemory (current run) and LongTermMemory (keyword-based, run-local). Dakera would be a third tier: cross-run semantic memory — persisting between startup() calls on the same project.

Setup

docker run -d -p 3300:3300 -e DAKERA_API_KEY=demo ghcr.io/dakera-ai/dakera:latest
pip install dakera

Self-hosted, no external API. Configuration could follow MetaGPT's existing config2.yaml pattern. Happy to prototype as a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions