A local-first multi-agent app development platform, built on PenguinHarness
feat(core,docs): the memory prompt names when a fact is worth saving (#397)
Yaowei Zheng956b05987be9
diff --git a/changelog/unreleased/2026-08-21-memory-save-signals.md b/changelog/unreleased/2026-08-21-memory-save-signals.mdnew file mode 100644index 00000000..bc3c1474--- /dev/null+++ b/changelog/unreleased/2026-08-21-memory-save-signals.md@@ -0,0 +1,38 @@+# Memory prompt names when to save++- **Date:** 2026-08-21+- **Type:** feature+- **Scope:** `core`, `docs`+- **PR:** [#397](https://github.com/Prism-Shadow/penguin-harness/pull/397)++[中文版](2026-08-21-memory-save-signals.zh.md)++The built-in `memory.prompt` said what is worth saving but not when to notice it, leaving the+judgement entirely to the model. It now names the moments that produce a durable fact:++- the user asks for the same thing again, or corrects a result in a way that holds beyond the+ current task — what they wanted instead is saved, with the why;+- a habit, convention or development practice stated more than once;+- a reusable working detail handed over that the Agent would otherwise have to ask for again — a+ service endpoint, a ticket or repository identifier, a preferred toolchain. The prompt's standing+ prohibition on credentials and personal data is restated at the signal, since the examples are+ the shape most likely to attract one.++A repeat is called a strong signal rather than a requirement, so one clear statement of a standing+preference still qualifies; when the Agent cannot tell whether something is worth keeping, it is+told to ask in the conversation.++## Details++- The prohibitions no longer name task progress, credentials or personal data. They are things a user sometimes does want kept, and a blanket refusal made the Agent argue with a direct request. What stays barred is what memory cannot usefully hold — facts the code, config or Git history already states, unconfirmed guesses, transcript excerpts. The visibility line stays as a fact rather than a rule: anyone who can reach the Agent reads all of it, which is what a user needs to know before asking for something sensitive to be saved.++- The block was tightened while the guidance went in: what to save, when, what never to, and the index rules are now four labelled lines rather than dense paragraphs. Despite carrying the new signals, the whole prompt is slightly shorter than it was before this change (1739 → 1719 characters), so no session pays for the addition.++- The prompt is a kernel-managed config leaf. The `2026-08-21` generation's `memory.prompt` hash was+ revised in place rather than appended to, that generation having shipped in no release. The five+ frozen older generations keep their previous hashes, so an Agent whose stored prompt is still an+ old default is recognized as such and advanced by the kernel update. An Agent whose prompt was+ edited by hand keeps that edit and does not receive the new guidance; the only way to adopt it is Agent settings → Kernel → Restore+ default configuration, which replaces the whole config and is not scoped to the prompt.+- The Configuration guide's Memory chapter gained one sentence covering the same ground, in both+ languages.diff --git a/changelog/unreleased/2026-08-21-memory-save-signals.zh.md b/changelog/unreleased/2026-08-21-memory-save-signals.zh.mdnew file mode 100644index 00000000..d42e7bc8--- /dev/null+++ b/changelog/unreleased/2026-08-21-memory-save-signals.zh.md@@ -0,0 +1,26 @@+# 记忆提示词明确了何时保存++- **Date:** 2026-08-21+- **Type:** feature+- **Scope:** `core`, `docs`+- **PR:** [#397](https://github.com/Prism-Shadow/penguin-harness/pull/397)++[English](2026-08-21-memory-save-signals.md)++内置 `memory.prompt` 原本只说了什么值得保存,没有说什么时候该注意到它,判断完全交给模型。现在它点明了产生长期事实的时机:++- 用户再次提出同一诉求,或以超出当前任务的方式纠正某项结果——保存他们真正想要的做法,连同原因;+- 反复讲到的习惯、约定或开发实践;+- 交代过一次、否则还要再问一遍的可复用工作信息——服务地址、工单或仓库标识、惯用工具链。提示词在该+ 信号处重申了凭据与个人信息的禁令,因为这类例子最容易把它们带进来。++「重复」被写成强信号而非硬性条件,因此长期偏好只讲一次同样成立;拿不准是否值得记住时,提示词要求 agent 在对话里直接询问用户。++## 细节++- 禁止清单不再点名任务进度、凭据与个人信息。这些有时正是用户希望记下来的内容,一刀切的禁止只会让 Agent 与明确的请求较劲。仍然禁止的是记忆本就不该承载的东西——代码、配置或 Git 历史已经说明的事实、未经确认的推测、大段对话原文。可见性那句保留为事实而非规则:能接触到该 Agent 的人都能读到全部内容,用户在要求保存敏感内容之前需要知道这一点。++- 补充这段指引的同时也把整段收紧了:保存什么、何时保存、绝不保存什么、索引规范,改为四行带标签的条目,不再是几段密集的长文。虽然多了这段信号说明,整段提示词仍略短于改动之前(1739 → 1719 字符),不会让每个 Session 为此多付开销。++- 该提示词是受 kernel 管理的配置叶子。`2026-08-21` 这一代的 `memory.prompt` 哈希就地修订——该代未随任何版本发布;此前五代已冻结的哈希保持不变,因此存量 Agent 若仍是旧版默认值会被识别出来并由 kernel 更新推进。手工改过提示词的 Agent 保留自己的版本,不会拿到这段新内容;唯一的采用方式是 Agent 设置 → Kernel → 恢复默认配置,它会整体覆盖配置,并非只针对该提示词。+- 配置说明的记忆章节同步补了一句同样口径的说明,中英各一处。diff --git a/packages/core/src/state/default-config.ts b/packages/core/src/state/default-config.tsindex 8040d02e..d4b575bf 100644--- a/packages/core/src/state/default-config.ts+++ b/packages/core/src/state/default-config.ts@@ -227,7 +227,7 @@ export const MEMORY_INDEX_MAX_CHARS = 25_000;* index itself.*/export const DEFAULT_MEMORY_PROMPT = `# Memory-Your long-term record across sessions: Markdown files you maintain with the file tools, in the memory directories named below (they already exist). One file per fact, with frontmatter:+Your long-term record across sessions: Markdown files you maintain with the file tools, in the directories below (they exist). One file per fact, with frontmatter:\`\`\`markdown---@@ -236,12 +236,16 @@ description: <one line — used to decide relevance during recall>updated_at: <YYYY-MM-DD>----<the fact; for corrections and decisions add **Why:** and **How to apply:** lines. Link related memories with [[their-name]] — a name that doesn't exist yet is fine. Write dates absolute.>+<the fact; for corrections and decisions add **Why:** and **How to apply:** lines. Link with [[their-name]] — a name that doesn't exist yet is fine. Dates absolute.>\`\`\`-Worth saving: who the user is (role, expertise, preferences) and how they want you to work, with the why; ongoing work, goals and constraints not derivable from the code; pointers to external resources.+**Save** who the user is and how they want you to work, with the why; goals and constraints not derivable from the code; pointers to external resources.-Each directory's \`MEMORY.md\` is its index, injected below: one line per memory, under ~150 characters (\`- [Title](file.md) — hook\`), no content, updated in the same round as the file — deletions included. Only the first ${MEMORY_INDEX_MAX_LINES} lines of an index are injected — keep it well under that: merge overlapping entries, drop stale ones, move detail into the topic files. Before saving, check the index and update the file that already covers the subject instead of duplicating; delete memories that prove wrong. Never save what code, config or git history already states, task progress, secrets, unconfirmed guesses, or transcript excerpts — if asked to, save the non-obvious part instead. Memory is readable by everyone who can reach this agent: no sensitive personal data.+**When:** a request repeated, a correction that outlives the task (with what they wanted instead), a habit or convention stated more than once, a reusable working detail you would otherwise ask for again. One clear statement is enough; a repeat only makes it obvious. Unsure? Ask.++**Never** what code, config or git history states, unconfirmed guesses, transcript excerpts — asked anyway, save the non-obvious part. Anything else is savable if the user wants it; anyone who reaches this agent reads it all.++**Index:** each \`MEMORY.md\` lists its memories one line each (\`- [Title](file.md) — hook\`, ~150 chars, no content), updated with the file — deletions included. Only the first ${MEMORY_INDEX_MAX_LINES} lines are injected: merge overlaps, drop stale entries. Before saving, check the index and extend the file that covers the subject; delete memories that prove wrong.## User memoryWhat holds wherever you work; every one of your sessions reads it.diff --git a/packages/core/src/state/kernel-history.ts b/packages/core/src/state/kernel-history.tsindex 5d2736f5..dde68eb2 100644--- a/packages/core/src/state/kernel-history.ts+++ b/packages/core/src/state/kernel-history.ts@@ -345,7 +345,7 @@ export const KERNEL_HASH_HISTORY: Readonly<Record<string, Readonly<Record<string"compaction.mode": "e58fac0b4b9c0f29b3d224da119dff5f6517a40d139faf92e309705b98bd410a","compaction.prompt": "8ed55781e8071083f8246ed70d9e063ee729d3872d5bc6a2bedfa9c99aed6ae5","memory.enabled": "b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b",- "memory.prompt": "9380e2382e5dd3d37a6470b0bc0d27c9ed113fa9a54ff78122784c57a16b992c",+ "memory.prompt": "be1a8733b5d23afb11af3086b369105d42b7209edce6749eed31c4dbede9beff","memory.workspace_prompt": "76c5a8e18a568f471593ef1da6d75d2596f27619cb877703b2dd28bb0554e0d5","vault.enabled": "b5bea41b6c623f7c09f1bf24dcae58ebab3c0cdd90ad966bc43a45b44867e12b","vault.prompt": "66e607aa4e205413f1816a677bed31af2d8c24218e71b55adba54aff5aa094ce",diff --git a/packages/docs/content/configuration.en.md b/packages/docs/content/configuration.en.mdindex e280db33..2dd4174b 100644--- a/packages/docs/content/configuration.en.md+++ b/packages/docs/content/configuration.en.md@@ -276,7 +276,7 @@ updated_at: 2026-08-07- Integration tests connect to a real database; no mock repositories.```-These three fields are all the frontmatter there is — which layer a memory belongs to is expressed by its directory, so there is no `type` field (a `type:` line left in an earlier file is ignored as an unknown field). Worth saving: who the user is (role, expertise, standing preferences) and how they want the Agent to work, with the why; decisions, constraints and plans not derivable from the code; stable entry points into external systems, documents and services. A topic that turns out to be wrong is deleted together with its index line, and dates are written absolute (`YYYY-MM-DD`) — relative ones mean nothing to a later Session. What must never be saved: facts the code, config or Git history already states; short-lived task progress and debugging notes; credentials, tokens or secrets; unconfirmed guesses; long transcript excerpts.+These three fields are all the frontmatter there is — which layer a memory belongs to is expressed by its directory, so there is no `type` field (a `type:` line left in an earlier file is ignored as an unknown field). Worth saving: who the user is (role, expertise, standing preferences) and how they want the Agent to work, with the why; decisions, constraints and plans not derivable from the code; stable entry points into external systems, documents and services. The prompt also names the moments that produce such a fact — a request made a second time, a correction that holds beyond the current task, a habit or development practice stated more than once, or a reusable working detail handed over that the Agent would otherwise ask for again. A repeat is a strong signal rather than a condition, so one clear statement of a standing preference is enough; when the Agent cannot tell whether something is worth keeping, it asks in the conversation. A topic that turns out to be wrong is deleted together with its index line, and dates are written absolute (`YYYY-MM-DD`) — relative ones mean nothing to a later Session. What must never be saved: facts the code, config or Git history already states; short-lived task progress and debugging notes; credentials, tokens or secrets; unconfirmed guesses; long transcript excerpts.Each `MEMORY.md` lists its scope's memories one line each — `- [Title](file.md) — hook`, links relative to the scope directory — and is updated in the same round as the file, so the two never disagree.diff --git a/packages/docs/content/configuration.zh.md b/packages/docs/content/configuration.zh.mdindex 0730b0dc..c657df20 100644--- a/packages/docs/content/configuration.zh.md+++ b/packages/docs/content/configuration.zh.md@@ -276,7 +276,7 @@ updated_at: 2026-08-07- 集成测试必须连接真实数据库,不使用 mock repository。```-frontmatter 只有这三个字段——记忆属于哪一层由所在目录表达,不设 `type` 字段(早期文件里残留的 `type:` 行会被当作未知字段忽略)。值得保存的是:用户是谁(角色、专长、长期偏好)以及希望 agent 如何工作(连同原因);无法仅从代码推导的决策、约束与计划;外部系统、文档与服务的稳定入口。记错的主题连同其索引行一并删除;日期写绝对日期(`YYYY-MM-DD`),相对日期对后续 Session 没有意义。不应保存:可从代码、配置或 Git 历史直接获得的事实;短期任务进度与调试流水;凭据、Token 等敏感值;未经确认的推测;大段对话原文。+frontmatter 只有这三个字段——记忆属于哪一层由所在目录表达,不设 `type` 字段(早期文件里残留的 `type:` 行会被当作未知字段忽略)。值得保存的是:用户是谁(角色、专长、长期偏好)以及希望 agent 如何工作(连同原因);无法仅从代码推导的决策、约束与计划;外部系统、文档与服务的稳定入口。提示词还点明了这类事实出现的时机——同一诉求被再次提出、以超出当前任务的方式纠正某项结果、反复讲到的习惯或开发实践、以及交代过一次、否则还要再问一遍的可复用工作信息。「重复」是强信号而非硬性条件,长期偏好只讲一次同样成立;拿不准是否值得记住时,agent 会在对话里直接询问用户。记错的主题连同其索引行一并删除;日期写绝对日期(`YYYY-MM-DD`),相对日期对后续 Session 没有意义。不应保存:可从代码、配置或 Git 历史直接获得的事实;短期任务进度与调试流水;凭据、Token 等敏感值;未经确认的推测;大段对话原文。每份 `MEMORY.md` 一行列一条记忆——`- [标题](file.md) — 一句钩子`,链接相对本作用域目录——并与记忆文件同轮更新,两者永不脱节。