Skip to content

ARIA: dedupe shortTermTracking entries in working memory - #363

Open
holoduke wants to merge 1 commit into
mainfrom
aria/dedupe-short-term-tracking-v2
Open

ARIA: dedupe shortTermTracking entries in working memory#363
holoduke wants to merge 1 commit into
mainfrom
aria/dedupe-short-term-tracking-v2

Conversation

@holoduke

Copy link
Copy Markdown
Owner

Problem

Working memory's shortTermTracking array is injected into every think/reflect prompt. The "daily self-improve nudge" string was appended on every reflect tick with no dedupe, and cleanupWorkingMemory only capped the list at 25 items — so on 2026-08-26 the array held exactly 25 identical copies of the nudge, bloating every brain prompt and drowning out real tracking items.

Fix (backend/memory/working-memory.ts)

  • New dedupeTracking() helper: normalized exact-match dedupe (trimmed, case-insensitive). Keeps the last occurrence so item order still reflects recency, and drops blank entries.
  • Applied at three points:
    • loadWorkingMemory() — cleans the already-bloated persisted state on next read, no migration needed.
    • updateWorkingMemory() — dedupes incoming shortTermTracking writes.
    • cleanupWorkingMemory() — dedupes before capping; trackingTrimmed now counts both deduped and capped removals.
  • Lowered MAX_TRACKING_ITEMS from 25 to 10, since duplicates no longer inflate the list and ~10 items keeps the prompt footprint small.

Verification

  • tsc --noEmit passes clean against main.
  • Dedupe logic sanity-tested: 25 duplicate nudges + case/whitespace variants + blanks collapse correctly to unique items in recency order.

🤖 Generated with Claude Code

The same 'daily self-improve nudge' string was appended on every
reflect tick and only capped at 25 items, so working memory carried
25 identical copies that were injected into every think/reflect
prompt — wasting tokens and drowning out real tracking items.

Fix in backend/memory/working-memory.ts:
- New dedupeTracking() helper: normalized exact-match dedupe
  (trimmed, case-insensitive), keeps the last occurrence so item
  order still reflects recency, and drops blank entries.
- Applied on load (cleans already-bloated persisted state on next
  read), on updateWorkingMemory writes, and in cleanupWorkingMemory
  before capping.
- Lowered MAX_TRACKING_ITEMS from 25 to 10 to keep the prompt
  footprint small now that duplicates no longer inflate the list.

Intent-summary: Working memory shortTermTracking accumulated identical entries (25 copies of the daily self-improve nudge) because nothing deduplicated the array on write, bloating every brain prompt.
Intent-tokens: dedupe, working-memory, shorttermtracking, duplicates, prompt-bloat, nudge, tokens

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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