fix: drop non-existent --print/--afk flags from the kimi CLI provider argv - #4242
Merged
Conversation
… argv (#4139) server/lib/kimi.js was written without a live `kimi` binary. Verified against kimi v0.32.0: `--print` and `--afk` are not options at all (`error: unknown option`), so every headless kimi-cli run died at argv parsing before doing any work. Non-interactive mode is implicit in supplying `-p`/`--prompt`, and kimi refuses to combine `--prompt` with `--yolo`/`-y`/`--auto`, so the headless path gets no mode flag and no approval posture — only `--model <id>` when pinned. The seeds (data.reference/providers.json, providers.sample.json) baked `args: ["--print"]` into kimi-cli, and migration 201 shipped that to existing installs, so removing the injection alone would leave deployed installs broken. Migration 269 strips both dead tokens from a stored kimi provider's args wherever they appear — unlike the usual "only rewrite an exactly-matching old default" rule, because neither flag exists in the binary, so keeping one is never a valid user preference.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server/lib/kimi.jswas written without a livekimibinary to check against, and the guesses were wrong in a way that broke the provider outright. Verified againstkimiv0.32.0:--printis not an option (error: unknown option '--print'/(Did you mean --prompt?)).ensureKimiHeadlessArgspushed it unconditionally, so every headlesskimi-clirun exited at argv parsing before doing any work. Non-interactive mode is implicit in supplying-p/--prompt; there is no separate mode flag.--afkis not an option either (error: unknown option '--afk'), so it is gone fromAPPROVAL_FLAGS.--promptwith--yolo/-y/--auto(error: Cannot combine --prompt with --yolo.) and runs unattended without one.ensureKimiHeadlessArgsnow adds only--model <id>when a real model id is pinned. The interactive TUI path (no--prompt) keeps--yolo, which parses cleanly.Prompt delivery is unchanged:
-p, --prompt <prompt>takes the prompt as the flag's argv value, and no stdin or--prompt-filemechanism exists, soprepareKimiPrompt'suseStdin: falsesplice is correct as shipped.Also fixed: the seeds and already-deployed installs
Removing the injection alone would not have fixed anything deployed. The
kimi-cliseed bakedargs: ["--print"]intodata.reference/providers.jsonandserver/lib/aiToolkit/defaults/providers.sample.json, and migration201-kimi-providersshipped that same frozen def to existing installs.setup-data.jsmerges only missing provider entries and never updates existing ones, so a storedkimi-cliwould have kept the fatal token forever.args: []forkimi-cli.269-kimi-drop-nonexistent-flagsstrips--print/--afkfrom a storedkimi-cli/kimi-tuiprovider's args. Unlike the usual conservative rule (see121-codex-tui-bypass-sandbox, which rewrites only an exactly-matching old default), this one removes the tokens wherever they appear, including from a hand-curated list — neither flag exists in the binary, so keeping one is never a valid user preference, it is a guaranteed startup failure. Every other arg is preserved in order.Deliberately out of scope
--output-format stream-json. It exists (--output-formattakestext(default) orstream-json) and would let a pipeline stage parse discrete JSON events instead of scraping possibly-interleaved plain text, but no stage parses kimi's stdout programmatically today, sotextstays the default. Noted in the file header rather than adopted.providerUsage.jsFAMILIESentry.kimi --helpexposes no usage/quota command in this version (kimi provider listshows configured providers and model counts, not consumption), so there is nothing to hook up.The remaining known limitation — a large prompt riding argv against Windows' ~32K limit / POSIX
ARG_MAX— is now documented as confirmed rather than speculative:-p <value>is the only prompt mechanismkimi --helpdocuments, so there is no lower-risk delivery to switch to.Docs/comments updated alongside: the
kimi.jsheader,cliProviderArgs.js's per-CLI convention table and prompt-dispatcher notes, and theserver/lib/README.mdcatalog row.Test plan
cd server && NODE_ENV=test npm test— full server suite green (1387 files, 28935 tests passed, 26 files / 252 tests skipped for the usual Postgres gating).server/lib/kimi.test.jsrewritten to assert the concrete corrected argv arrays rather than the old--print-bearing ones, plus:ensureKimiHeadlessArgsnever introduces--print,--afk,--yolo,-y, or--autoacross a matrix of base args and model values;ensureKimiHeadlessArgs→prepareKimiPromptand spells out the full spawn-site argv, so a regression cannot hide behind two individually-plausible halves.scripts/migrations/269-kimi-drop-nonexistent-flags.test.jscovers: the seeded["--print"]case, stripping out of a curated list while preserving order, a--afkpinned onkimi-tui, no-op when already clean, leaving other providers that legitimately use--print(claude-code, antigravity) alone, missing provider, non-arrayargs, missingdata/providers.json, and invalid JSON.server/lib/cliProviderArgs.test.jsandserver/lib/tuiHandshake.test.jsupdated for the corrected argv, including an explicit "never injects--printor--afk" assertion at thebuildCliArgslevel.Closes #4139