Repository navigation
Description
你运行的 Kimi Code 版本是?
2.6.0
你使用的是哪个开放平台/订阅?
kimi.com coding plan
你使用的是哪个模型?
kimi-3.1-pro
你的电脑平台是?
windows 11 x64
你遇到了什么问题?
问题摘要
在 Windows 上使用 Kimi Code CLI 2.6.0 的非交互模式 kimi --prompt 时,主代理可以正常完成模型请求并调用 Agent 工具,但前台子代理会在启动后几十毫秒内被取消,统一返回:
status: failed
stop_reason: timed_out
subagent error: Agent timed out after 0 hours.
[partial output] none — the subagent wrote no text in this run before it ended.
该问题同时出现在完整实现任务的 coder 子代理和不读写任何文件的最小 explore 健康检查中。三次 Agent 工具调用的报告耗时分别为 66 ms(首次实现调用)、17 ms(恢复调用)和 103 ms(最小健康检查)。恢复原 coder 子代理也立即失败。显式设置 KIMI_SUBAGENT_TIMEOUT_MS=7200000 后问题仍可复现,因此不是简单的超时时间过短。
环境
- Kimi Code CLI:2.6.0,native 安装
- 操作系统:Microsoft Windows 10.0.26200,x64
- 导出清单中的平台标识:
win32 x64 - Node.js 运行时标识:24.15.0
- Shell:
C:\Program Files\Git\bin\bash.exe - 工作目录:
D:/PYTHON/osta_certificate - 模型:
kimi-code/k3.1-pro,主代理和子代理均使用该模型 kimi doctor:config.toml与tui.toml均显示OK- 两个会话的 wire protocol:1.5
复现步骤?
最小复现
在 Git Bash 中执行:
KIMI_SUBAGENT_TIMEOUT_MS=7200000 kimi --prompt '这是一次只读的子代理健康检查。请同步调用一次 explore 子代理,让它仅返回 subagent-ok,不要读取或修改任何文件;收到后原样返回该文本。'主代理实际发起的工具调用为:
Agent(
subagent_type="explore",
run_in_background=false,
prompt="这是一次只读健康检查。不要读取或修改任何文件,也不要调用任何工具。仅返回以下文本,不要添加任何其他内容:subagent-ok"
)
预期:子代理返回 subagent-ok,主代理收到后原样输出。
实际:子代理没有返回任何文本,Agent 工具在 103 ms 后以 timed_out 失败;主代理随后如实报告未收到结果。
对应导出:exports/health-check-session.zip,会话 session_6e7afca5-ac55-4886-8b95-d8b27fbe9626。
原始故障与时间线
对应导出:exports/story-4.2-session.zip,会话 session_dccb621e-b882-4ca2-b18f-d985e42f3113。
主代理按照工作流同步启动一个 coder 子代理,要求读取故事规范并完成实现。底层 agents/main/wire.jsonl 记录如下:
- 2026-11-14 17:57:51.251 UTC:首次
Agent工具调用。 - 17:57:51.283 UTC:
subagent.spawned,runInBackground=false。 - 17:57:51.284 UTC:
subagent.started。 - 17:57:51.317 UTC:
subagent.cancelled。 - 17:57:51.318 UTC:工具返回
Agent timed out after 0 hours,durationMs=66。 - 17:57:57.385 UTC:使用
Agent(resume="agent-0", prompt="continue")恢复同一子代理。 - 17:57:57.387 UTC:恢复实例启动。
- 17:57:57.402 UTC:恢复实例被取消。
- 17:57:57.403 UTC:再次返回相同错误,
durationMs=17。
子代理自己的 agents/agent-0/wire.jsonl 显示:初始化和 step.begin 后立即出现 turn.cancel、turn.ended(reason=cancelled) 和 prompt.aborted;没有助手响应或工具调用。会话日志中存在子代理的 llm request,但没有对应的 llm response。与此同时,主代理的多次模型请求均正常收到响应。
独立健康检查的关键记录:
- 2026-11-14 18:02:27.040 UTC:同步调用
explore。 - 18:02:27.119 UTC:子代理启动。
- 18:02:27.142 UTC:子代理被取消。
- 18:02:27.144 UTC:工具返回相同错误,
durationMs=103。
已排除或尚未确定的事项
已确认:
- 故障发生在前台
Agent子代理的启动/超时/取消路径;不是子代理执行任务过久。 - 原任务和最小健康检查均在首个子代理模型响应前失败。
- 显式设置正向
KIMI_SUBAGENT_TIMEOUT_MS=7200000没有消除故障。 - CLI 配置校验正常,主代理模型请求正常。
- 这不是项目 PowerShell 脚本的 3600 秒停滞阈值触发;目标进程在两分钟左右已正常退出,而子代理实际只运行了几十毫秒。
尚未确定:
- CLI 内部具体哪段源码或哪个状态转换把前台子代理错误地判定为零小时超时。
- 是否影响其他模型、其他 CLI 版本或交互式 TUI;本次未验证这些组合。
- 是否能通过持久化
[subagent] timeout_ms配置绕过;本次仅验证了环境变量覆盖无效,未修改用户配置。
影响
依赖同步子代理的实现和独立审查工作流无法执行。每次失败都会要求主代理恢复子代理或停止任务,造成自动化批次无法完成。
另有一个独立的项目批处理问题:pwsh/run-stories-2.4-5.7.ps1 只检查 CLI 进程退出码,因此将已明确写入 status: blocked / no subagents 的故事计为成功并继续下一故事。该问题放大了故障影响,但不是子代理立即超时的根因。相关日志和脚本仅作为上下文附上。
附件
exports/story-4.2-session.zip:原始coder调用与恢复失败的完整官方会话导出。exports/health-check-session.zip:最小explore健康检查的完整官方会话导出。project-evidence/001-story-4.2.log:外层批处理捕获的故事日志。project-evidence/batch.log:批次将失败故事按退出码 0 结束并进入下一故事的记录。project-evidence/status.json:该批次留下的状态快照。project-evidence/run-stories-2.4-5.7.ps1:相关批处理脚本原文。manifest.json:附件用途、大小及 SHA-256。
两个会话导出均使用 --no-include-global-log。其中的 logs/kimi-code.log 是对应会话自己的日志,不是全局诊断日志。导出未包含 CLI 配置文件。高置信度凭据模式扫描未发现私钥、API token 或已填写的凭据字段。
期望的行为是什么?
No response
补充信息
kimi-subagent-failure-report-20261115-020852.zip
Contribution
- 我愿意自己提交修复此 bug 的 PR(请先等待维护者在本 issue 中批准)
Activity
shenxingy commentedon Nov 14, 2026
I reproduced this on Linux x64 (Kimi Code CLI 2.6.0,
kimi-code/k3.1-pro, print mode) and traced it to a single cause in the 2.6.0 bundle.Cause
applyPrintModeConfigDefaults()runsfillSectionDefault(config, SUBAGENT_SECTION, "timeoutMs", 0). It does the same forSWARM_SECTION. This only writes to memory, and only when the user has not set a value. It sits next tobashTaskTimeoutS = 0andmaxStepsPerTurn = 0, so 0 seems to mean "no limit" here.SubagentTooltakesresolveSubagentTimeoutMs(config), which returnsconfig.get("subagent")?.timeoutMs ?? 72e5. That value is now 0, and the tool passes it straight tosetTimeout(() => { timedOut = true; controller.abort("Timed out") }, timeoutMs). With 0, the abort fires on the next event-loop tick. That is why the subagent is cancelled within tens of milliseconds (your 17/66/103 ms) and the error reads "timed out after 0 hours".AgentRunBatch.linkAttemptSignalsarms no timer whentask.timeout <= 0. OnlySubagentTooldisagrees.Linux checks:
exploresubagent:Agent timed out after 0 hours;KIMI_SUBAGENT_TIMEOUT_MS=600000 kimi -p ..., it completes and returns the file contents.[subagent]/timeout_ms = 7200000in~/.kimi-code/config.toml, it completes.We did not test Windows, so we don't know why the env var has no effect there. The config file goes through a different path, so it is worth trying on Windows:
Suggested fix: in
SubagentTool, skipsetTimeoutwhentimeoutMs <= 0, the same way the swarm path does. Alternatively, print mode could stop writing 0 intosubagent.Related: #3187 (print mode does not honour
bash_task_timeout_s = 0either).Merge pull request #240 from shenxingy/docs/kimi-upstream-4943
LeafLIU210 commentedon Nov 15, 2026
Update from the reporter on Windows 11 x64 with Kimi Code CLI 2.6.0:
I have confirmed that the positive-timeout workaround resolves the immediate subagent failures on my machine.
I appended the following to
C:\Users\Leaf_\.kimi-code\config.toml:Verification results:
coderimplementation subagent successfully. The subsequent independent review subagents also return their findings normally.explorehealth check now completes and returnssubagent-ok.This confirms that setting a positive persistent timeout prevents print mode from applying
subagent.timeoutMs = 0, thereby avoiding the unconditionalsetTimeout(..., 0)failure path described in #4868.One clarification: the successful health check was run with both the persistent config entry and
KIMI_SUBAGENT_TIMEOUT_MS=7200000present. Therefore, it does not independently prove that the environment-variable-only workaround works on Windows. The workaround confirmed here is the positive value inconfig.toml.The underlying zero-timeout handling has been addressed in
mainby #4868. My installed 2.6.0 build still requires this positive-timeout workaround.I am closing this issue as completed because the root cause has been identified and fixed upstream, and the workaround has been verified on my side. Thank you for the analysis and fix. @shenxingy
LeafLIU210 commentedon Nov 15, 2026
Update from the reporter on Windows 11 x64 with Kimi Code CLI 2.6.0:
I have confirmed that the positive-timeout workaround resolves the immediate subagent failures on my machine.
I appended the following to
C:\Users\Leaf_\.kimi-code\config.toml:Verification results:
coderimplementation subagent successfully. The subsequent independent review subagents also return their findings normally.explorehealth check now completes and returnssubagent-ok.This confirms that setting a positive persistent timeout prevents print mode from applying
subagent.timeoutMs = 0, thereby avoiding the unconditionalsetTimeout(..., 0)failure path described in #4868.One clarification: the successful health check was run with both the persistent config entry and
KIMI_SUBAGENT_TIMEOUT_MS=7200000present. Therefore, it does not independently prove that the environment-variable-only workaround works on Windows. The workaround confirmed here is the positive value inconfig.toml.The underlying zero-timeout handling has been addressed in
mainby #4868. My installed 2.6.0 build still requires this positive-timeout workaround.I am closing this issue as completed because the root cause has been identified and fixed upstream, and the workaround has been verified on my side. Thank you for the analysis and fix. @shenxingy
shenxingy commentedon Nov 15, 2026
On the environment-variable question:
KIMI_SUBAGENT_TIMEOUT_MS=7200000on its own cannot help in print mode, because 7200000 is the registered default. A value from the environment is not auserValue, andisUnsetinagent/task/printDefaults.tstreats an effective value equal to the default as unset, soapplyPrintModeConfigDefaultswrites 0 over it. Any other positive value is kept (600000 worked on Linux), as is any value inconfig.toml. After #4868 this no longer fails, butKIMI_SUBAGENT_TIMEOUT_MS=7200000 kimi -pstill gets no limit instead of two hours.