Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: overhaul memory system to focus on user values, not code details

Adam Eivy8711439e0b56
diff --git a/.changelog/v0.11.x.md b/.changelog/v0.11.x.md
index 7e9125d4df..5c7b16f073 100644
--- a/.changelog/v0.11.x.md
+++ b/.changelog/v0.11.x.md
@@ -187,3 +187,10 @@ This release focuses on security improvements, bug fixes for the AI runner syste
- **Color-Coded Expanded View**: Expanded agent output now color-codes tool invocations (accent blue), input details (gray), and tool results (dim gray) for easy scanning
- **Scrollable Output**: Expanded output view is now height-limited and scrollable to prevent page layout issues with verbose agents
- **Tool Counter**: Shows total tool invocation count when agents use more than 3 tools
+
+### Memory System Overhaul — User-Centric Knowledge
+- **Focus on the user, not the code**: Memory extraction now prioritizes user values, preferences, work patterns, and aesthetic taste — not implementation details an agent can discover by reading files
+- **Higher quality bar**: Minimum confidence raised from 0.6 to 0.7; auto-save threshold raised from 0.8 to 0.85. Most task outputs now correctly produce zero memories instead of noisy low-value ones
+- **Implementation detail filter**: Both LLM classifier and pattern-based fallback now reject file paths, CSS values, port numbers, architecture descriptions, status assessments, and other trivially-discoverable code facts
+- **Removed noise patterns**: Eliminated pattern extractors for "no issues found", "already well-optimized", conclusion sections, and positive assessments — these were generating the bulk of low-value 0% confidence approval requests
+- **Key test**: Every candidate memory now passes the question "Would a brand-new agent benefit from knowing this even with full code access?" — if it's about code, reject; if it's about the user, keep
diff --git a/server/services/memoryClassifier.js b/server/services/memoryClassifier.js
index d7f174cf9b..05458dbc5b 100644
--- a/server/services/memoryClassifier.js
+++ b/server/services/memoryClassifier.js
@@ -24,7 +24,7 @@ const DEFAULT_CONFIG = {
model: 'gptoss-20b',
timeout: 60000,
maxOutputLength: 10000,
- minConfidence: 0.6,
+ minConfidence: 0.7,
fallbackToPatterns: true
};
@@ -111,24 +111,28 @@ async function buildClassificationPrompt(task, agentOutput, config) {
* Fallback prompt if template not found
*/
function buildFallbackPrompt(task, agentOutput) {
- return `Analyze this agent output and extract useful memories.
+ return `Analyze this agent output and extract memories about the USER — their values, preferences, work patterns, and qualities they care about.
Task: ${task.description || 'Unknown task'}
Output:
${agentOutput.substring(0, 8000)}
Return JSON with memories array. Each memory should have:
-- type: fact|learning|observation|decision|preference
-- category: codebase|workflow|tools|architecture|patterns|conventions|preferences
-- content: the actual memory
-- confidence: 0.6-1.0
+- type: preference|decision|learning
+- category: values|workflow|preferences|communication|aesthetics|patterns
+- content: the actual memory about the user
+- confidence: 0.7-1.0
- tags: relevant tags
-- reasoning: why this is worth remembering
+- reasoning: what this reveals about the user
-Only include memories with genuine reusable value. Do not include:
-- Task echoes (e.g., "Task X was completed")
-- Generic summaries
-- Temporary or session-specific info
+DO NOT include:
+- Implementation details (file paths, function names, CSS values, component structures)
+- Architecture descriptions (easily discoverable from code)
+- Task completion summaries (that's git history)
+- Generic best practices any developer would know
+- One-time code observations or status assessments
+
+Most outputs should produce ZERO memories. Only extract when you observe something genuinely revealing about the user's values, preferences, or work patterns.
Return: {"memories": [...], "rejected": [...]}`;
}
@@ -200,15 +204,30 @@ function parseLLMResponse(response) {
return { memories: [], rejected: parsed.rejected || [], parseError: false };
}
- // Validate each memory
+ // Validate each memory — reject implementation details and low-value noise
const validMemories = parsed.memories.filter(m => {
if (!m.type || !m.content || typeof m.confidence !== 'number') return false;
- if (m.confidence < 0.6) return false;
- if (m.content.length < 10) return false;
+ if (m.confidence < 0.7) return false;
+ if (m.content.length < 15) return false;
// Reject obvious task echoes
if (/^Task\s+['"].*['"]\s*:/i.test(m.content)) return false;
- if (/was\s+(completed|successful|done)/i.test(m.content) && m.content.length < 50) return false;
+ if (/was\s+(completed|successful|done)/i.test(m.content) && m.content.length < 80) return false;
+
+ // Reject implementation details — file paths, function names, CSS values
+ if (/\.(jsx?|tsx?|css|json|md|py|sh|yml)\b/i.test(m.content) && m.type !== 'preference') return false;
+ if (/\b\d+px\b/.test(m.content)) return false;
+ if (/\b#[0-9a-f]{6}\b/i.test(m.content) && m.type !== 'preference') return false;
+ if (/\bport\s+\d{4}\b/i.test(m.content)) return false;
+
+ // Reject architecture descriptions (easily discoverable from code)
+ if (/\b(?:uses?\s+(?:express|react|vite|pm2|tailwind|socket\.io|zod))\b/i.test(m.content) && m.type === 'fact') return false;
+
+ // Reject positive status assessments (not memories)
+ if (/\b(?:no\s+issues?\s+found|well[- ]optimized|already\s+(?:has|implements)|no\s+(?:fixes?|changes?)\s+(?:required|needed))\b/i.test(m.content)) return false;
+
+ // Reject one-time observations about code state
+ if (/\b(?:imported?\s+but\s+(?:not\s+used|unused|never)|is\s+sized|has\s+\d+\s+lines?)\b/i.test(m.content)) return false;
return true;
});
diff --git a/server/services/memoryExtractor.js b/server/services/memoryExtractor.js
index 20716ffa2f..6258357acb 100644
--- a/server/services/memoryExtractor.js
+++ b/server/services/memoryExtractor.js
@@ -53,155 +53,84 @@ function parseMemoryBlocks(output) {
/**
* Extract implicit patterns from agent output
- * Looks for common patterns that indicate learnings/observations
+ * Focuses on user preferences and values — not implementation details
*/
function extractPatterns(output) {
const memories = [];
let match;
- // Pattern: "I learned that..." or "I discovered that..."
- const learnedRegex = /(?:I\s+)?(?:learned|discovered|found out|realized|noticed)\s+that\s+(.+?)(?:\.|$)/gi;
- while ((match = learnedRegex.exec(output)) !== null) {
- memories.push({
- type: 'learning',
- content: match[1].trim(),
- confidence: 0.6,
- category: 'other',
- tags: []
- });
- }
-
- // Pattern: "The codebase uses..." or "This project uses..."
- const usesRegex = /(?:The\s+)?(?:codebase|project|app|system)\s+uses\s+(.+?)(?:\.|$)/gi;
- while ((match = usesRegex.exec(output)) !== null) {
- memories.push({
- type: 'fact',
- content: `The codebase uses ${match[1].trim()}`,
- confidence: 0.7,
- category: 'codebase',
- tags: ['architecture']
- });
- }
-
- // Pattern: "User prefers..." or "The user wants..."
- const prefersRegex = /(?:The\s+)?user\s+(?:prefers|wants|likes|requested)\s+(.+?)(?:\.|$)/gi;
+ // Pattern: "User prefers..." or "The user wants..." or "User values..."
+ const prefersRegex = /(?:The\s+)?user\s+(?:prefers|wants|likes|requested|values|cares about|insists on|prioritizes|expects)\s+(.+?)(?:\.|$)/gi;
while ((match = prefersRegex.exec(output)) !== null) {
- memories.push({
- type: 'preference',
- content: `User prefers ${match[1].trim()}`,
- confidence: 0.8,
- category: 'preferences',
- tags: ['user-preference']
- });
- }
-
- // Pattern: "I decided to..." or "We should..."
- const decidedRegex = /(?:I\s+)?(?:decided|chose)\s+to\s+(.+?)\s+because\s+(.+?)(?:\.|$)/gi;
- while ((match = decidedRegex.exec(output)) !== null) {
- memories.push({
- type: 'decision',
- content: `Decided to ${match[1].trim()} because ${match[2].trim()}`,
- confidence: 0.7,
- category: 'workflow',
- tags: ['decision']
- });
- }
-
- // Pattern: "Note:" or "Important:"
- const noteRegex = /(?:Note|Important|Remember):\s*(.+?)(?:\.|$)/gi;
- while ((match = noteRegex.exec(output)) !== null) {
- memories.push({
- type: 'context',
- content: match[1].trim(),
- confidence: 0.65,
- category: 'other',
- tags: ['note']
- });
- }
-
- // Pattern: "No Issues Found" / "No issues detected" / "No fixes required"
- // High confidence - this is a clear finding that something is working well
- const noIssuesRegex = /\*\*(?:No\s+(?:Issues?|Problems?|Errors?|Bugs?)\s+Found|No\s+(?:fixes?|changes?)\s+(?:required|needed|necessary))\*\*/gi;
- if (noIssuesRegex.test(output)) {
- memories.push({
- type: 'observation',
- content: 'Analysis found no issues requiring fixes',
- confidence: 0.85,
- category: 'codebase',
- tags: ['audit-result', 'no-action-needed']
- });
- }
-
- // Pattern: "already well-optimized" / "already has excellent" / "already implemented"
- // Exclude colons to prevent truncated memories like "Already has excellent responsive design:"
- const alreadyWorkingRegex = /(?:already|currently)\s+(?:has\s+)?(?:excellent|good|great|proper|well[- ]?optimized|well[- ]?implemented|working\s+well|fully\s+implemented)\s+([^\n.:]+)/gi;
- while ((match = alreadyWorkingRegex.exec(output)) !== null) {
- const captured = match[1].trim();
- // Skip if capture is too short or empty
- if (captured.length < 5) continue;
- memories.push({
- type: 'fact',
- content: `Already has excellent ${captured}`,
- confidence: 0.85,
- category: 'codebase',
- tags: ['existing-feature', 'no-action-needed']
- });
- }
-
- // Pattern: Conclusion sections - extract the actual conclusion content
- const conclusionRegex = /#{1,3}\s*Conclusion\s*\n+(.+?)(?:\n\n|\n#|$)/gis;
- while ((match = conclusionRegex.exec(output)) !== null) {
- const conclusion = match[1].trim().replace(/\n/g, ' ').substring(0, 300);
- if (conclusion.length > 20) {
+ const content = match[1].trim();
+ // Only keep if substantive (not just a single word or implementation detail)
+ if (content.length >= 15 && !isImplementationDetail(content)) {
memories.push({
- type: 'learning',
- content: conclusion,
- confidence: 0.85,
- category: 'codebase',
- tags: ['conclusion', 'audit-result']
+ type: 'preference',
+ content: `User prefers ${content}`,
+ confidence: 0.8,
+ category: 'preferences',
+ tags: ['user-preference']
});
}
}
- // Pattern: "The application/UI/system is..." followed by positive assessment
- const assessmentRegex = /(?:The\s+)?(?:application|app|UI|system|codebase|code)\s+(?:is|has)\s+(?:already\s+)?(?:well[- ]?(?:optimized|designed|structured|implemented)|properly\s+(?:configured|set up)|fully\s+(?:functional|working))/gi;
- while ((match = assessmentRegex.exec(output)) !== null) {
- memories.push({
- type: 'observation',
- content: match[0].trim(),
- confidence: 0.8,
- category: 'codebase',
- tags: ['assessment', 'status']
- });
+ // Pattern: User pushed back on something (reveals values)
+ const pushbackRegex = /user\s+(?:pushed back on|rejected|didn't like|asked (?:us|me) to (?:change|redo|fix))\s+(.+?)(?:\.|$)/gi;
+ while ((match = pushbackRegex.exec(output)) !== null) {
+ const content = match[1].trim();
+ if (content.length >= 15 && !isImplementationDetail(content)) {
+ memories.push({
+ type: 'preference',
+ content: `User pushed back on: ${content}`,
+ confidence: 0.8,
+ category: 'values',
+ tags: ['user-feedback', 'values']
+ });
+ }
}
return memories;
}
/**
- * Extract task-related context
+ * Check if content is an implementation detail rather than a user insight
*/
-function extractTaskContext(task, output, success) {
- const memories = [];
+function isImplementationDetail(content) {
+ const lower = content.toLowerCase();
- if (success && task.description) {
- // Successful task completion - extract what was done
- const summary = output.length > 500 ? output.substring(0, 500) + '...' : output;
+ // File paths, function names, component references
+ if (/\.(jsx?|tsx?|css|json|md|py|sh|yml)\b/i.test(content)) return true;
+ if (/(?:function|class|component|const|import|export|require)\s/i.test(content)) return true;
- // Look for completion summary at end of output
- const summaryMatch = output.match(/(?:Summary|Done|Completed):\s*(.+?)(?:\n\n|$)/is);
- if (summaryMatch) {
- memories.push({
- type: 'learning',
- content: `Task "${task.description.substring(0, 100)}": ${summaryMatch[1].trim()}`,
- confidence: 0.75,
- category: 'workflow',
- tags: ['task-completion']
- });
- }
- }
+ // Specific code references (line numbers, variable names with dots)
+ if (/\b(?:line\s+\d+|\.js\b|\.ts\b)/i.test(content)) return true;
+ if (/[a-z]+\.[a-z]+\(/i.test(content)) return true;
- return memories;
+ // CSS/styling specifics
+ if (/\b(?:\d+px|#[0-9a-f]{3,8}|p[xytblr]-\d|sm:|md:|lg:)\b/i.test(content)) return true;
+
+ // Package/dependency names
+ if (/\b(?:npm|yarn|package\.json|node_modules|import\s+\{)\b/i.test(content)) return true;
+
+ // Port numbers, URLs, endpoints
+ if (/(?:port\s+\d{4}|localhost|\/api\/|endpoint)/i.test(content)) return true;
+
+ // Architecture descriptions (easily discoverable)
+ if (/\b(?:uses?\s+(?:express|react|vite|pm2|socket\.io|zod))\b/i.test(lower)) return true;
+ if (/\b(?:monorepo|middleware|route\s+handler|service\s+layer)\b/i.test(lower)) return true;
+
+ return false;
+}
+
+/**
+ * Extract task-related context
+ * Only extracts if the output reveals something about user preferences
+ */
+function extractTaskContext(_task, _output, _success) {
+ // Task completion summaries are not useful memories — they're git history.
+ // Only the LLM classifier should extract user-insight memories from task output.
+ return [];
}
/**
@@ -293,9 +222,9 @@ export async function extractAndStoreMemories(agentId, taskId, output, task = nu
// Deduplicate
const unique = deduplicateMemories(allMemories);
- // Filter by confidence
- const highConfidence = unique.filter(m => m.confidence >= 0.8);
- const mediumConfidence = unique.filter(m => m.confidence >= 0.5 && m.confidence < 0.8);
+ // Filter by confidence — only high-quality memories pass through
+ const highConfidence = unique.filter(m => m.confidence >= 0.85);
+ const mediumConfidence = unique.filter(m => m.confidence >= 0.7 && m.confidence < 0.85);
const created = [];