Compare commits

..

No commits in common. "4ae96c6e02931e711f472abe8d32196db71833c8" and "3bf619e2dd04ee58da5baa6baf540c514fdb1cdd" have entirely different histories.

4 changed files with 6 additions and 23 deletions

View file

@ -916,8 +916,6 @@ class ConnectionHandler:
self.chat_history_conf = int(private_config["chat_history_conf"])
if private_config.get("mcp_endpoint", None) is not None:
self.config["mcp_endpoint"] = private_config["mcp_endpoint"]
if private_config.get("mcp_forward_speaker", None) is not None:
self.config["mcp_forward_speaker"] = private_config["mcp_forward_speaker"]
if private_config.get("context_providers", None) is not None:
self.config["context_providers"] = private_config["context_providers"]
@ -1124,19 +1122,7 @@ class ConnectionHandler:
# 仅在该说话人首次出现时把身份注入 system,之后靠对话历史首轮保留,
# 避免每轮在 system 重复出现名字诱导模型反复称呼
speaker_for_system = None
# 展示名只取本轮数据(声纹快照 → query JSON),不读并发下会被覆盖的连接态
cs = ""
if speaker is not None:
cs = (speaker.name or "").strip()
if not cs and depth == 0 and query:
q = query.strip()
if q.startswith("{") and q.endswith("}"):
try:
parsed = json.loads(q)
if isinstance(parsed, dict):
cs = str(parsed.get("speaker") or "").strip()
except (json.JSONDecodeError, TypeError, ValueError):
pass
cs = (self.current_speaker or "").strip()
if cs and cs != UNKNOWN_SPEAKER_NAME and cs not in self.system_introduced_speakers:
self.system_introduced_speakers.add(cs)
speaker_for_system = cs
@ -1384,7 +1370,7 @@ class ConnectionHandler:
# 统一处理工具调用结果
if tool_results:
self._handle_function_result(tool_results, depth=depth, streamed_text=streamed_text, speaker=speaker)
self._handle_function_result(tool_results, depth=depth, streamed_text=streamed_text)
# 存储对话内容
if len(response_message) > 0:
@ -1409,7 +1395,7 @@ class ConnectionHandler:
return True
def _handle_function_result(self, tool_results, depth, streamed_text="", speaker=None):
def _handle_function_result(self, tool_results, depth, streamed_text=""):
need_llm_tools = []
record_tools = []

View file

@ -47,7 +47,7 @@ async def handle_user_intent(conn: "ConnectionHandler", text, speaker=None):
# 会话开始时生成sentence_id
conn.sentence_id = str(uuid.uuid4().hex)
# 处理各种意图
return await process_intent_result(conn, intent_result, text, speaker=speaker)
return await process_intent_result(conn, intent_result, text)
async def check_direct_exit(conn: "ConnectionHandler", text):
@ -81,7 +81,7 @@ async def analyze_intent_with_llm(conn: "ConnectionHandler", text):
async def process_intent_result(
conn: "ConnectionHandler", intent_result, original_text, speaker=None
conn: "ConnectionHandler", intent_result, original_text
):
"""处理意图识别结果"""
try:

View file

@ -362,8 +362,7 @@ async def call_mcp_endpoint_tool(
message = json.dumps(payload)
log_suffix = ""
if meta:
# 只记是否附带身份及字段名,不输出 speakerId/speakerName 明文
log_suffix = f",_meta: 附带身份字段 {list(meta.keys())}"
log_suffix = f",_meta: {json.dumps(meta, ensure_ascii=False)}"
logger.bind(tag=TAG).info(
f"发送MCP接入点工具调用请求: {actual_name},参数: {json.dumps(arguments, ensure_ascii=False)}{log_suffix}"
)

View file

@ -153,8 +153,6 @@ async def test_executor_reads_snapshot_not_conn_state(monkeypatch):
monkeypatch.setattr(executor_mod, "call_mcp_endpoint_tool", fake_call)
conn = _Conn()
# 模拟并发场景:连接态已被下一轮覆盖成另一个人,meta 仍必须取自快照
conn.current_speaker = "旧说话人"
await executor_mod.MCPEndpointExecutor(conn).execute(
conn,
"HassTurnOn",