From 44884cc0c06eec4a1dbcb4c0982196c0f9530718 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 02:50:46 +0000 Subject: [PATCH] Make memory system usable by agents via file-based I/O Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- scripts/memory/store.mjs | 99 +++++++++++++++++++++++++---------- src/prompts/scheduler-flow.md | 4 ++ 2 files changed, 75 insertions(+), 28 deletions(-) diff --git a/scripts/memory/store.mjs b/scripts/memory/store.mjs index fcc851f..7151510 100644 --- a/scripts/memory/store.mjs +++ b/scripts/memory/store.mjs @@ -1,5 +1,5 @@ import { ingestEvents } from '../../src/services/memory/index.js'; -import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs'; import path from 'node:path'; // Parse environment variables @@ -29,33 +29,75 @@ if (promptPath) { } } -const baseTs = Date.now(); -const 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 - } +// Check for memory input file +let memoryContent = ''; +const cliArgs = process.argv.slice(2); +const fileArgIndex = cliArgs.indexOf('--file'); +const explicitFile = fileArgIndex !== -1 ? cliArgs[fileArgIndex + 1] : null; +const defaultFile = 'memory-update.md'; + +if (explicitFile && existsSync(explicitFile)) { + try { + memoryContent = readFileSync(explicitFile, 'utf8').trim(); + console.log(`Loaded memory content from ${explicitFile}`); + } 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); + } +} + +const baseTs = Date.now(); +let events = []; + +if (memoryContent) { + events.push({ + agent_id: agentId, + content: memoryContent, + timestamp: baseTs, + tags: ['scheduler', cadence, 'store', 'insight'], + metadata: { + session_id: runId, + source: 'agent-output', + importance: 0.8, // User-provided memory is important + prompt_path: promptPath + } + }); +} 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.'); + 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 + } + } + ]; +} try { // 1. Ingest events @@ -77,7 +119,8 @@ try { agentId, promptPath, promptIntent, - events: events.length + events: events.length, + sourceFile: explicitFile || (memoryContent ? defaultFile : 'fallback') }, outputs: { storedCount: stored.length, diff --git a/src/prompts/scheduler-flow.md b/src/prompts/scheduler-flow.md index 56f48e2..36ff7ba 100644 --- a/src/prompts/scheduler-flow.md +++ b/src/prompts/scheduler-flow.md @@ -36,9 +36,13 @@ Every agent prompt invoked by the schedulers (daily/weekly) MUST enforce this co - Retrieval command MUST write cadence-scoped evidence artifacts: - `.scheduler-memory/retrieve-.ok` - `.scheduler-memory/retrieve-.json` containing operation inputs/outputs (`agentId`, `query`, seeded event count, ingested count, retrieved count). + - **Agent Action**: Review `.scheduler-memory/latest//memories.md` for relevant context. + 5. **Store memory after implementation and before completion publish**: + - **Agent Action**: Write any new insights, learnings, or patterns to `memory-update.md`. - Run configured memory storage workflow after prompt execution (for example via `scheduler.memoryPolicyByCadence..storeCommand`) - Storage command MUST call real memory services (`src/services/memory/index.js#ingestEvents`, which uses ingestor/summarizer pipeline) and MUST emit deterministic marker `MEMORY_STORED`. + - Storage command MUST ingest content from `memory-update.md` if present. - Storage command MUST write cadence-scoped evidence artifacts: - `.scheduler-memory/store-.ok` - `.scheduler-memory/store-.json` containing operation inputs/outputs (`agentId`, input event count, stored count, generated summaries).