myagent-ai 1.23.62 → 1.23.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -795,8 +795,8 @@ class MainAgent(BaseAgent):
795
795
  + self.SYSTEM_PROMPT.split("\n", 1)[1]
796
796
  )
797
797
  system_content = _prompt_with_placeholder.replace(_CONTEXT_PLACEHOLDER, context_xml)
798
- # 追加 XML 输出格式规范(确保 LLM 每次都能看到格式要求)
799
- system_content = system_content + "\n最后,再检查输出格式,确保满足以下要求:\n" + xml_prompt
798
+ system_content = system_content + "\n最后,再检查输出格式,确保满足以下要求:" + self.xml_prompt
799
+
800
800
  # Step 3: 构建 LLM 消息(必须包含 role=user,否则 OpenAI 兼容 API 返回 400)
801
801
  messages = [Message(role="system", content=system_content)]
802
802
 
@@ -106,7 +106,8 @@ class ChatBotManager:
106
106
  if loop.is_running() and not any(
107
107
  t for t in asyncio.all_tasks(loop) if t.get_name() == f"bot_{key}"
108
108
  ):
109
- asyncio.ensure_future(self._run_bot(key, bot))
109
+ task = asyncio.ensure_future(self._run_bot(key, bot))
110
+ self._bot_tasks[key] = task
110
111
  except Exception as e:
111
112
  logger.error(f"平台 {cfg.display_name or cfg.platform} 初始化失败: {e}")
112
113
 
@@ -200,6 +201,9 @@ class ChatBotManager:
200
201
  logger.info(f"聊天平台 {name} 已取消")
201
202
  except Exception as e:
202
203
  logger.error(f"聊天平台 {name} 运行异常: {e}")
204
+ # 运行异常时移除 bot 实例,下次热更新会重新创建全新的 bot
205
+ self._bots.pop(name, None)
206
+ self._bot_tasks.pop(name, None)
203
207
 
204
208
  async def _safe_stop(self, name: str, bot: BaseChatBot):
205
209
  """安全停止单个 bot(不抛异常)"""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.23.62",
3
+ "version": "1.23.64",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
package/web/api_server.py CHANGED
@@ -307,7 +307,8 @@ class ApiServer:
307
307
  bot = mgr._bots.get(key)
308
308
  if bot:
309
309
  logger.info(f"补启动聊天平台: {key}")
310
- asyncio.create_task(mgr._run_bot(key, bot), name=f"bot_{key}")
310
+ task = asyncio.create_task(mgr._run_bot(key, bot), name=f"bot_{key}")
311
+ mgr._bot_tasks[key] = task
311
312
  logger.info("聊天平台配置已热更新")
312
313
 
313
314
  def _setup_routes(self):