Skip to content

Agent: prepareStep memory category starvation with single limit:50 read #116

@federiconeri

Description

@federiconeri

Summary

prepareStep in the agent orchestrator calls store.read({ limit: 50 }) which returns the 50 most recent entries across ALL types combined, then filters by type in memory. After many iterations, work_log entries dominate and push out strategic_context, decision, and project_knowledge entries entirely.

Problem / Context

The memory injection is the agent's learning mechanism. If strategic context and decisions are absent from the prompt after ~50 work logs, the agent loses its long-term knowledge — defeating the purpose of permanent memory types.

Proposed Solution

Make separate reads per type to guarantee each category is represented:

const recentLogs = await store.read({ type: 'work_log', limit: 5 });
const knowledge = await store.read({ type: 'project_knowledge', limit: 3 });
const decisions = await store.read({ type: 'decision', limit: 2 });
const strategic = await store.read({ type: 'strategic_context', limit: 1 });

This trades 1 disk read for 4, but each is bounded and guarantees category representation.

Files to Modify

File Changes
src/agent/orchestrator.ts Replace single store.read({ limit: 50 }) with per-type reads

Acceptance Criteria

  • Each memory type always has entries in the prompt (when they exist in the store)
  • Total injected entries are bounded (e.g., 11 max)
  • Existing tests pass

Metadata

Metadata

Assignees

Labels

ai/llmAI workflows, agents, promptsenhancementEnhancement to existing feature

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions