feat(scheduler): generate unique memory update files per run to avoid merge conflicts

- Modified `scripts/agent/run-scheduler-cycle.mjs` to generate a unique `memory-updates/<timestamp>__<agent>.md` path and pass it via `SCHEDULER_MEMORY_FILE` env var.
- Updated `scripts/memory/store.mjs` to prioritize `SCHEDULER_MEMORY_FILE` for ingestion.
- Updated `src/prompts/scheduler-flow.md` to instruct agents to write to the unique memory file.
- Updated `src/prompts/daily/torch-garbage-collection-agent.md` to include `memory-updates/*.md` in the cleanup scope.
- Moved existing `memory-update.md` to `memory-updates/legacy-memory-update-<timestamp>.md` to clear the root.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-17 15:19:52 +00:00
1 parent b8827be83c
commit 2a39713189
6 files changed
+39 -25

No files matched your search

+15 -3
View File
@@ -900,9 +900,21 @@ async function main() {
const runStartMs = Date.parse(runArtifactSince);
const outputChunks = [];
const memoryDir = path.resolve(process.cwd(), 'memory-updates');
await fs.mkdir(memoryDir, { recursive: true });
const memoryFile = path.join(memoryDir, `${ts()}__${selectedAgent}.md`);
const schedulerEnv = {
AGENT_PLATFORM: platform,
...(model ? { AGENT_MODEL: model } : {}),
SCHEDULER_AGENT: selectedAgent,
SCHEDULER_CADENCE: cadence,
SCHEDULER_PROMPT_PATH: promptPath,
SCHEDULER_MEMORY_FILE: memoryFile,
};
if (schedulerConfig.memoryPolicy.retrieveCommand) {
const retrieveResult = await runCommand('bash', ['-lc', schedulerConfig.memoryPolicy.retrieveCommand], {
env: { AGENT_PLATFORM: platform, ...(model ? { AGENT_MODEL: model } : {}), SCHEDULER_AGENT: selectedAgent, SCHEDULER_CADENCE: cadence, SCHEDULER_PROMPT_PATH: promptPath },
env: schedulerEnv,
});
outputChunks.push(retrieveResult.stdout, retrieveResult.stderr);
if (retrieveResult.code !== 0) {
@@ -921,7 +933,7 @@ async function main() {
if (schedulerConfig.handoffCommand) {
const handoff = await runCommand('bash', ['-lc', schedulerConfig.handoffCommand], {
env: { AGENT_PLATFORM: platform, ...(model ? { AGENT_MODEL: model } : {}), SCHEDULER_AGENT: selectedAgent, SCHEDULER_CADENCE: cadence, SCHEDULER_PROMPT_PATH: promptPath },
env: schedulerEnv,
});
outputChunks.push(handoff.stdout, handoff.stderr);
if (handoff.code !== 0) {
@@ -954,7 +966,7 @@ async function main() {
if (schedulerConfig.memoryPolicy.storeCommand) {
const storeResult = await runCommand('bash', ['-lc', schedulerConfig.memoryPolicy.storeCommand], {
env: { AGENT_PLATFORM: platform, ...(model ? { AGENT_MODEL: model } : {}), SCHEDULER_AGENT: selectedAgent, SCHEDULER_CADENCE: cadence, SCHEDULER_PROMPT_PATH: promptPath },
env: schedulerEnv,
});
outputChunks.push(storeResult.stdout, storeResult.stderr);
if (storeResult.code !== 0) {
+13 -13
View File
@@ -34,21 +34,21 @@ let memoryContent = '';
const cliArgs = process.argv.slice(2);
const fileArgIndex = cliArgs.indexOf('--file');
const explicitFile = fileArgIndex !== -1 ? cliArgs[fileArgIndex + 1] : null;
const envFile = process.env.SCHEDULER_MEMORY_FILE;
const defaultFile = 'memory-update.md';
if (explicitFile && existsSync(explicitFile)) {
const targetFile = explicitFile || (envFile && existsSync(envFile) ? envFile : (existsSync(defaultFile) ? defaultFile : null));
if (targetFile) {
try {
memoryContent = readFileSync(explicitFile, 'utf8').trim();
console.log(`Loaded memory content from ${explicitFile}`);
if (existsSync(targetFile)) {
memoryContent = readFileSync(targetFile, 'utf8').trim();
console.log(`Loaded memory content from ${targetFile}`);
} else {
console.warn(`Target memory file does not exist: ${targetFile}`);
}
} catch (err) {
console.warn(`Failed to read memory file ${explicitFile}:`, err.message);
}
} else if (!explicitFile && existsSync(defaultFile)) {
try {
memoryContent = readFileSync(defaultFile, 'utf8').trim();
console.log(`Loaded memory content from default file ${defaultFile}`);
} catch (err) {
console.warn(`Failed to read default memory file ${defaultFile}:`, err.message);
console.warn(`Failed to read memory file ${targetFile}:`, err.message);
}
}
@@ -70,7 +70,7 @@ if (memoryContent) {
});
} else {
// Fallback if no file provided (preserve existing behavior for compatibility)
console.warn('No memory input found (checked --file or default memory-update.md). using fallback placeholder.');
console.warn(`No memory input found (checked --file, env SCHEDULER_MEMORY_FILE=${envFile}, or default ${defaultFile}). using fallback placeholder.`);
events = [
{
agent_id: agentId,
@@ -120,7 +120,7 @@ try {
promptPath,
promptIntent,
events: events.length,
sourceFile: explicitFile || (memoryContent ? defaultFile : 'fallback')
sourceFile: targetFile || 'fallback'
},
outputs: {
storedCount: stored.length,