fix(kimi): forward role-specific model config to launch (restore deferred pending CLI verification)#2985
fix(kimi): forward role-specific model config to launch (restore deferred pending CLI verification)#2985anmol0b wants to merge 2 commits into
Conversation
codebanditssss
left a comment
There was a problem hiding this comment.
Careful PR, and the tests are the strongest part — reflect.DeepEqual against the full argv including flag ordering, plus the whitespace-only case and composition with the approval flags. That's the version of these tests that actually catches a regression rather than just executing the line. go test ./internal/adapters/agent/kimi/... green locally, all 9 checks green.
On deferring the restore path — I think that's right, and I can back it with precedent. You framed it as caution pending verification, but it also matches what the codebase already does:
claudecodeforwards--modelon launch (claudecode.go:172), and itsGetRestoreCommandemits only--resume <sessionID>plus an optional--append-system-prompt. No model.codexis the one that wires both (codex.go:109 and :151).
So launch-yes/restore-no is what the most prominent adapter already does. Kimi matching claudecode here isn't a gap to close later, it's the dominant existing shape — worth noting in case that changes how urgent the follow-up feels.
Approving. Two non-blocking notes inline, both about comments and prose rather than behaviour.
| // --session the way it does on the launch path (see issue #2890); wiring it | ||
| // blind risks silently breaking session resume. Left as a fast-follow pending | ||
| // verification against a real kimi install. | ||
| func appendModelFlag(cmd *[]string, cfg ports.AgentConfig) { |
There was a problem hiding this comment.
This doc comment is good and does the job it claims. The other half of the pair doesn't exist though.
The PR description says "a doc comment on appendModelFlag and an inline comment on GetRestoreCommand both point back to this decision." GetRestoreCommand is untouched by this diff and carries no such comment.
That matters a little more than a typical missing comment, because the scenario you're defending against is specifically someone opening GetRestoreCommand to "just mirror Codex" — and that person is looking at the function you didn't annotate. They'd have to already know to check appendModelFlag, or discover it by tripping the test.
TestGetRestoreCommandDoesNotForwardModelOverride does catch it, so the safeguard genuinely holds and this isn't a correctness issue. But the breadcrumb you designed for is the cheaper of the two to hit, and it's a two-liner:
func (p *Plugin) GetRestoreCommand(ctx context.Context, cfg ports.RestoreConfig) (cmd []string, ok bool, err error) {
// Deliberately does not forward cfg.Config.Model: --model + --session
// composition is unverified against a real kimi install (see #2890 and
// appendModelFlag). Pinned by TestGetRestoreCommandDoesNotForwardModelOverride.| } | ||
|
|
||
| // GetConfigSpec reports the per-project agent config keys Kimi understands. | ||
| func (p *Plugin) GetConfigSpec(ctx context.Context) (ports.ConfigSpec, error) { |
There was a problem hiding this comment.
Not about this hunk, but this is the closest anchor — the sibling list in the description is broader than what's actually on main.
Checking origin/main:
- copilot has no model forwarding at all, so fix(copilot): forward role-specific model config to launch and restore #2975 isn't merged.
- vibe likewise, so Vibe ignores role-specific model config on launch #2897 isn't either.
- kiro does handle the model, but through a different mechanism entirely — it writes it into a hooks file (kiro/hooks.go:268) rather than passing a CLI flag.
So "matching claude-code, codex (#2869), kiro (#2932), and copilot (#2975)" is in practice "matching claude-code and codex." Doesn't change a line of this PR, but a reviewer taking it at face value would build the wrong mental map of where the audit series has actually landed, and kiro in particular isn't a precedent for the flag approach at all.
Worth a quick edit to the description so the series stays legible as it grows.
Also minor: the last two checklist boxes are unticked, but all 9 checks are green on this head.
|
@anmol0b — new information relevant to the restore deferral here, which arrived after I approved. @Hardik180704 verified the equivalent composition against a real Pi CLI in #2989:
That's the first actual evidence in the series — every one of these PRs, including this one, had been reasoning from the same absence of it. To be clear about what it does and doesn't show: it settles Pi, not Kimi. They're different CLIs that happen to share a But it does mean the cost of checking is now known to be low — one resume against a real install — and it shifts the prior. Worth knowing because Nothing blocking — this stays approved either way. Just didn't want the deferral to outlive the uncertainty that motivated it. |
illegalcall
left a comment
There was a problem hiding this comment.
Reviewed and approving. ✅
- gofmt clean,
go vetclean, fullkimipackage test suite passes locally (go 1.24.1). - Verified against Moonshot's docs that
kimi --model <model>is a real, documented launch flag, so the launch-path forwarding will take effect. - Especially appreciate the discipline on the restore path: not forwarding
--modelalongside--sessionwhen the composition is unverified, documenting exactly why, and locking the decision in withTestGetRestoreCommandDoesNotForwardModelOverrideso a future "just mirror Copilot/Codex" edit can't silently regress it. This is the right posture when the CLI behavior can't be confirmed.
|
Thanks for contributing to Agent Orchestrator. This PR is being picked up by the current external contributor on-call pair: If someone is already working on this, please continue as usual. For faster context or live questions, you can also join the AO Discord. Join the session here: Come by if you want to see what is being built, ask questions, or just hang around with the community. |
|
Thanks for catching this @codebanditssss Added the missing breadcrumb comment on On the restore deferral: I don't have a real kimi install to verify |
What
Adds
appendModelFlagto the Kimi adapter, called fromGetLaunchCommand, so a configuredagentConfig.modelis forwarded as--model <model>to thekimiCLI. Also adds a GetConfigSpec override advertising the model field, matching claude-code and codex (#2869). (kiro #2932 handles model config through a hooks file rather than a CLI flag, so it isn't precedent for this approach; copilot's equivalent fix, #2975, is still open and not yet merged.)Unlike the Copilot fix, this does not wire
appendModelFlagintoGetRestoreCommand.Kimi's docs don't confirm
--modelcomposes with--sessionon resume, so forwarding itthere is left as a documented fast-follow rather than guessed at.
Why
Fixes #2890. A Kimi worker/orchestrator configured with a specific model silently fell back
to
kimi's global default because the adapter never readcfg.Config.Model— sameroot-cause pattern as #2769 (Codex), #2895 (Copilot), and #2897 (Vibe) in this audit series.
How
appendModelFlagpattern: appends--modelonly whenstrings.TrimSpace(cfg.Config.Model)is non-blank, so an unconfigured launch isbyte-for-byte unchanged.
GetRestoreCommandis intentionally left unchanged. A doc comment onappendModelFlagand an inline comment on
GetRestoreCommandboth point back to this decision, and adedicated regression test (
TestGetRestoreCommandDoesNotForwardModelOverride) locks it inso a future "just mirror Copilot/Codex" edit doesn't silently wire it without verifying
kimi --model X --session Yagainst a real install first.TestGetConfigSpecEmpty(asserted zero fields) withTestGetConfigSpecAdvertisesModelField, since that assumption no longer holds oncemodelis declared.Testing
Full package run, all passing (35 tests, no regressions):
TestGetConfigSpecAdvertisesModelFieldTestGetLaunchCommandAppendsModelFlagWhenConfiguredTestGetLaunchCommandOmitsModelFlagWhenBlankTestGetLaunchCommandModelFlagComposesWithApprovalFlagsTestGetRestoreCommandDoesNotForwardModelOverrideOpen follow-up
Verify
--model+--sessioncomposition against a realkimiinstall, then wireappendModelFlagintoGetRestoreCommandin a follow-up PR (tracked against #2890).Checklist
main(or continuing an existing PR branch)go, frontend, etc.)