myagent-ai 1.18.0 → 1.18.1
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.
- package/agents/main_agent.py +22 -33
- package/core/vnc_manager.py +7 -1
- package/package.json +1 -1
package/agents/main_agent.py
CHANGED
|
@@ -706,46 +706,35 @@ class MainAgent(BaseAgent):
|
|
|
706
706
|
)
|
|
707
707
|
break
|
|
708
708
|
|
|
709
|
-
# [v1.
|
|
710
|
-
#
|
|
709
|
+
# [v1.18.0] 特殊处理模型不支持图片输入
|
|
710
|
+
# 策略: 保留图片数据,break 后让 _stream_process_message 返回 ⚠️ 标记
|
|
711
|
+
# model chain 的 _try_model_chain_stream_inner 检测到 ⚠️ 后会继续尝试下一个模型
|
|
711
712
|
_vision_keywords = [
|
|
712
713
|
"doesn't support image", "does not support image", "model_incompatible",
|
|
713
714
|
"image input", "not support vision", "unsupported multimodal", "image capability",
|
|
714
715
|
"不支持图片", "不支持图像", "图片输入", "图像输入", "不支持多模态",
|
|
715
716
|
"视觉", "image_url", "multimodal", "vision",
|
|
716
717
|
]
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
context.metadata
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
718
|
+
_is_vision_error = (
|
|
719
|
+
any(kw.lower() in _llm_error.lower() for kw in _vision_keywords)
|
|
720
|
+
and context.metadata.get("user_images")
|
|
721
|
+
)
|
|
722
|
+
|
|
723
|
+
if _is_vision_error:
|
|
724
|
+
logger.warning(f"[{task_id}] 模型 {self.llm.model} 不支持图片输入,"
|
|
725
|
+
f"将切换到支持图片的模型重试")
|
|
726
|
+
# 返回 ⚠️ 标记的错误,让 model chain 继续尝试下一个模型
|
|
727
|
+
# 注意: 不清除 context.metadata["user_images"],下一个模型仍可使用
|
|
728
|
+
_vision_skip_msg = f"⚠️ 模型 {self.llm.model} 不支持图片,正在切换..."
|
|
729
|
+
context.working_memory["final_response"] = _vision_skip_msg
|
|
730
|
+
await self._emit_v2_event("v2_reasoning", {"content": _vision_skip_msg}, stream_callback)
|
|
731
|
+
if self.memory:
|
|
732
|
+
self.memory.add_session(
|
|
733
|
+
session_id=context.session_id,
|
|
734
|
+
role="assistant",
|
|
735
|
+
content=_vision_skip_msg,
|
|
729
736
|
)
|
|
730
|
-
|
|
731
|
-
response = await self._call_llm(messages)
|
|
732
|
-
if response.success:
|
|
733
|
-
# 纯文本重试成功,给回复加上提示前缀
|
|
734
|
-
_vision_prefix = "⚠️ 当前模型不支持图片识别,已自动使用纯文本模式处理(图片未发送给模型)。\n\n"
|
|
735
|
-
llm_raw = _vision_prefix + response.content
|
|
736
|
-
context.working_memory["final_response"] = llm_raw
|
|
737
|
-
await self._emit_v2_event("v2_reasoning", {"content": llm_raw}, stream_callback)
|
|
738
|
-
if self.memory:
|
|
739
|
-
self.memory.add_session(
|
|
740
|
-
session_id=context.session_id,
|
|
741
|
-
role="assistant",
|
|
742
|
-
content=llm_raw,
|
|
743
|
-
)
|
|
744
|
-
break
|
|
745
|
-
else:
|
|
746
|
-
# 纯文本也失败了,走下面的通用错误处理
|
|
747
|
-
_llm_error = response.error or ""
|
|
748
|
-
logger.error(f"[{task_id}] 纯文本重试也失败: {_llm_error}")
|
|
737
|
+
break # 退出 agent 循环,让 model chain 尝试下一个模型
|
|
749
738
|
|
|
750
739
|
# 其他 LLM 错误
|
|
751
740
|
error_msg = f"LLM 调用失败: {response.error}"
|
package/core/vnc_manager.py
CHANGED
|
@@ -597,6 +597,12 @@ class VNCManager:
|
|
|
597
597
|
|
|
598
598
|
env = {**os.environ, "DISPLAY": self.display}
|
|
599
599
|
|
|
600
|
+
# [v1.18.0] proot/Termux 兼容: 可能需要额外的安全参数
|
|
601
|
+
cmd.append("-nobell")
|
|
602
|
+
cmd.append("-noxdamage")
|
|
603
|
+
# 跳过 Xinerama 检查(proot 环境下可能失败)
|
|
604
|
+
env["X11VNC_NO_UNIXPW"] = "1"
|
|
605
|
+
|
|
600
606
|
logger.info(f"启动 x11vnc: {' '.join(cmd)}")
|
|
601
607
|
self._x11vnc_process = subprocess.Popen(
|
|
602
608
|
cmd,
|
|
@@ -612,7 +618,7 @@ class VNCManager:
|
|
|
612
618
|
if self._x11vnc_process.poll() is not None:
|
|
613
619
|
stderr = ""
|
|
614
620
|
try:
|
|
615
|
-
stderr = self._x11vnc_process.stderr.read().decode("utf-8", errors="replace")[:
|
|
621
|
+
stderr = self._x11vnc_process.stderr.read().decode("utf-8", errors="replace")[:2000]
|
|
616
622
|
except Exception:
|
|
617
623
|
pass
|
|
618
624
|
logger.error(f"x11vnc 启动失败: {stderr}")
|