Skip to content

Prototyped improvements for memory subagent#22898

Merged
SandyTao520 merged 9 commits into
st/feat/experimental-memory-manager-agentfrom
gundermanc/memory-agent-tweaks
Mar 18, 2026
Merged

Prototyped improvements for memory subagent#22898
SandyTao520 merged 9 commits into
st/feat/experimental-memory-manager-agentfrom
gundermanc/memory-agent-tweaks

Conversation

@gundermanc
Copy link
Copy Markdown
Member

Summary

Quick and dirty prototypes of:

  • Auto approval of writes to the global GEMINI.md file.
  • Better tool description so it gets called automatically.
  • Turn count optimization.
  • Prompt user if the agent isn't sure which store a memory should belong to.

@gundermanc gundermanc requested review from a team as code owners March 18, 2026 05:11
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 introduces a significant enhancement to the system's memory management capabilities by integrating an experimental Memory Manager Agent. This new subagent is designed to provide a more structured and intelligent approach to handling user memories, allowing for better organization, de-duplication, and context-aware routing of information across global and project-specific scopes. The change aims to improve the overall efficiency and effectiveness of how the system learns and retains user preferences and facts, moving beyond simple memory storage to a more active and managed memory system.

Highlights

  • Experimental Memory Manager Agent: Introduced an experimental Memory Manager Agent (experimental.memoryManager) to replace the built-in save_memory tool, enabling more sophisticated memory operations like adding, removing, de-duplicating, and organizing memories.
  • Enhanced Memory Routing and Context: The new memory manager subagent includes a detailed system prompt outlining a memory hierarchy (global and project-specific GEMINI.md files) and routing guidelines, including prompting the user for clarification when memory storage is ambiguous.
  • Optimized Agent Efficiency: The Memory Manager Agent's system prompt includes explicit instructions for efficiency, such as minimizing turns, staying focused, being decisive, and being context-aware to reduce unnecessary thinking and file system operations.
  • Policy and Access Control for Global Memories: Implemented a new policy (memory-manager.toml) to automatically allow the save_memory agent to read and write to the global ~/.gemini/ directory, ensuring proper access control while enabling its functionality.
  • Conditional Tool Registration: The legacy MemoryTool is now conditionally registered, being replaced by the Memory Manager Agent when the experimental.memoryManager flag is enabled.
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.

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
Copy Markdown
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 a new experimental MemoryManagerAgent to replace the save_memory tool. This new agent is more powerful, allowing for hierarchical memory management across global and project scopes. It includes a detailed system prompt, logic to discover context files, and a specific security policy. The changes also include updating configuration, schemas, and documentation to support this new feature. My review found one critical issue where the agent's model configuration in the implementation does not match the test, which could impact performance and cost, and needs to be addressed.

Note: Security Review did not run due to the size of the PR.

Comment on lines +164 to +166
modelConfig: {
model: 'gemini-3-flash-preview',
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The model configuration for the MemoryManagerAgent does not align with its corresponding test (memory-manager-agent.test.ts). The test explicitly checks for the gemini-2.5-flash-base model and a thinkingBudget of 0 to ensure efficiency. The current implementation uses gemini-3-flash-preview and lacks the thinkingBudget configuration.

To ensure the agent is optimized for performance and cost as intended, and to make the tests pass, the model configuration should be updated to use a base model with thinking disabled.

    modelConfig: {
      model: 'gemini-2.5-flash-base',
      generateContentConfig: {
        thinkingConfig: {
          thinkingBudget: 0,
        },
      },
    },

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Mar 18, 2026
@SandyTao520 SandyTao520 force-pushed the st/feat/experimental-memory-manager-agent branch 2 times, most recently from 8d2ff18 to 6949763 Compare March 18, 2026 17:38
# Insufficient context
If you find that you have insufficient context to read or modify the memories as described,
reply with what you need, and exit. Do not search the codebase for the missing context.
${getInitialContext()}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The initial context is a snapshot from process startup - if the user modifies GEMINI.md files during the session (or we used save_memory earlier in this session), the agent gets stale context.

@SandyTao520 SandyTao520 merged commit 4708017 into st/feat/experimental-memory-manager-agent Mar 18, 2026
1 check passed
@SandyTao520 SandyTao520 deleted the gundermanc/memory-agent-tweaks branch March 18, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants