prompt(memory): tighten memoryExtractor against transient snapshots + role-name filenames - #8
Merged
Merged
Conversation
… role-name filenames The 2026-05-20 dogfood (Bug 3) found memoryExtractor over-producing: one night's memory tree held 113 files, including ~24 timestamped status / progress snapshots saved as permanent type:project entries, and files whose names leaked the producing role (webSearcher/generalist-*.md, generalist/generalist-*.md). Root cause was the prompt itself. It explicitly said "DO save ... ongoing-work status", directly inducing the snapshots, while the adjacent "temporary task context" exclusion contradicted it. Filename guidance was just "concise kebab/snake-case" with nothing about provenance. Three prompt changes: - New "What counts as durable" section with a concrete test — "would this entry be wrong or useless an hour from now?" — and an explicit Skip list for point-in-time status / progress snapshots. Replaces the contradictory "ongoing-work status" / "temporary task context" bullets. - filename field: name the topic, never prefix with a role / agent / task name; reuse an existing entry's filename verbatim when updating. - Workflow step 2: when refining an existing entry, write to its exact filename — never create a -update / -v2 / -final sibling. The cross-layer duplication (main re-extracting background-task-result blocks into L1) is not a prompt issue and is left to a separate code change. memoryExtractor role-prompt snapshot hash updated in both snapshot tests (15ad654 -> 296e169); no other role prompt changed. typecheck clean, 1462/1462 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the bundled memoryExtractor system prompt to reduce low-value memory writes by strengthening “durability” guidance and tightening filename/update rules, and refreshes prompt snapshot hashes to match.
Changes:
- Add an explicit “durability test” + skip list to prevent transient status/progress snapshots from being saved as long-term memory.
- Tighten filename guidance to avoid role/agent/task prefixes and to reuse existing filenames verbatim when updating.
- Update snapshot-hash fixtures for
memoryExtractorin the two prompt snapshot tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/agents/bundled/memoryExtractor.ts | Updates the memoryExtractor prompt with durability criteria and filename/update rules to reduce transient/duplicate memory files. |
| src/agents/role-prompt.snapshot.test.ts | Refreshes the expected prompt hash for memoryExtractor. |
| src/prompt/prompt-for-role.test.ts | Refreshes the expected prompt hash for memoryExtractor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The 2026-05-20 dogfood report (Bug 3) found
memoryExtractorover-producing — one night's memory tree held 113 files. Three symptoms:stock-monitoring-latest-status-2026-05-19-21-29.md,strength-test-second-round-3-returned.md, …) saved astype:projectentries that go stale within the hour.webSearcher/generalist-*.md(foreign role prefix),generalist/generalist-*.md(double prefix).-update/-completefilename variants instead of in-place updates.Root cause is the prompt itself: it explicitly said
DO save ... ongoing-work status, directly inducing #1, while the adjacenttemporary task contextexclusion contradicted it. Filename guidance was only "concise kebab/snake-case" — nothing about provenance or reuse.Change
Three edits to the
memoryExtractorsystem prompt:## What counts as durablesection with a concrete test — "would this entry be wrong or useless an hour from now?" — and an explicit Skip list for point-in-time status / progress snapshots. Replaces the contradictory "ongoing-work status" / "temporary task context" bullets.filenamefield: name the memory's topic; never prefix with a role / agent / task name; reuse an existing entry's filename verbatim when updating.-update/-v2/-finalsibling.Stays within the prompt design principle: first person, no enumeration of sibling agents / architecture, "the request" framing. Structurally it adds one section and moves the save/skip bullets out of "Body conventions" into it.
Out of scope
The cross-layer duplication symptom (Bug 3 現象2 —
mainre-extracting<background-task-result>blocks into L1, becausemain's extraction can't see worker L3 entries) is not a prompt issue. It needs a code change (exclude bg-result blocks frommain's extraction window) and is left to a separate PR. Bug 4 having restored the curator also lets it reconcile genuine cross-role duplicates.Testing
memoryExtractorrole-prompt snapshot hash updated in both snapshot tests (role-prompt.snapshot.test.ts,prompt-for-role.test.ts):15ad654…→296e169…. No other role prompt changed.extract.test.tsregression guard ("Do NOT emit memory contents as JSON") still holds — that line is unchanged.pnpm typecheckclean;pnpm test1462/1462 pass.🤖 Generated with Claude Code