Inject memory file path into inner Claude context#149
Conversation
The context injection included memory contents but not the file path, so the inner Claude could read memory but not write back to it. Include the absolute path in the injection label so the inner Claude knows where to save. Also update CLAUDE.md to reference the session context instead of the old hardcoded .claude/MEMORY.md path which has been wrong since PR #144 moved runtime data to DATA_DIR. Fixes #147
Review by KaiReview: Fix inner Claude memory path and enable persistent memory writesCritical: NoneWarningEmpty/missing memory skips path injection — bootstrapping problem Fix: inject the path label even when memory is empty, or inject it unconditionally as a separate prefix: parts.append(f"[Your persistent memory (file: {memory_path}):]\n{memory if memory else '(empty)'}")SuggestionAbsolute path disclosure in prompts
CleanThe Bottom line: The core idea is sound, but the bootstrapping case (empty memory on first use) is a real bug that will reproduce the original issue for new installs. Block on that fix before merging. |
On a fresh install the memory file is empty, so the if-memory guard skipped the block entirely and the inner Claude never received the path. Now injects the path unconditionally: with content when available, or a note that the file is empty/not yet created.
Review by KaiReview: Inject memory file path into inner Claude contextThe prior review's blocking concern (bootstrapping bug) is fixed. All three cases now inject the path. The fix is correct. SuggestionInconsistent message format across the three cases ( The "has content" case uses bracket notation ending with a colon: The empty and not-created cases switch to a different phrasing ending with a period: If the inner Claude is pattern-matching on the prefix to extract the path, the inconsistency between these formats could cause it to miss the path in the empty/not-created cases. Unifying the format would make extraction more reliable: parts.append(f"[Your persistent memory (file: {memory_path}):]\n(currently empty)")
parts.append(f"[Your persistent memory (file: {memory_path}):]\n(not yet created)")Clean
Bottom line: The blocking issue from the prior review is resolved. Only the format inconsistency is worth a look before merging. |
Review by KaiReview: Inject memory file path into inner Claude contextThe format inconsistency flagged in the prior review is resolved. All three cases now use the same bracket structure: SuggestionUnhandled read error ( Clean
Bottom line: Ready to merge. The read-error gap is worth a follow-up but is pre-existing and out of scope for this fix. |
Summary
.claude/MEMORY.mdpathSince PR #144 moved runtime data to
DATA_DIR/memory/MEMORY.md, the inner Claude has been told to write to a path that no longer exists. The context injection provided memory contents for reading but not the file path for writing. Now the injection label includes both:Test plan
make checkcleanFixes #147