- [Monitor Logging & Thought-Signature Backfill Hardening] Fix Tokio Worker Panic and Connection Hang Caused by Byte-Slicing Thought Snippets on Multi-Byte Character Boundaries (PR #3574, Fixes #3573, Thanks to @a3339530357):
- Safe UTF-8 Character Boundary Truncation: Fixed a standard library
char boundary panicinmonitor.rs's thought signature backfill path, where raw byte-slicing&trimmed[..32]was executed on thinking content. When multi-byte characters (e.g. Chinese at 3 bytes/char or Emojis at 4 bytes) straddled the 32nd byte index, slicing inside a code point caused immediate panics. Replaced with the existing shared utilitysafe_truncate_str(trimmed, 32), which automatically rolls back to the nearest valid character boundary. - Eradicate Downstream Connection Drops & Silent Log Losses: Permanently eliminated Tokio worker crashes triggered by this panic, resolving
socket hang up/Empty reply from servererrors in downstream clients (such as Chinese coding agents and chatbots) during non-streaming requests, and ensuring monitor request logs are 100% reliably persisted to the database.
- Safe UTF-8 Character Boundary Truncation: Fixed a standard library
- [监控日志与思考签名回填安全加固] 修复思考片段按字节切片切在多字节字符中间导致的 Rust worker panic 与连接挂起 (PR #3574, Fixes #3573, Thanks to @a3339530357):
- UTF-8 字符边界安全回退: 修复在
monitor.rs签名回填路径中对思考内容执行&trimmed[..32]原生字节切片时,因中文(3 字节/字)或 Emoji(4 字节)等宽字符横跨第 32 字节触发的标准库char boundary panic。改用通用工具safe_truncate_str(trimmed, 32),在截断点落在多字节内部时自动向左回退至最近合法字符边界。 - 根治下游连接中断与日志静默丢失: 彻底消除由上述 panic 引发的 tokio worker 崩溃,解决下游应用(如中文 Agent、聊天客户端)在非流式模式下收到的
socket hang up/Empty reply from server异常,确保请求监控日志 100% 完整落库。
- UTF-8 字符边界安全回退: 修复在
What's Changed
- fix(monitor): 修复思考片段按字节截断切在多字节字符中间导致的连接 panic by @a3339530357 in #3574
New Contributors
- @a3339530357 made their first contribution in #3574
Full Changelog: v4.8.9...v4.9.0