fuzhengwei / fuzhengwei/WaLiCode

[Bug] 流式响应丢弃第一个 chunk,导致工具调用参数不完整与正文开头缺字

Open
#149 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
133
Forks
11
PR merge metrics
No merged PRs in 30d

Description

补充:WaLiAPI 侧的工具调用问题已由作者合并修复(fuzhengwei/WaLiAPI#53),
**但正文丢首字符的问题依然存在**,并且这次定位到了明确规律。

## 已排除的可能

| 排除项 | 依据 |
|---|---|
| 网关差异 | 官方 WaLiAPI 与自建网关**逐片输出完全一致**:`['\n']` |
| 版本差异 | 官方最新版全新安装,同样复现 |
| 对话历史干扰 | **全新对话首轮**即复现 |
| 网关侧截断 | 网关日志中 content 完整:`'\n1. 分析:用户再次打招呼...'` |

也就是说,**服务端返回是完整的,内容是在客户端渲染时丢的**。

## 触发条件:只有纯文本回复才出问题

同一个 WaLiCode 版本(0.6.9)、同一个模型(gpt-5.4)、同为流式:

| 场景 | 界面渲染 |
|---|---|
| 回复中**带工具调用** | 「思考过程」被正确识别并折叠为可展开组件 ✅ |
| **纯文本回复**(无工具调用) | 直接显示 `ink>`,开头的 ``,此时内容已拼装完毕 → 成功
- **纯文本回复**:边流边解析。`` 被上游切成 `` 两片,
解析器在第一片中匹配不到完整标签,**把 `\n1` 等不同位置,也印证了这个推测。

## 建议的修复方向

1. 流式解析标签时,若缓冲内容最终未构成完整标签,应把缓冲的原始文本**原样输出**;
2. 或者对 `` 改为「先完整累积再解析」,与带工具调用时的路径保持一致。

## 复现

```bash
curl -N http://<任意 OpenAI 兼容网关>/v1/chat/completions \
-H "Authorization: Bearer sk-xxx" -H "Content-Type: application/json" \
-d '{"model":"gpt-5.4","stream":true,
"messages":[{"role":"user","content":"逐字输出:\n测试\n\n好"}]}'
```

对比 curl 抓到的原始 SSE(`` 完整)与 WaLiCode 界面显示(`ink>`),
用**不带工具调用的纯对话**即可复现。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the provided curl request and compare the complete SSE chunks with the WaLiCode interface output. Trace the pure-text streaming rendering path and its cross-chunk tag handling; done means split opening tags are preserved and the displayed response matches the server content exactly.

Written by the indexing model from the issue text.

Assessment

Domain
frontend
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.