Skip to content

Fix/empty memory context - #296

Merged
GoDiao merged 3 commits into
GoDiao:mainfrom
Benson-BS:fix/empty-memory-context
Nov 22, 2026
Merged

GoDiao merged 3 commits into
GoDiao:mainfrom
Benson-BS:fix/empty-memory-context

Conversation

@Benson-BS

Copy link
Copy Markdown
Contributor

fix(memory): report an empty memory index
Part of #278. This PR addresses T-CTX-10 only.

When MEMORY.md is missing or empty, the main session now tells the model that its memory is currently empty.

Tests:

  • bun test src/utils/__tests__/emptyMemoryContext.test.ts src/utils/__tests__/firstUserMessageContext.test.ts

If this PR is merged, I plan to work on the other items in #278.

@GoDiao GoDiao left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @Benson-BS, and welcome to DreamCoder! This picks the right gate: the notice is added only when auto-memory is on, the same condition that loads the index, it goes to the main session and not to subagents, and it reaches the model in the desktop app. The tests restore the env and caches they touch, pass in shuffled order alongside the other memory and context tests, and fail without the change. A few things before we merge.

Should fix

1. The notice lands inside the instruction files block. getClaudeMds (src/utils/claudemd.ts) builds the context in two parts: the instruction files under "Codebase and user instructions are shown below. Follow them: they override your default behavior…", then the memory index under MEMORY_INDEX_PROMPT ("The memory index below is not an instruction file…") with a Contents of <path> (user's auto-memory…) header. #287 split them on purpose (see T-CTX-04 in context.md). The PR joins the bare sentence to the end of that output (src/context.ts:184-192), so in a project with a CLAUDE.md and no MEMORY.md, it reads as the last line of that CLAUDE.md, under "Follow them", and "they will appear here" has no "here". The agent-memory version that T-CTX-10 asks to match puts the sentence under a ## MEMORY.md heading (src/memdir/memdir.ts:305-312).

When the index is missing or empty, please emit the same shape as a non-empty one: MEMORY_INDEX_PROMPT, the Contents of <auto-memory path> (…) header, then the empty notice. A test with a project instruction file that checks the notice comes after the memory index preamble would cover it; the current toContain checks can't see the position.

2. The sentence now exists twice. src/memdir/memdir.ts:311 already has it, built from ENTRYPOINT_NAME; the PR adds a second copy with MEMORY.md hard-coded (src/utils/claudemd.ts:1211). Please put it in one place in memdir and use it from both.

3. Status line in context.md. Fixed findings in that file have a first line under the heading like - 状态:已修复(#270):… (T-CTX-02, T-CTX-04 and others). Please use - 状态:已修复(#296):… instead of the quote block.

4. CHANGELOG. The blank line after the new entry splits the ### Fixed list in two; please remove it. Entries for external PRs reference the PR and end with a thank-you, so this one should end with (#296). Thanks @Benson-BS.

Notes

  • getEmptyAutoMemoryNotice checks tengu_moth_copse again. GrowthBook is off in DreamCoder, so it's always false; if you move the notice into getClaudeMds' memory index path for point 1, it can go.
  • We'll use fix(memory): report an empty memory index as the squash title.

Thanks for offering to take on the rest of #278. As the issue says, the remaining items can go in one PR.

…empty-memory-context

# Conflicts:
#	CHANGELOG.md
@Benson-BS

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've addressed the feedback in 7e5351b:

  • Moved the empty-memory notice into the memory index block and added a test for its position after project instructions.
  • Reused the empty-memory text from memdir.
  • Updated the status line in context.md and the changelog entry.
  • Merged the latest main and resolved the changelog conflict.

The related tests and desktop checks passed locally. The full server test run had one failure in the previously failing MCP npx path test.

Could you please review it again when you have time?

@GoDiao GoDiao left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @Benson-BS, all four points are in. With a missing or empty MEMORY.md, the model now gets the memory index preamble, the MEMORY.md header and the notice, the same shape as a non-empty index, and the new position test fails with the old placement. The sentence lives once in memdir, the CHANGELOG entry is right, and CI is green. I'll tidy the blank line under the T-CTX-10 status line on main after merging.

We'll be opening more features and issues soon, and you're very welcome to keep contributing; the remaining #278 items can go in one PR, as you offered. If you find DreamCoder useful, a star on the repo would be much appreciated.

@GoDiao
GoDiao merged commit ddb4f31 into GoDiao:main Nov 22, 2026
4 checks passed
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