zai-org / zai-org/feedback

[Bug] 微信 Bot(iLink)长回复被截断:sendmessage 无分片逻辑

Open
#385 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

提交前确认 · Pre-submission checklist
  • 我已搜索过现有 issue,确认这不是重复(关键词:weixin / 微信 / bot / 分片 / 截断,无同类问题)
  • 我已阅读 CONTRIBUTING.md
问题类别 · Category

对话 / Agent 交互 · Agent chat

涉及的 Agent 框架 · Agent framework

ZCode Agent(自研)

严重程度 · Severity

影响体验 · Major(功能可用但体验受损)

复现频率 · Reproducibility

必现 · Always

环境 · Environment
  • 平台:Windows 10/11 x64
  • ZCode:最新 Windows 版(2026-08-27 安装)
  • 渠道:微信 Bot(iLink,provider = weixin)
问题描述 · Summary

通过 ZCode 内置的「微信 Bot」渠道对话时,回复文本较长(约 2000 字符以上)会被截断,后半部分直接丢失。Telegram / Feishu 渠道同样场景下正常,因此是 weixin provider 特有的缺陷。

复现步骤 · Steps to reproduce
  1. 在 ZCode 中创建一个 weixin 渠道 Bot 并扫码绑定;
  2. 在微信中让 agent 生成一篇超过 2000 字符的回复(例如"写一篇 3000 字的长文");
  3. 观察微信端收到的消息:约 2000 字符处被截断,后半部分丢失。
根因分析 · Root cause

对 app.asar 反编译对比三个 Bot provider 的发送逻辑:

Telegram(有分片):

d = I0e(r.text);            // 按 3900 字符切片
for (let [l, u] of d.entries()) { await sendMessage(...); }

Feishu(有分片):

for (let i of eze(n.text)) await zb(...);   // 按 1900 字符切片

Weixin(无分片,一次性发送整条文本):

await mh(t, e, "/sendmessage", {
  msg: { ..., item_list: [{ type: 1, text_item: { text: yUe(n) } }] }
});

微信 iLink Bot 协议(https://ilinkai.weixin.qq.com/ilink/bot)社区实现普遍以 2000 字符作为单条消息的保守兼容上限(见 weixin-bot 协议规范 6.5 节「长消息分片策略(2000 字符限制)」),超过即被服务端截断。ZCode 的 weixin provider 缺少与 Telegram / Feishu 一致的分片逻辑,导致长回复被截断。

建议修复 · Suggested fix

参照协议 6.5 推荐算法,在 weixin provider 的 send 方法中按 ≤2000 字符分片、逐片调用 /sendmessage

  • 每个分片单独发送(顺序 await,保持先后顺序);
  • 每个分片使用新的 client_id(现 hUe() 每次生成新的,天然满足);
  • 复用同一个 context_token(协议要求回复必须原样回传);
  • 分片边界优先在 \n\n / \n / 空格处切,找不到合适边界再硬切。

与 Telegram(3900)、Feishu(1900)的既有实现风格一致,改动面很小。感谢!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the weixin provider’s send method and its /sendmessage call, then compare it with the existing Telegram and Feishu splitting behavior described in the issue. Verify the iLink message limit and boundary rules before changing the sender. Done means long replies arrive as ordered chunks of at most 2000 characters while reusing the same context_token.

Written by the indexing model from the issue text.

Assessment

Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.