Skip to content

Agent memory package is dead code — no cross-query learning or recall is wired into the investigation agent #233

Description

@rafeegnash

Problem

The internal/agent/memory package implements an AgentMemory type with recent-query recall (GetSimilarQueries), service-health tracking (UpdateServiceHealth), learned-pattern accumulation (LearnPattern), and an intent-similarity scorer (calculateSimilarity). None of it is ever instantiated or referenced anywhere in the codebase. A grep for agent/memory, AgentMemory, memory.New, GetSimilarQueries, AddQueryContext, LearnPattern, and UpdateServiceHealth outside the package itself returns zero hits. Agent.InvestigateQuery builds a brand-new semantic.NewAnalyzer() on every call (agent.go:66) and carries no state across queries.

Where

  • internal/agent/memory/memory.go:12-107
  • internal/agent/agent.go:62-108
  • internal/agent/agent.go:66

Root cause

The memory layer was written as part of an 'agent memory' design but was never connected to the agent lifecycle. Agent (agent.go:40-45) has no *memory.AgentMemory field, so each query is fully stateless — the product is not actually 'remembering' anything despite advertising incident/query memory.

How to fix

Add a mem *memory.AgentMemory field to Agent, initialize it in NewAgent with a configurable MaxQueries, and in InvestigateQuery: (1) before fan-out, call mem.GetSimilarQueries(queryIntent, 3) and inject prior similar contexts into agentCtx.GatheredData["prior_context"] and BuildFinalContext; (2) after completion, call mem.AddQueryContext(...) and mem.LearnPattern(...). Persist AgentMemory to the resource SQLite cache (modernc.org/sqlite already a dep) so memory survives process restarts. Alternatively delete the package if memory is intentionally out of scope, so it stops implying a capability that does not exist.

Acceptance criteria

A second related query within a session demonstrably reuses prior gathered context (verifiable via a debug log / chain-of-thought entry referencing a similar past query), and AgentMemory has at least one production caller covered by a test.

Severity: medium · from holistic hardening review.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions