diff --git a/main/xiaozhi-server/agent-base-prompt.txt b/main/xiaozhi-server/agent-base-prompt.txt
index 7b54792c..51bd34a0 100644
--- a/main/xiaozhi-server/agent-base-prompt.txt
+++ b/main/xiaozhi-server/agent-base-prompt.txt
@@ -65,7 +65,7 @@ Calling unnecessarily is also wrong: User asks ”明天天气” → you call g
For the input format `{"speaker":"...", "content":"..."}` (speaker = speaker name, content = text):
-1. [Identity known] When `speaker` is a specific name, identity has been recognized. On the first turn you must address them naturally and adjust your response style based on their history.
+1. [Identity known] When `speaker` is a specific name, identity has been recognized — remember it and stay consistent about who they are. The only restriction is about OPENING a reply: do not start every reply by greeting or addressing them by name. You may greet/address them by name naturally ONLY ONCE (the first time you see their name); after that, get straight to the point. This does NOT forbid mentioning their name — if the user asks who they are, whether you know them (e.g. "你知道我是谁吗", "还记得我吗"), or otherwise references their identity, you MUST answer truthfully using their recognized name. Always adjust your response style based on their history.
2. [Identity unknown] When `speaker` is `未知说话人`, the system failed to identify the voice. You must NEVER mention the data inside the `speakers_info` tag to the user. Judge from context whether the speaker is the owner or the owner's friend, and keep the conversation natural.
diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py
index 8772180c..7dfd2145 100644
--- a/main/xiaozhi-server/core/connection.py
+++ b/main/xiaozhi-server/core/connection.py
@@ -983,7 +983,7 @@ class ConnectionHandler:
llm_responses = self.llm.response_with_functions(
self.session_id,
self.dialogue.get_llm_dialogue_with_memory(
- memory_str, self.config.get("voiceprint", {})
+ memory_str, self.config.get("voiceprint", {}), self.current_speaker
),
functions=functions,
)
@@ -991,7 +991,7 @@ class ConnectionHandler:
llm_responses = self.llm.response(
self.session_id,
self.dialogue.get_llm_dialogue_with_memory(
- memory_str, self.config.get("voiceprint", {})
+ memory_str, self.config.get("voiceprint", {}), self.current_speaker
),
)
except Exception as e:
diff --git a/main/xiaozhi-server/core/utils/dialogue.py b/main/xiaozhi-server/core/utils/dialogue.py
index 4039f01e..cb0a20f2 100644
--- a/main/xiaozhi-server/core/utils/dialogue.py
+++ b/main/xiaozhi-server/core/utils/dialogue.py
@@ -92,7 +92,8 @@ class Dialogue:
return result
def get_llm_dialogue_with_memory(
- self, memory_str: str = None, voiceprint_config: dict = None
+ self, memory_str: str = None, voiceprint_config: dict = None,
+ current_speaker: str = None,
) -> List[Dict[str, str]]:
# 构建对话
dialogue = []
@@ -145,8 +146,12 @@ class Dialogue:
# 追加说话人信息
try:
speakers = voiceprint_config.get("speakers", [])
- if speakers:
+ current_speaker_name = (current_speaker or "").strip()
+ if speakers or (current_speaker_name and current_speaker_name != "未知说话人"):
dynamic_part += "\n"
+ # 当前说话人置于块首,确保弱模型也能稳定获取身份
+ if current_speaker_name and current_speaker_name != "未知说话人":
+ dynamic_part += f"\n当前说话人:{current_speaker_name}"
for speaker_str in speakers:
try:
parts = speaker_str.split(",", 2)