Skip to content

[Bug]: 微信 Bot 消息分片:500ms flush 在句子中间截断,建议改为语义边界分片 #4372

@LUMIAO9527

Description

@LUMIAO9527

Version line

v2 — Go rewrite (1.x), main-v2 (active development)

Exact version

v1.7.0

What happened?

问题描述

使用微信 Bot 时,Reasonix 的回复被拆分为多条微信消息发送,且拆分位置在句子中间,阅读体验很差。

例如:

消息1: "我是 "
消息2: "Reasonix
,一个专注于执行代码任务的 AI 编程助手。\n\n我的核心能力:\n- 读取和修改代码 — 擅长分析项目结构、修改代码、解决 Bug\n-"
消息3: "文件操作 — 创建、编辑、搜索文件\n- Shell 命令 — 在 PowerShell 环境下执行构建、测试、Git 等操作\n- 代码理解 — 通过 codegraph 工具进行符号级别的代码分析\n- 技能系统 — 可调用项目预置"
消息4: "的 playbook(如代码评审、探索、研究等)…"

根因分析

问题出在 internal/bot/render.gomaybeFlush() 方法:

func (s *renderSink) maybeFlush() {
    if time.Since(s.lastFlush) > 500*time.Millisecond {
        s.flush()
    }
}

### Steps to reproduce

1send messages

### OS / platform

WeChat/微信

### Relevant logs or output

```shell

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentCore agent loop (internal/agent, internal/control)bugSomething isn't workingv2Go rewrite (1.x) — main-v2 branch, active development

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions