Skip to content

feat: Add Persistent Memory configuration to Sub Agent / Sub Agent Flow nodes #540

Description

@breaking-brake

Overview

Claude Code has added a Persistent Memory feature for sub-agents (docs).
This issue adds memory field configuration to both Sub Agent nodes and Sub Agent Flow nodes.


Background: Persistent Memory

Adding a memory field to a sub-agent's YAML frontmatter assigns a persistent directory that survives across conversations, allowing the sub-agent to build up knowledge over time.

---
name: code-reviewer
description: Reviews code for quality and best practices
memory: user
---

Memory Scopes

Scope Storage Location Use Case
user ~/.claude/agent-memory/<name>/ Remember learnings across all projects
project .claude/agent-memory/<name>/ Project-specific knowledge (VCS-trackable)
local .claude/agent-memory-local/<name>/ Project-specific knowledge (not in VCS)

Behavior When Enabled

  • Sub-agent's system prompt includes instructions for reading/writing to the memory directory
  • First 200 lines of MEMORY.md in the memory directory are included in the system prompt
  • Read, Write, and Edit tools are automatically enabled

Current State

SubAgentData (current fields)

// src/shared/types/workflow-definition.ts
export interface SubAgentData {
  description: string;
  prompt: string;
  tools?: string;
  model?: 'sonnet' | 'opus' | 'haiku' | 'inherit';
  color?: 'red' | 'blue' | 'green' | 'yellow' | 'purple' | 'orange' | 'pink' | 'cyan';
  outputPorts: number;
}

SubAgentFlowNodeData (current fields)

export interface SubAgentFlowNodeData {
  subAgentFlowId: string;
  label: string;
  description?: string;
  outputPorts: 1;
  model?: 'sonnet' | 'opus' | 'haiku' | 'inherit';
  tools?: string;
  color?: keyof typeof SUB_AGENT_COLORS;
}

Neither type includes a memory field.


Implementation Tasks

1. Type Definitions

T1: src/shared/types/workflow-definition.ts

  • Add MemoryScope type: 'user' | 'project' | 'local'
  • Add memory?: MemoryScope field to SubAgentData
  • Add memory?: MemoryScope field to SubAgentFlowNodeData

2. Webview UI

T2: src/webview/src/components/PropertyOverlay.tsx - SubAgent section

  • Add Memory Scope dropdown to Sub Agent PropertyOverlay
    • Options: None (default), user, project, local
    • Help text: briefly explain each scope's storage location

T3: src/webview/src/components/PropertyOverlay.tsx - SubAgentFlow section

  • Add Memory Scope dropdown to Sub Agent Flow PropertyOverlay
    • Same options and help text as Sub Agent

T4: src/webview/src/components/nodes/SubAgentNode.tsx

  • Display a badge or icon on the node when memory is configured

T5: src/webview/src/components/nodes/SubAgentFlowNode.tsx

  • Display a badge or icon on the node when memory is configured

3. Schema & Validation

T6: resources/workflow-schema.json

  • Add memory field definition to SubAgent node type
  • Add memory field definition to SubAgentFlow node type
  • Add AI generation instructions for appropriate memory field usage

T7: src/extension/utils/validate-workflow.ts

  • Add memory field validation (enum check: user | project | local)

4. i18n

T8: Translation files

  • en.json: Add memory-related labels and help text
  • ja.json: Same
  • ko.json: Same
  • zh-CN.json: Same
  • zh-TW.json: Same

5. Testing

  • T9: Manual E2E - Set, save, and reload Memory Scope on Sub Agent node
  • T10: Manual E2E - Set, save, and reload Memory Scope on Sub Agent Flow node
  • T11: Manual E2E - Memory badge displays correctly on nodes
  • T12: Manual E2E - AI-generated workflows correctly output memory field

Modified Files

File Changes
src/shared/types/workflow-definition.ts Add MemoryScope type, add memory to SubAgentData / SubAgentFlowNodeData
src/webview/src/components/PropertyOverlay.tsx Add Memory dropdown to both SubAgent and SubAgentFlow sections
src/webview/src/components/nodes/SubAgentNode.tsx Memory badge display
src/webview/src/components/nodes/SubAgentFlowNode.tsx Memory badge display
resources/workflow-schema.json Add memory field definitions
src/extension/utils/validate-workflow.ts Add memory validation
src/webview/src/i18n/translations/*.json Add i18n entries

Out of Scope

  • Actual memory directory creation/management (workflow execution engine scope)
  • MEMORY.md preview/edit UI
  • Other unimplemented Claude Code Sub Agent frontmatter fields (permissionMode, skills, hooks, disallowedTools)

Acceptance Criteria

  • Sub Agent node PropertyOverlay allows selecting Memory Scope (user / project / local / none)
  • Sub Agent Flow node PropertyOverlay allows selecting Memory Scope
  • Configured Memory Scope is correctly saved/restored in workflow JSON
  • Nodes with memory configured display a badge/icon
  • AI workflow generation properly supports the memory field
  • Invalid memory values trigger validation errors

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions