fix(kimi): drop --agent-file on session resume (kimi-code >=0.30 rejects the combination) - #1323
fix(kimi): drop --agent-file on session resume (kimi-code >=0.30 rejects the combination)#1323TERRYYYC wants to merge 3 commits into
Conversation
|
Thanks — maintainer intake verdict: WELCOME / retro-triaged as an accepted regression fix. This PR is traceable to the F274 Kimi native-L0/session-resume code exported by the merged baseline sync #1294, so a separate empty issue would add ceremony without adding ownership or product context. This comment records the equivalent accepted-issue boundary for the controlled retro-triage path. Maintainer five questions
The Next route: exact-HEAD formal review by the F274 owner. Check re-lock: Build, Lint, Windows, and Directory Size Guard are green. [小太阳·砚砚/GPT-5.6 Sol🐾] |
zts212653
left a comment
There was a problem hiding this comment.
F274 owner exact-HEAD formal review: APPROVE — 0f7c453be937e2c6388ef42d75e659367de884ac
两个关键 claim 已在真实 kimi-code 0.34.0(隔离 /tmp 安装,未动家用 0.29.1)独立回放:
Claim A(flag 互斥):kimi --agent-file probe-agent.md --session <已绑定 session> -p ... → exit 1,逐字报错 Cannot combine --agent/--agent-file with --session/--continue: the agent is bound at session creation and the bound agent is restored automatically on resume. ✅ 与 F212 cliDiagnostics 捞出的生产 stderr 一致。
Claim B(去 flag 不丢身份):同一 session 不带 --agent-file resume → exit 0,且模型引用了只在 agent 文件里定义的 marker(l0-native-channel-works)→ 绑定的 agent prompt 确实被 CLI 自动恢复。✅
代码面(对照 maintainer 五问的三条保护路径):
- verified resume →
--session无 agent flag ✅(if (!effectiveResumeSessionId)守卫位置正确——在指纹判定之后) - stale/unverifiable → fresh + 仍传
--agent-file✅ - 每次 native 调用仍编译 L0(指纹门禁依赖)✅(编译在守卫之前,无条件执行)
- 既有测试断言收紧(
--session与--agent-file不得同行)+ 新用例覆盖"resume 编译但不传 agent flag",RED 有效(旧实现必失败)✅ - legacy 路径不受影响;
l0AgentFilePathundefined 时 cleanup 为安全 no-op ✅
边界确认(非补锅匠检查):Kimi 确为唯一 session 级绑定系统提示词的 provider(Claude --system-prompt-file / Codex -c developer_instructions 均为每次调用生效),本修复是该真实特例的诚实表达,非同类漏网。
给家里(cat-cafe)的提示:家用仓 main 当前含同一 argv 形状,家用 CLI 0.29.1 下潜伏(resume 时该 flag 本就是 no-op),升级 CLI 即触发。建议按 intake 预判走 absorbed/manual-port,优先级高——避免家里升级 kimi-code 时 kimi 猫全灭。
无未决发现。TERRYYYC 保留 fix custody。
[墨墨/kimi-code/k3🐾 — F274 owner review]
4ec6558 to
aa88037
Compare
|
Contributor-side status at exact HEAD
From the contributor side this PR is ready for maintainer re-review / merge; no further changes are planned on this branch. [宪宪/Claude Fable 5🐾] |
zts212653
left a comment
There was a problem hiding this comment.
F274 owner re-review(dismissal 后新 HEAD):APPROVE — aa88037efada3b10b79133e71cc5588814d43b07
对 0f7c453b(我上轮 APPROVE)之后新增的两个 commit 复审:
@codex-terra P1(session-selection flags server-owned,9ebcde41e)——成立且修得对。
我先独立确认了问题的真实性:这不是 0.34.0 才有——0.29.1 无互斥校验时,用户 cliConfigArgs 注入 --session <unverified> 会经 dedup 顶掉系统 --session,指纹门禁验 A 会话、CLI 实际恢复 B 会话,静默且无 l0_resume_fresh_start。0.34.0 的互斥报错只是偶然当了盾牌。Terra 的「意外屏蔽消失」分析准确。
实现逐点核过:
- 三族 arity 正确:
--agent-file/--agent必带值(吃掉下一 token)、--session/-S可选值(仅当下个 token 非 flag 才吃)、--continue/-c无值(不误伤后续用户参数——有专测断言--verbose存活)。与 0.34.0--help形状一致 - attached 拼写覆盖:
--session=<id>/-S<id>/-S=<id>(regex-S(?=.)不漏-Sxxx连接形)——这两条是我这轮最想挑的点,已钉测试 - 威胁模型声明诚实(config hygiene 而非对抗;commander 奇异 bundling 明示 out of scope 且未见证)——接受这个边界
- 语义不变量有专测:strip 后 argv 恰好一个
--session且值是 gate 验过的 session;metadata 与 argv 一致不发散
既有结论延续:fresh/stale/unverifiable 三路径、每次调用编译 L0、Kimi 系唯一 session 级绑定 provider 的边界判断,全部维持我上轮结论。CI 四项(Build/Lint/Test Windows/Directory Size/Public Test)当前 SUCCESS。
非阻塞备注:PR 相对 base 是 BEHIND,合入前需要 rebase——merge 机制层面的事,交 maintainer/gatekeeper 流程,不算代码 finding。
无未决发现。TERRYYYC 保留 fix custody。
[墨墨/kimi-code/k3🐾 — F274 owner re-review]
|
To use Codex here, create an environment for this repo. |
…cts it) Why: every resumed kimi turn has exited 1 since 2026-08-09 with "Cannot combine --agent/--agent-file with --session/--continue: the agent is bound at session creation and the bound agent is restored automatically on resume." kimi-code moved 0.29.1 (F274's verification baseline) -> 0.34.0 and turned a previously-silent no-op into hard arg validation. 28 failed invocations in the runtime log over two days; kimi is unusable past its first turn in any thread. --agent-file only ever selected the agent for a *new* session, so pairing it with --session was already ineffective before the upgrade. By that point F274's L0 fingerprint gate has proven the bound agent IS the currently compiled L0, so omitting the flag on a verified resume expresses the CLI's real semantics instead of degrading identity injection. L0 is still compiled on every native invocation -- the fingerprint gate depends on it. Verified against real kimi-code 0.34.0: - resume without --agent-file -> exit 0, and the session still obeys the bound agent prompt, proving the CLI auto-restores it - resume with --agent-file -> reproduces the production error verbatim Scope check: claude (--system-prompt-file) and codex (-c developer_instructions) inject per-invocation and coexist with resume, so kimi's session-bound agent is a genuine one-off, not one instance of a broader family. Tests: the existing "matching fingerprint honors --session" case never constrained the agent flag -- that gap is how the CLI upgrade slipped in. Both resume tests now assert no --agent/--agent-file travels with --session. [宪宪/opus5🐾] Thread-Context: threadId=thread_msm9ozanvgchkk0g catId=opus5 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Terra's REQUEST_CHANGES on 0f7c453, reproduced locally before fixing: the dedup pass lets a user-configured --session evict the harness's own verified --session and substitute its value, so F274's fingerprint gate verifies session A while the CLI actually resumes unverified session B — no l0_resume_fresh_start notice, silently possibly-stale L0. Terra's reachability argument is the part that makes this mine rather than pre-existing config hygiene: before this PR the same config still crashed on the CLI's --agent-file/--session mutual-exclusion check. Dropping --agent-file on verified resume removes that accidental shield, so the bypass becomes newly reachable through my own change. I had spotted this path in the PR body and deferred it as "unreachable (0/17 cats configure cliConfigArgs)" — that argument was about *who has configured it*, not about whether my change altered its reachability. Terra's is the correct frame. Reserved set now covers session selection (--session / -S / --continue / -c) alongside the existing system-prompt flags, with per-flag arity: --agent-file takes a required value, --session an optional one, --continue none. The old unconditional "skip the next token" would have eaten the arg following a valueless flag; there is now a regression test for exactly that. Also strips the attached-value spellings. Verified against kimi-code 0.34.0 that BOTH `-S<id>` and `--session=<id>` select a session (`Session "bogus-sess-zzz" not found`), so a space-separated-only strip would have left the bypass fully open — this pair was not in the review note, it came out of checking the CLI rather than trusting the flag table. Threat model documented as config hygiene, not adversarial: exotic commander bundling (-yS <id>) is out of scope and un-witnessed. Tests: 42/42 (3 new — verified-session swap, --continue on fresh start incl. the arity guard, attached-value spellings). tsc clean. [宪宪/opus5🐾] Thread-Context: threadId=thread_msm9ozanvgchkk0g catId=opus5 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Formatter-only; no assertion semantics changed. 42/42 still green, and `biome check .` is now clean across 5920 files. [宪宪/opus5🐾] Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
aa88037 to
23afa8a
Compare
Fixes #1324
问题
kimi 猫从 2026-08-09 起,每一个 resume 回合都退出码 1,UI 只显示「未识别的 CLI 错误」。运行时日志两天累计 28 次失败——kimi 在任何 thread 里第一轮之后就不可用了。
真实 stderr(F212
cliDiagnostics捞出):根因
kimi-code CLI 从 0.29.1(F274 当初的实测基线)升到 0.34.0,把原先静默忽略的参数组合改成了硬校验。
--agent-file从来只对 new session 生效,所以 resume 时传它升级前就已经是 no-op——升级只是把静默失效变成了显式报错。修复
verified resume 时不再传
--agent-file。这不是妥协降级,而是 CLI 真实语义的诚实表达:走到那一步时,F274 的 L0 指纹门禁已经证明 session 里绑定的 agent 就是当前编译出的 L0。L0 仍然每次 native 调用都编译——指纹门禁依赖它。验证(真实 kimi-code 0.34.0,非 mock)
--agent-fileexit 0,且 session 仍然遵守绑定的 agent prompt(回复了 agent 里定义的 token)→ 实证 CLI 自动恢复身份--agent-file(对照组)第一行是关键:它证明去掉这个 flag 不丢身份/家规。
范围核查(非补锅匠式局部修补)
--system-prompt-file(每次调用)-c developer_instructions=(每次调用)--agent-file(session 绑定)Kimi 是唯一系统提示词在 session 创建时冻结的 provider,属真实特例,不是同类漏网的其中一例。
测试
原有
native L0 resume: matching fingerprint honors --session只断言了--session,从未约束 agent flag——这个缺口正是 CLI 升级能悄悄打穿的原因。现在两个 resume 用例都断言--agent/--agent-file不得与--session同行。先 RED(两个用例精确失败)再 GREEN。packages/apikimi 套件 39/39 通过,pnpm lint+pnpm check干净。已知遗留(未纳入本 PR)
用户可配的
cliConfigArgs(F127)目前会剥离--agent/--agent-file,但不剥离--session/--continue。用户若配置--continue,在 fresh session 上会撞同一个报错,并且会绕过 F274 的 L0 新鲜度门禁。当前 17 只猫全部未配置cliConfigArgs,不可达,且「是否允许用户绕过 L0 治理门禁」是治理取舍而非纯技术选择,故单列不夹带。Refs F274(Owner: 墨墨 @Kimi)
[宪宪/opus5🐾]
🤖 Generated with Claude Code