Skip to content

feat(agent): Add long-term memory feature to Friday#125

Closed
hongxicheng wants to merge 10 commits into
agentscope-ai:mainfrom
hongxicheng:AddLongTermMemory
Closed

feat(agent): Add long-term memory feature to Friday#125
hongxicheng wants to merge 10 commits into
agentscope-ai:mainfrom
hongxicheng:AddLongTermMemory

Conversation

@hongxicheng
Copy link
Copy Markdown
Collaborator

@hongxicheng hongxicheng commented Feb 14, 2026

Description

This PR depends on PR #124 .
Related to #124 .
image
image

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with npm run format command in the root directory
  • Docstrings/comments are in appropriate style (TSDoc/JSDoc for TypeScript/JavaScript, Google style for Python)
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@hongxicheng hongxicheng added the enhancement New feature or request label Feb 14, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @hongxicheng, 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 Friday agent by introducing long-term memory and external service integration via the Model Context Protocol (MCP). The changes provide Friday with the ability to remember past interactions through configurable embedding models and vector stores, and to connect with a variety of external services, both local and remote. The user experience is improved with new, intuitive configuration interfaces in the frontend.

Highlights

  • Long-Term Memory Integration: Introduced long-term memory capabilities to the Friday agent using AgentScope's Mem0LongTermMemory, allowing the agent to retain information across conversations. This includes new configuration options for embedding providers, models, API keys, and vector store settings.
  • Model Context Protocol (MCP) Management: Added a comprehensive feature for managing MCP servers, enabling Friday to connect to external services. This includes both local (StdIOStatefulClient) and remote (HttpStatelessClient) MCP server configurations, with a dedicated UI for setup and management.
  • Frontend Configuration UI: Developed new UI components for configuring long-term memory settings and managing MCP servers within the Friday application. This includes forms for various embedding and vector store parameters, as well as a dedicated sheet for adding, editing, and deleting MCP server configurations.
  • Backend Argument and Model Extensions: Extended the Python backend to support new command-line arguments for long-term memory and MCP server configurations. New utility functions were added to handle embedding model retrieval and vector store clearing, and the main agent initialization now incorporates these new features.
