Skip to content

fix: Windows 中文系统上 agent-reach doctor 误判微信公众号渠道不可用 #262

@Pgooone

Description

@Pgooone

Bug 描述

在 Windows 中文系统上运行 agent-reach doctor 时,微信公众号文章渠道会被错误地标记为 [X] 不可用,即使 mcporterExa MCP 已经正确安装且功能完全正常。

复现步骤

  1. 在 Windows 中文系统上安装 agent-reach
  2. 正确安装并配置 mcporter + Exa MCP(mcporter config add exa https://mcp.exa.ai/mcp
  3. 运行 agent-reach doctor

实际结果

  • 抛出异常:UnicodeDecodeError: 'gbk' codec can't decode byte 0x94 in position 185: illegal multibyte sequence
  • 微信公众号文章显示 [X] 需要 mcporter + Exa MCP 来搜索和阅读微信公众号文章
  • agent-reach doctor 状态为 8/16(实际应为 9/16)

问题根因

agent_reach/channels/wechat.py_exa_available() 函数中:

r = subprocess.run(
    [mcporter, "config", "list"],
    capture_output=True, text=True, timeout=5,
)

使用 text=True 时,Python 在 Windows 中文系统上默认以 gbk 编码读取子进程输出。当 mcporter config list 的输出中包含 UTF-8 特殊字符(如字节 0x94)时,gbk 解码失败,抛出 UnicodeDecodeError,异常被捕获后返回 False,导致 doctor 误判。

验证现象

尽管 doctor 显示 [X],实际上微信公众号渠道完全可用

mcporter call 'exa.web_search_exa(query: "人工智能 site:mp.weixin.qq.com", numResults: 3)'
mcporter call 'exa.web_fetch_exa(urls: ["https://mp.weixin.qq.com/s/..."], maxCharacters: 5000)'

以上命令均可正常执行并返回微信公众号文章结果。

修复建议

text=True 替换为 encoding="utf-8", errors="replace",使其与 exa_search.py 中的做法保持一致:

r = subprocess.run(
    [mcporter, "config", "list"],
    capture_output=True, encoding="utf-8", errors="replace", timeout=5,
)

已在本地验证:修复后 agent-reach doctor 正常运行,微信公众号文章显示为 ✅,状态变为 9/16。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions