ARIA: dedupe shortTermTracking entries in working memory - #363
Open
holoduke wants to merge 1 commit into
Open
Conversation
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>
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
Working memory's
shortTermTrackingarray is injected into every think/reflect prompt. The "daily self-improve nudge" string was appended on every reflect tick with no dedupe, andcleanupWorkingMemoryonly 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)dedupeTracking()helper: normalized exact-match dedupe (trimmed, case-insensitive). Keeps the last occurrence so item order still reflects recency, and drops blank entries.loadWorkingMemory()— cleans the already-bloated persisted state on next read, no migration needed.updateWorkingMemory()— dedupes incomingshortTermTrackingwrites.cleanupWorkingMemory()— dedupes before capping;trackingTrimmednow counts both deduped and capped removals.MAX_TRACKING_ITEMSfrom 25 to 10, since duplicates no longer inflate the list and ~10 items keeps the prompt footprint small.Verification
tsc --noEmitpasses clean against main.🤖 Generated with Claude Code