Skip to content

fix(memory): preserve personal memory on truncation, dedupe proposals, and support cross-project scopes - #139

Open
mfituri wants to merge 2 commits into
mainfrom
fix/memory-truncation-dedupe-scopes
Open

mfituri wants to merge 2 commits into
mainfrom
fix/memory-truncation-dedupe-scopes

Conversation

@mfituri

@mfituri mfituri commented Nov 21, 2026

Copy link
Copy Markdown

When team and project memory files grew past the 8 KB <memory> block cap, buildMemoryBlock sliced from the end and silently dropped personal and personal-project memories first. Agents could also propose already-saved or cross-thread duplicate lines, accepting a proposal could append duplicate lines or only target project-scoped files, and general proposals lacked guidance to avoid first-person wording when they might be accepted for the team.

What changed

  • Keep personal memories on truncation (packages/contracts/src/memory.ts, apps/web/src/components/memory/MemoryPanel.tsx): Trim earlier (less-specific) sections first when the <memory> block exceeds MEMORY_MAX_BYTES so personal and personal-project sections stay intact.
  • Deduplicate proposals and accepts (apps/server/src/memory/Memory.ts): Reject memory_propose additions when the normalized line is already saved in any active memory file for the project or pending from another thread in the same project, and refuse memory.decide additions when the line already exists in the target file.
  • Support cross-project scopes on proposal cards (packages/contracts/src/memory.ts, apps/server/src/memory/Memory.ts, apps/web/src/components/memory/): Add an optional scope field on MemoryDecideInput and a This project / All projects toggle on MemoryDecisionButtons (shared by chat cards, the Memory panel, and the Questions page) so additions can save to memory/people/<login>.md or memory/team.md as well as project-scoped files.
  • Scope-neutral proposal wording (packages/contracts/src/memory.ts, apps/server/src/mcp/toolkits/memory/tools.ts, evals/mcp-tool-use/cases/voice-agent-memories.ndjson): Instruct agents to write general memory proposals neutrally (without "me" or the user's name) and add a matching eval case.

Verification

  • vp run check:changed passes (format, lint, knip, graphql, 42-package typecheck, unit tests including AgentContextBudget.test.ts, and React compiler coverage).
  • vp test run mcp-tool-use/run.test.ts -t "voice agent case" (from evals) passes.

Model: Gemini 4 Neon (Antigravity)

@cursor

cursor Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes memory proposal/accept validation and which files merges target; incorrect dedupe or scope logic could block valid proposals or write to the wrong memory file.

Overview
Fixes <memory> block truncation so oversized blocks drop less-specific sections first (team before project before personal), preserving personal and personal-project lines instead of trimming from the end.

Server-side deduplication now blocks memory_propose when the normalized line is already on disk in any project memory file or pending in another thread, and blocks accepts that would append a duplicate or use an invalid me/team vs scope pairing.

Proposal cards add a This project / All projects toggle that passes optional scope on memory.decide, routing accepts to memory/team.md and memory/people/<login>.md when “all projects” is chosen.

Agents are guided to propose neutral wording (no “me” or the user’s name), with matching tool copy, block footer text, and an eval guard case.

Reviewed by Cursor Bugbot for commit 97cc454. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4a0ac13. Configure here.

Comment thread apps/server/src/memory/Memory.ts Resolved
Comment thread apps/server/src/memory/Memory.ts Resolved
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.

1 participant