n8n
Version:
n8n Workflow Automation Tool
2 lines (1 loc) • 3.62 kB
TypeScript
export declare const MEMORY_PROMPT = "## Memory Guidance\n\n### Purpose\n\nUse this to configure the target agent's memory behavior.\n\n### Workflow\n\nFresh agents must include this default memory config unless the user explicitly asks to disable or change memory:\n```json\n{\n \"enabled\": true,\n \"storage\": \"n8n\",\n \"observationalMemory\": {\n \"enabled\": true\n }\n}\n```\n\nThis is the configurable agent's session memory. The runtime-managed\n`observationalMemory` settings tune that memory behavior; they are not a\nseparate user-facing memory product.\n\n### Rules\n\n- When creating a new agent, always write the exact default `memory` object above.\n- Set `storage` to \"n8n\".\n- Set `observationalMemory.enabled` to `true` for new agents unless the user explicitly asks to disable observational memory.\n- Keep the rest of `observationalMemory` optional; add tuning fields only for explicit tuning or disabling.\n- Supported observational memory tuning fields: `enabled`, `observerModel`, `reflectorModel`, `observerThresholdTokens`, `reflectorThresholdTokens`, `renderTokenBudget`, `observationLogTailLimit`, and `lockTtlMs`.\n- Memory worker model fields must use object shape: `{ \"model\": \"provider/model-name\", \"credential\": \"<credentialId>\" }`.\n- Only set `observerModel`, `reflectorModel`, `extractorModel`, or `episodicMemory.reflectorModel` when the user explicitly asks to use a specific model for memory work.\n- Use only credential IDs returned by `resolve_llm`, `ask_llm`, or `ask_credential` for memory worker model fields. Do not invent IDs or copy a main-model credential unless one of those tools returned it for that worker model provider.\n\n### Episodic Memory\n\n- Enable `memory.episodicMemory` only when the user asks for Episodic Memory, long-term memory, prior conversations, remembered decisions, exact artifacts, or cross-session memory.\n- Before enabling it, call `ask_credential({ credentialType: \"openAiApi\", purpose: \"OpenAI credential for Episodic Memory embeddings\" })`.\n- On success, set `memory.episodicMemory = { \"enabled\": true, \"credential\": \"<credentialId>\" }` and preserve existing `topK` or `maxEntriesPerRun`.\n- `memory.episodicMemory.credential` is only for OpenAI embeddings. It is separate from optional `extractorModel` and `reflectorModel` worker credentials.\n- If credential selection is skipped, do not enable Episodic Memory; explain that it needs an OpenAI credential for embeddings.\n- Do not add instructions saying the agent should remember, store, save, or decide what context matters. The runtime handles memory extraction and indexing.\n- If instructions mention Episodic Memory, phrase it as retrieval/use only, e.g. \"Use recalled prior context when relevant to the user's request.\"\n- Do not invent Episodic Memory credential IDs or reuse the main model credential unless `ask_credential` returned it for this purpose.\n\n### Gotchas\n\n- Session memory and Episodic Memory are different features; do not use one as a substitute for the other.\n- Observational memory is runtime-managed session memory behavior; do not add target-agent instructions telling it how to save observations.\n- A skipped Episodic Memory credential means Episodic Memory stays disabled.\n\n### Verify\n\n- Fresh runnable agents have enabled n8n memory unless explicitly disabled.\n- Fresh runnable agents set `observationalMemory.enabled` to `true` unless explicitly disabled.\n- Episodic Memory has an OpenAI credential returned by `ask_credential`.\n- Existing memory tuning is preserved unless the user asked to change it.";