Skip to content

修复 Runner 工具输出非法 UTF-8 导致 terminal 丢失 - #93

Merged
wuchulonly merged 1 commit into
masterfrom
fix/aop-invalid-utf8
Aug 10, 2026
Merged

修复 Runner 工具输出非法 UTF-8 导致 terminal 丢失#93
wuchulonly merged 1 commit into
masterfrom
fix/aop-invalid-utf8

Conversation

@wuchulonly

Copy link
Copy Markdown
Contributor

问题

Runner 工具和 PTY 输出本质上是任意字节。此前 progressStreamer 会直接把原始 []byte 转成 protobuf string,工具最终结果也没有统一校验。遇到 0xff 等非法 UTF-8 时,aop.Wrap 编码失败,消息会被丢弃;若丢失的是 terminal ToolResult,上游调用会一直等待到超时。

修复

  • Progress 在按行发送和最终 Flush 时统一使用 strings.ToValidUTF8
  • ExecuteToolRequest 返回 terminal event 前,递归清洗 CallId、Name、text、reasoning、refusal 以及嵌套 ToolResult。
  • 合法 UTF-8 内容保持不变,非法字节以替换字符降级,保证 AOP 消息始终可编码。
  • 增加非法孤立字节、跨 chunk 多字节字符和嵌套终态字段的回归测试。

验证

  • go test ./pkg/runner ./pkg/node
  • go test -race ./pkg/runner ./pkg/node

@wuchulonly
wuchulonly merged commit d852455 into master Aug 10, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant