mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 07:51:52 +00:00
fix(memory): close the content gap so agents can actually write and retrieve learnings
- run-selected-prompt.mjs: set SCHEDULER_MEMORY_FILE env var before spawning each agent so store.mjs has a well-known path to read from (memory-updates/<ts>__<agent>.md) - retrieve.mjs: format memories.md using m.summary + date/tags in readable markdown sections instead of raw m.content blobs; agents can now scan injected context at a glance - store.mjs: remove semantically-empty fallback placeholder events that polluted the store and degraded retrieval quality; also fix default cadence 'weekly' -> 'daily' to match retrieve - scheduler-flow.md: replace vague "write insights" instruction with a concrete three-section template (Key findings / Patterns / Warnings) and clarify that $SCHEDULER_MEMORY_FILE is set by the scheduler automatically Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
1 parent
87d6b3ef0c
commit
8a9080e7c3
4 files changed
+39
-32
No files matched your search
@@ -84,7 +84,17 @@ try {
|
||||
writeFileSync(path.join(sessionDir, 'retrieve.json'), JSON.stringify(artifact, null, 2));
|
||||
writeFileSync(path.join(sessionDir, 'retrieve.ok'), 'MEMORY_RETRIEVED\n');
|
||||
writeFileSync(path.join(latestDir, 'retrieve.ok'), 'MEMORY_RETRIEVED\n');
|
||||
writeFileSync(path.join(latestDir, 'memories.md'), retrieved.map(m => `- ${m.content}`).join('\n'));
|
||||
// Format retrieved memories as readable markdown sections.
|
||||
// Prefer m.summary (compact excerpt) over m.content (full blob) for prompt injection.
|
||||
const memoriesMarkdown = retrieved.length > 0
|
||||
? retrieved.map((m, i) => {
|
||||
const date = new Date(m.created_at || m.last_seen || Date.now()).toISOString().split('T')[0];
|
||||
const tagStr = Array.isArray(m.tags) && m.tags.length > 0 ? m.tags.join(', ') : '';
|
||||
const text = (m.summary || m.content || '').trim();
|
||||
return `### ${i + 1}. [${date}]${tagStr ? ` (${tagStr})` : ''}\n\n${text}`;
|
||||
}).join('\n\n---\n\n')
|
||||
: '_No memories found for this agent. This may be the first run or the memory store is empty._';
|
||||
writeFileSync(path.join(latestDir, 'memories.md'), memoriesMarkdown);
|
||||
|
||||
// 5. Output success marker to stdout (for scheduler verification)
|
||||
console.log('MEMORY_RETRIEVED');
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
// Parse environment variables
|
||||
const fallbackCadence = 'weekly';
|
||||
const fallbackCadence = 'daily';
|
||||
const cadence = process.env.SCHEDULER_CADENCE || fallbackCadence;
|
||||
const agentId = process.env.SCHEDULER_AGENT || `scheduler-memory-${cadence}`;
|
||||
const promptPath = process.env.SCHEDULER_PROMPT_PATH || '';
|
||||
@@ -69,34 +69,9 @@ if (memoryContent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Fallback if no file provided (preserve existing behavior for compatibility)
|
||||
console.warn(`No memory input found (checked --file, env SCHEDULER_MEMORY_FILE=${envFile}, or default ${defaultFile}). using fallback placeholder.`);
|
||||
events = [
|
||||
{
|
||||
agent_id: agentId,
|
||||
content: `Store memory event A for ${cadence} :: ${promptIntent}`,
|
||||
timestamp: baseTs,
|
||||
tags: ['scheduler', cadence, 'store'],
|
||||
metadata: {
|
||||
session_id: runId,
|
||||
source: 'scheduler-store',
|
||||
importance: 0.55,
|
||||
prompt_path: promptPath
|
||||
}
|
||||
},
|
||||
{
|
||||
agent_id: agentId,
|
||||
content: `Store memory event B for ${cadence} :: ${promptIntent}`,
|
||||
timestamp: baseTs + 1,
|
||||
tags: ['scheduler', cadence, 'store'],
|
||||
metadata: {
|
||||
session_id: runId,
|
||||
source: 'scheduler-store',
|
||||
importance: 0.55,
|
||||
prompt_path: promptPath
|
||||
}
|
||||
}
|
||||
];
|
||||
// No memory file found — skip ingest rather than storing meaningless placeholder events.
|
||||
// Placeholder events pollute the store and degrade retrieval quality on future runs.
|
||||
console.warn(`No memory input found (checked --file, env SCHEDULER_MEMORY_FILE=${envFile}, and default ${defaultFile}). Skipping ingest.`);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -120,7 +95,7 @@ try {
|
||||
promptPath,
|
||||
promptIntent,
|
||||
events: events.length,
|
||||
sourceFile: targetFile || 'fallback'
|
||||
sourceFile: targetFile || 'none'
|
||||
},
|
||||
outputs: {
|
||||
storedCount: stored.length,
|
||||
|
||||
Reference in new issue
Block a user