Changelog
  • package-lock.json
    • Added 'json5' dependency.
    • Updated 'peer' flags for various existing dependencies.
  • package.json
    • Added 'json5' dependency.
  • packages/app/friday/args.py
    • Added new command-line arguments for long-term memory configuration, including embedding provider, model name, API key, kwargs, local storage options, and vector store provider.
    • Introduced a new 'json_list_type' function to parse JSON strings into lists of dictionaries for MCP server configurations.
    • Added a new argument for 'mcpServers' to accept a JSON list of MCP server configurations.
  • packages/app/friday/main.py
    • Imported 'Mem0LongTermMemory' for long-term memory functionality.
    • Integrated 'Mem0LongTermMemory' into the 'ReActAgent' initialization, conditionally enabling it based on arguments.
    • Added logic to connect to and close MCP servers using the new 'mcp_manager' module.
    • Modified the agent's system prompt to include information about long-term memory when enabled.
  • packages/app/friday/mcp_manager/init.py
    • Added a new module to manage MCP connections.
    • Exported 'connect_mcp_servers' and 'close_mcp_connections' functions.
  • packages/app/friday/mcp_manager/manager.py
    • Implemented 'connect_mcp_servers' to parse MCP server configurations and connect to local (StdIOStatefulClient) or remote (HttpStatelessClient) servers.
    • Implemented '_connect_local_server' to handle local MCP service connections and registration with the toolkit.
    • Implemented '_connect_remote_server' to handle remote MCP service connections and registration with the toolkit.
    • Implemented 'close_mcp_connections' to properly shut down local MCP client connections.
  • packages/app/friday/model.py
    • Imported various embedding model classes from 'agentscope.embedding'.
    • Added 'get_memory_model' function to retrieve chat models specifically for memory operations.
    • Added 'get_embedding_model' function to retrieve embedding model instances based on provider and configuration.
  • packages/app/friday/utils/common.py
    • Added 'shutil' import for directory operations.
    • Implemented 'clear_vector_store' function to remove vector store data from local storage, addressing potential dimension mismatch issues.
  • packages/client/src/components/MCP/DeleteConfirmDialog.tsx
    • Added a new React component for confirming the deletion of an MCP server.
  • packages/client/src/components/MCP/MCPServerCardHeader.tsx
    • Added a new React component for the header of an MCP server configuration card, including a toggle switch for enabling/disabling and a delete button.
  • packages/client/src/components/MCP/MCPServerForm.tsx
    • Added a new React component for configuring MCP servers, supporting 'local' and 'remote' types.
    • Implemented 'simple' and 'advanced' configuration modes for remote MCP servers, allowing direct JSON input or guided form fields.
    • Included dynamic input fields for headers (key-value pairs) for remote MCP configurations.
    • Added validation logic and error display for MCP server configurations.
  • packages/client/src/components/MCP/ValidationErrorDialog.tsx
    • Added a new React component to display validation errors in a dialog.
  • packages/client/src/context/FridaySettingRoomContext.tsx
    • Updated 'saveFridayConfig' to update the local 'fridayConfig' state only upon successful save response from the backend.
  • packages/client/src/context/MCPContext.tsx
    • Added a new React context ('MCPProvider' and 'useMCP') for managing MCP server configurations in the frontend.
    • Implemented state management for adding, deleting, updating, saving, and canceling MCP server configurations.
    • Included validation logic for MCP server properties, including name uniqueness and JSON format checks.
    • Added a function to update and immediately save the 'enabled' status of an MCP server.
  • packages/client/src/i18n/en.json
    • Added new translation keys for MCP server management, including titles, descriptions, form fields, validation messages, and button labels.
    • Added new translation keys for long-term memory settings, including embedding provider, model name, API key, kwargs, vector store provider, and local storage options.
  • packages/client/src/i18n/zh.json
    • Added new Chinese translation keys for MCP server management and long-term memory settings, mirroring the English additions.
  • packages/client/src/pages/FridayPage/ChatPage/MCPManagementSheet.tsx
    • Added a new React component for a sheet that allows users to manage MCP servers.
    • Integrated 'MCPProvider', 'MCPServerCardHeader', 'MCPServerForm', and 'DeleteConfirmDialog' to provide a full MCP management interface.
    • Included search functionality to filter MCP servers.
  • packages/client/src/pages/FridayPage/ChatPage/index.tsx
    • Imported 'MCPManagementSheet' and 'useFridaySettingRoom'.
    • Added a 'Plug2Icon' button to the chat page sidebar to open the MCP management sheet.
    • Implemented 'handleMcpSave' to save MCP server configurations via the 'FridaySettingRoomContext'.
  • packages/client/src/pages/FridayPage/SettingPage/KwargsFormList.tsx
    • Updated to dynamically adjust labels and help text for 'embeddingKwargs' in addition to 'clientKwargs' and 'generateKwargs'.
  • packages/client/src/pages/FridayPage/SettingPage/index.tsx
    • Added new form items for 'longTermMemory', 'embeddingProvider', 'embeddingModelName', 'embeddingApiKey', 'vectorStoreProvider', 'saveToLocal', and 'localStoragePath'.
    • Implemented logic to auto-fill a default local storage path when long-term memory is enabled and 'saveToLocal' is checked.
    • Adjusted API key requirements based on the selected LLM and embedding providers.
    • Modified the save button behavior to no longer automatically navigate to the chat page after saving, allowing users to click a 'Back to Chat' button.
  • packages/client/src/pages/FridayPage/config.tsx
    • Added 'embeddingProviderOptions' for various embedding API providers.
    • Added 'vectorStoreProviderOptions' for different vector database providers.
  • packages/client/src/pages/FridayPage/index.tsx
    • Wrapped the 'ChatPage' component with 'FridaySettingRoomContextProvider' to ensure settings are available.
  • packages/shared/src/config/friday.ts
    • Defined a new 'MCPServer' interface to structure MCP server configurations, including local/remote types, enabled status, and detailed configuration fields.
    • Extended the 'FridayConfig' interface to include 'mcpServers' (an array of 'MCPServer' objects) and new properties for long-term memory configuration (e.g., 'longTermMemory', 'embeddingProvider', 'embeddingModelName', 'embeddingApiKey', 'embeddingKwargs', 'saveToLocal', 'localStoragePath', 'vectorStoreProvider').
Activity
  • No human activity has been recorded on this pull request yet.
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
Copy Markdown

@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 significant new feature: long-term memory for the Friday agent, using embeddings and a vector store. It also adds a comprehensive MCP (Model Context Protocol) server management system, both in the backend and with a new UI on the frontend. My review focuses on improving code maintainability by reducing duplication, enhancing robustness in attribute access, and adopting standard logging practices for better production readiness. Overall, this is a well-structured feature addition.

Comment thread packages/app/friday/model.py Outdated
Comment thread packages/app/friday/main.py Outdated
Comment thread packages/app/friday/mcp_manager/manager.py Outdated
@hongxicheng
Copy link
Copy Markdown
Collaborator Author

/gemini review

Copy link
Copy Markdown

@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 PR introduces a significant new feature: long-term memory for the Friday agent, along with a UI for managing MCP servers. The implementation is extensive, covering both backend and frontend changes.

My review focuses on several key areas:

  • Consistency: I've pointed out inconsistencies in JSON parsing between different parts of the application, which could lead to bugs.
  • Correctness: I found a bug where a fallback for an API key was documented but not implemented, and another where a configuration field (vectorStoreKwargs) was not being saved.
  • Maintainability: I've made suggestions to improve the extensibility of the code, particularly around provider-specific configurations, to make future enhancements easier.

Overall, this is a solid implementation of a complex feature. The new UI components and backend logic are well-structured. Addressing the issues I've raised will improve the robustness and maintainability of the new functionality.

Comment thread packages/app/friday/main.py
Comment thread packages/client/src/components/MCP/MCPServerForm.tsx
Comment thread packages/client/src/pages/FridayPage/SettingPage/index.tsx Outdated
Comment thread packages/app/friday/args.py
Comment thread packages/app/friday/main.py
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

This PR is marked as stale because there has been no activity for 30 days. Remove stale label or add new comments or this PR will be closed in 5 day.

@github-actions
Copy link
Copy Markdown

Close this stale PR.

@github-actions github-actions Bot closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request stale-pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant