diff --git a/CHANGELOG.md b/CHANGELOG.md index 74b74a958..4d5c93b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - Memory: add vector search for agent memories (Markdown-only scope) with SQLite index, chunking, lazy sync + file watch, and per-agent enablement/fallback. ### Changes +- Agents: strengthen memory recall guidance (memory_search mandatory for past work/preferences; system prompt injects conditional recall section; memory_get now described as safe snippet fetch). - Browser: add `scrollintoview` action to scroll refs into view before click/type. - Memory: embedding providers support OpenAI or local `node-llama-cpp`; config adds defaults + per-agent overrides, provider/fallback metadata surfaced in tools/CLI. - CLI/Tools: new `clawdbot memory` commands plus `memory_search`/`memory_get` tools returning snippets + line ranges and provider info. diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index d71fad490..522c38cfc 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -183,6 +183,14 @@ export function buildAgentSystemPrompt(params: { "", ] : []; + const memorySection = + availableTools.has("memory_search") || availableTools.has("memory_get") + ? [ + "## Memory Recall", + "Before answering anything about prior work, decisions, dates, people, preferences, or todos: run memory_search on MEMORY.md + memory/*.md; then use memory_get to pull only the needed lines. If low confidence after search, say you checked.", + "", + ] + : []; const lines = [ "You are a personal assistant running inside Clawdbot.", @@ -212,6 +220,7 @@ export function buildAgentSystemPrompt(params: { "If a task is more complex or takes longer, spawn a sub-agent. It will do the work for you and ping you when it's done. You can always check up on it.", "", ...skillsSection, + ...memorySection, hasGateway ? "## Clawdbot Self-Update" : "", hasGateway ? [ diff --git a/src/agents/tools/memory-tool.ts b/src/agents/tools/memory-tool.ts index de2b0251b..a3fc80484 100644 --- a/src/agents/tools/memory-tool.ts +++ b/src/agents/tools/memory-tool.ts @@ -34,7 +34,7 @@ export function createMemorySearchTool(options: { label: "Memory Search", name: "memory_search", description: - "Search agent memory files (MEMORY.md + memory/*.md) using semantic vectors.", + "Mandatory recall step: semantically search MEMORY.md + memory/*.md before answering questions about prior work, decisions, dates, people, preferences, or todos; returns top snippets with path + lines.", parameters: MemorySearchSchema, execute: async (_toolCallId, params) => { const query = readStringParam(params, "query", { required: true }); @@ -77,7 +77,8 @@ export function createMemoryGetTool(options: { return { label: "Memory Get", name: "memory_get", - description: "Read a memory file by path (workspace-relative).", + description: + "Safe snippet read from MEMORY.md or memory/*.md with optional from/lines; use after memory_search to pull only the needed lines and keep context small.", parameters: MemoryGetSchema, execute: async (_toolCallId, params) => { const relPath = readStringParam(params, "path", { required: true });