Support customized system prompt base#102
Merged
fridayL merged 2 commits intoMemTensor:devfrom Jul 17, 2025
Merged
Conversation
…mpt with a custom system prompt.
5 tasks
Contributor
There was a problem hiding this comment.
Pull Request Overview
Support per-query custom system prompts via a new base_prompt parameter
- Extend
MOS.chat(in both CoT and non-CoT paths) andMOSCore.chatto accept and forwardbase_prompt - Update
_build_system_promptto interpolate{memories}in a provided template and maintain backward-compatible behavior - Add tests covering custom prompt usage in both core and high-level APIs
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/memos/mem_os/main.py | Updated MOS.chat, _chat_with_cot_enhancement, and _generate_enhanced_response_with_context to accept and forward base_prompt |
| src/memos/mem_os/core.py | Extended chat signature and enhanced _build_system_prompt to handle base_prompt templates and memory interpolation |
| tests/mem_os/test_memos_core.py | Added tests for MOSCore.chat with a custom base prompt and for _build_system_prompt behavior under various scenarios |
| tests/mem_os/test_memos.py | Added tests ensuring MOS.chat passes base_prompt correctly in both CoT-disabled and CoT-enabled modes |
Comments suppressed due to low confidence (2)
src/memos/mem_os/main.py:57
- The docstring for
_chat_with_cot_enhancementis missing a description for the newbase_promptparameter. Please add anArgsentry explaining its purpose and usage.
def _chat_with_cot_enhancement(
tests/mem_os/test_memos_core.py:595
- Consider adding a test that verifies when no
base_promptis provided toMOSCore.chat, the default system prompt ("You are a knowledgeable and helpful AI assistant.") is used and sent to the LLM.
@patch("memos.mem_os.core.UserManager")
fridayL
approved these changes
Jul 17, 2025
tianxing02
pushed a commit
to tianxing02/MemOS
that referenced
this pull request
Feb 24, 2026
feat: Add parameter to chat functions to override the base system prompt with a custom system prompt. Co-authored-by: chunyu li <78344051+fridayL@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added parameter to mos.chat(base_prompt=) to enable base_prompt to be customised on a per-query basis.
base_prompt (str, optional): A custom base prompt to use for the chat.
{memories}placeholder.Issue: #90
Summary: (Support customized system prompt base)
Fix: #(90)
Reviewer: @fridayL
Checklist: