Skip to content

Conversation

@marcelsamyn
Copy link
Owner

This commit addresses several issues with memory extraction and storage:

  1. Distinguish user facts from assistant statements: Updated the extraction prompt to only extract facts explicitly stated by the user, not speculative statements or assumptions made by the assistant. This prevents the system from storing assistant guesses as if they were user-provided facts.

  2. Enhanced graph cleanup for redundancy removal: Improved the cleanup prompt with detailed instructions for identifying and removing:

    • Redundant/duplicate nodes
    • Speculative or incorrect information
    • Outdated information
    • Contradictions (keeping most recent/specific information)
  3. Atlas-based contradiction detection: Modified the cleanup process to use the User Atlas as the source of truth. When user corrections are made (reflected in the atlas), the nightly cleanup now detects and removes contradicting graph nodes.

  4. Fixed missing import: Added missing env import in routes/dream.ts

These changes ensure that:

  • Only user-stated facts are extracted and stored
  • The nightly cleanup actively removes redundant and incorrect information
  • User corrections (via atlas updates) propagate to the graph during cleanup
  • The memory system maintains higher accuracy and data quality over time

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @iamarcel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the accuracy and quality of the memory system by ensuring that only user-provided facts are stored and by implementing a more robust graph cleanup mechanism. These changes prevent the accumulation of incorrect or speculative information, allowing user corrections to propagate effectively, and ultimately maintaining a more reliable and truthful knowledge graph over time.

Highlights

  • Refined Fact Extraction: The system now strictly extracts only facts explicitly stated or confirmed by the user, preventing the storage of speculative statements, assumptions, or unconfirmed interpretations made by the assistant.
  • Enhanced Graph Cleanup Logic: The graph cleanup process has been significantly improved with detailed instructions for identifying and removing redundant/duplicate nodes, speculative or incorrect information, outdated data, and contradictions.
  • Atlas-Based Contradiction Detection: The nightly cleanup now leverages the User Atlas as the definitive source of truth, actively detecting and removing graph nodes that contradict user corrections or current information reflected in the atlas.
  • Missing Import Fixed: A previously missing env import in routes/dream.ts has been added, resolving a potential dependency issue.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several significant improvements to the memory extraction and cleanup processes. The prompts for both graph extraction and cleanup have been substantially refined to focus on user-provided facts, avoid assistant speculation, and use the User Atlas as a source of truth for contradiction detection. This should greatly enhance the accuracy and quality of the stored knowledge graph. Additionally, a missing import in dream.ts has been fixed.

My review focuses on code consistency. I've pointed out an inconsistent use of dynamic imports in cleanup-graph.ts that could be aligned with the rest of the file for better maintainability. Overall, the changes are well-implemented and align with the stated goals of the pull request.

const client = await createCompletionClient(userId);

// Fetch user atlas for context about user corrections and current state
const { getAtlas } = await import("../atlas");
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This dynamic import of getAtlas is inconsistent with other static imports in this file, such as createCompletionClient and useDatabase. For better code consistency and maintainability, it's generally better to use static imports at the top of the file unless there's a specific reason for lazy loading (like circular dependencies or performance optimization). Consider making this a static import to align with the file's existing style.

@marcelsamyn
Copy link
Owner Author

@claude can you fix the CI failure?

@marcelsamyn marcelsamyn force-pushed the claude/fix-memory-storage-011FMEdqzzWcrBozDmzfx5hy branch 2 times, most recently from 467e062 to da6ff10 Compare November 25, 2025 09:10
This commit addresses several issues with memory extraction and storage:

1. **Distinguish user facts from assistant statements**: Updated the extraction
   prompt to only extract facts explicitly stated by the user, not speculative
   statements or assumptions made by the assistant. This prevents the system
   from storing assistant guesses as if they were user-provided facts.

2. **Enhanced graph cleanup for redundancy removal**: Improved the cleanup
   prompt with detailed instructions for identifying and removing:
   - Redundant/duplicate nodes
   - Speculative or incorrect information
   - Outdated information
   - Contradictions (keeping most recent/specific information)

3. **Atlas-based contradiction detection**: Modified the cleanup process to
   use the User Atlas as the source of truth. When user corrections are made
   (reflected in the atlas), the nightly cleanup now detects and removes
   contradicting graph nodes.

4. **Fixed missing import**: Added missing `env` import in routes/dream.ts

These changes ensure that:
- Only user-stated facts are extracted and stored
- The nightly cleanup actively removes redundant and incorrect information
- User corrections (via atlas updates) propagate to the graph during cleanup
- The memory system maintains higher accuracy and data quality over time
@marcelsamyn marcelsamyn force-pushed the claude/fix-memory-storage-011FMEdqzzWcrBozDmzfx5hy branch from da6ff10 to 5269e95 Compare November 25, 2025 09:19
@marcelsamyn marcelsamyn merged commit dbe1613 into main Nov 25, 2025
1 check passed
@marcelsamyn marcelsamyn deleted the claude/fix-memory-storage-011FMEdqzzWcrBozDmzfx5hy branch November 25, 2025 09:21
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.

3 participants