wangzhibo
2026-08-31 17ac2ce0ed52874616c79c910667e41e34604826
xiaozhi-esp32-server/main/xiaozhi-server/core/connection.py
@@ -200,6 +200,16 @@
        # 标记当前是否为来电接听模式
        self.incoming_call = None
        # Phase 1 App Runtime(连接内存,不建表)
        self.active_app_id = "chat"
        self.current_task_id = "conversation"
        self.interaction_mode = "CHAT"
        self.current_source = "default_chat"
        self.tool_policy = "inherit_agent"
        self.tool_allowlist = []
        self.original_system_prompt = None
        self.awaiting_voice_app_choice = False
    async def handle_connection(self, ws: websockets.ServerConnection):
        try:
            # 获取运行中的事件循环(必须在异步上下文中)
@@ -649,6 +659,8 @@
            self._init_prompt_enhancement()
            """注入工具调用few-shot示例(仅function_call模式)"""
            self._inject_tool_call_fewshot()
            if self.original_system_prompt is None:
                self.original_system_prompt = self.prompt
        except Exception as e:
            self.logger.bind(tag=TAG).error(f"实例化组件失败: {e}")