Skip to content

prompt(memory): tighten memoryExtractor against transient snapshots + role-name filenames - #8

Merged
RowitZou merged 1 commit into
mainfrom
feature/memory-extractor-prompt
May 20, 2026
Merged

prompt(memory): tighten memoryExtractor against transient snapshots + role-name filenames#8
RowitZou merged 1 commit into
mainfrom
feature/memory-extractor-prompt

Conversation

@RowitZou

Copy link
Copy Markdown
Owner

Problem

The 2026-05-20 dogfood report (Bug 3) found memoryExtractor over-producing — one night's memory tree held 113 files. Three symptoms:

  1. Transient status snapshots saved as permanent memory — ~24 timestamped status / progress snapshots (stock-monitoring-latest-status-2026-05-19-21-29.md, strength-test-second-round-3-returned.md, …) saved as type:project entries that go stale within the hour.
  2. Role names leaked into filenameswebSearcher/generalist-*.md (foreign role prefix), generalist/generalist-*.md (double prefix).
  3. -update / -complete filename 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 adjacent temporary task context exclusion contradicted it. Filename guidance was only "concise kebab/snake-case" — nothing about provenance or reuse.

Change

Three edits to the memoryExtractor system prompt:

  • 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 memory's topic; never prefix with a role / agent / task name; reuse an existing entry's filename verbatim when updating.
  • Workflow step 2: when the conversation only refines an existing entry, write to its exact filename — never create a -update / -v2 / -final sibling.

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 — main re-extracting <background-task-result> blocks into L1, because main's extraction can't see worker L3 entries) is not a prompt issue. It needs a code change (exclude bg-result blocks from main'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

  • memoryExtractor role-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.
  • The extract.test.ts regression guard ("Do NOT emit memory contents as JSON") still holds — that line is unchanged.
  • pnpm typecheck clean; pnpm test 1462/1462 pass.

🤖 Generated with Claude Code

… 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>
Copilot AI review requested due to automatic review settings May 20, 2026 08:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 memoryExtractor in 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.

@RowitZou
RowitZou merged commit ce8ef67 into main May 20, 2026
1 check passed
@RowitZou
RowitZou deleted the feature/memory-extractor-prompt branch May 20, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants