MoonshotAI / MoonshotAI/kimi-code
Windows 下结构化工具结果在 UI 可见但模型无法读取
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
问题描述
在 Windows 环境下,Kimi Code CLI 的结构化工具结果会显示在 UI 中,但模型无法读取这些工具返回的实际内容。
该问题从 0.23.1 升级到 0.23.2 后仍然存在。
目前观察到:
Read工具能执行,UI 能显示读取到的行数,但模型无法看到文件正文。Glob工具能执行,UI 能显示匹配到的文件数量和列表,但模型无法读取匹配结果。Bashstdout 可以被模型正常读取。- 因此问题不像是 shell、文件权限或命令执行失败,更像是结构化工具结果没有正确注入模型上下文。
该问题不局限于某个具体项目或具体文件;读取当前工作区内任意可访问的普通文本文件时均可复现。
复现环境
- Kimi Code CLI 版本:
0.23.2 - 曾复现的旧版本:
0.23.1 - 操作系统:Windows
- 启动方式:PowerShell 中启动 Kimi Code CLI
- 测试模式:交互式
kimi -y
复现步骤
- 准备任意包含普通文本文件的工作区。
- 在 PowerShell 中进入该工作区。
- 启动 Kimi Code CLI:
kimi -y
- 在交互中输入:
请读取当前工作区内任意一个已存在的文本文件,并原样输出前 5 行
或:
Read an accessible text file in the current workspace and print the first 5 lines exactly.
- 再测试
Glob:
请搜索当前工作区内已存在的某类文件,例如 *.json 或 *.md
- 再测试
Bash:
请运行 echo hello 并原样输出
实际行为
Read
UI 显示 Read 工具执行成功,并且识别到了文件行数,例如:
Used Read (<some-file>) · N lines
但模型无法看到文件正文,并回复类似:
读取工具没有返回可见内容,因此无法原样输出。
或:
The file appears to be empty or could not be displayed from the read result.
Glob
UI 显示 Glob 找到了匹配文件,例如:
Used Glob (...) · N files
<UI 中显示了匹配文件列表>
但模型回复它没有从工具返回中看到任何匹配结果。
Bash
执行:
请运行 echo hello 并原样输出
结果正常:
Ran a command
$ echo hello
hello
说明 Bash stdout 可以正常进入模型上下文。
预期行为
当 Read 成功并报告读取到 N 行时,文件正文应被注入到模型可见上下文中,模型应能原样输出或总结文件内容。
当 Glob 成功并且 UI 显示匹配文件时,模型应能读取到同样的匹配文件列表。
补充验证
本地 shell 可以正常读取文件:
Get-Content .\<some-file> -TotalCount 5
Git Bash / shell stdout 也正常:
bash.exe -lc "pwd; echo hello; node -v"
配置检查通过:
kimi doctor
结果:
All checked config files are valid.
纯文本 prompt 模式正常:
kimi -p "只回复 ok"
结果正常返回:
ok
但 prompt 模式中,如果请求读取本地文件,则不会输出预期文件内容,只会创建/恢复 session,或没有有效正文输出。
另外,--prompt 不能与 --auto / --yolo 组合使用:
kimi --auto -p "Read a local text file"
结果:
error: Cannot combine --prompt with --auto.
kimi -y -p "Read a local text file"
结果:
error: Cannot combine --prompt with --yolo.
初步判断
问题看起来发生在结构化工具结果注入模型上下文的链路中。
目前证据:
Read工具执行成功,UI 能看到读取行数。Glob工具执行成功,UI 能看到匹配数量和文件列表。Bashstdout 能被模型正常读取。- 但
Read/Glob的实际结构化结果正文对模型不可见。
推测链路:
结构化工具生成结果
-> UI 摘要/渲染正常
-> 注入模型可见上下文时,结果正文丢失或被省略
影响范围
已观察到受影响:
ReadGlob
已观察到不受影响:
Bashstdout
建议排查方向
- 结构化工具结果序列化逻辑
- 工具结果正文注入模型上下文的逻辑
- UI 展示的工具摘要与模型实际接收到的 tool message 是否不一致
- Windows 环境下结构化工具 payload 的处理
- 交互式
kimi -y模式下工具结果传播链路
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in interactive kimi -y on Windows with Read, Glob, and Bash, comparing the UI summaries with the tool messages received by the model. Trace the structured-tool result serialization and context-injection path, including Windows payload handling. Done means the model can read Read file contents and Glob match lists while Bash behavior remains working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100