fix(kimi-code): honor --agent-file and --agent at TUI launch - #2770
fix(kimi-code): honor --agent-file and --agent at TUI launch#2770mohidmakhdoomi wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 4be5df6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ec11430ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
7ec1143 to
957bee6
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 957bee61eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
957bee6 to
88b43b1
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The interactive TUI runs on the agent-core-v2 engine by default, and that engine's SDK client dropped both agent options at session creation: it read only the session id, work dir, additional dirs, model, thinking, permission and metadata, then bound the default profile. The startup session therefore started on the built-in agent with no warning, while print mode — which takes a different path — bound the requested one. Register explicit agent files on the client's engine bootstrap, the way skill directories already are and the way print mode already registers the same flag, and pass a requested profile into the bind the client already performs for the model and thinking effort. That bind deliberately stays where it is, after the session is wired: it publishes the oversized AGENTS.md and tool-pattern warnings, the agent event bus has no replay, and the tool-pattern warning is emitted once per pattern, so binding any earlier would drop them. Binding that late means the session already exists by the time an unusable profile name is caught, and creating a session runs the SessionStart hook and records the start as its last step. So the name is resolved against the workspace's agent catalog before anything is created, the way the legacy engine resolves it before its store write, and deleting the session is kept only as a backstop for a bind that fails after that check passes. The CLI hands the files to the harness, which is built before any session exists and is the only place a launch-wide registration can happen. Selecting a profile stays per-session, so a session created later still starts on the default agent — though a file named after a built-in agent keeps replacing that built-in for the rest of the launch, which the docs now state.
88b43b1 to
e1f1ce3
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Two files conflicted, both where main rewrote a region this branch also touches: - packages/node-sdk/src/sdk-rpc-client-v2.ts — the engine import block, where MoonshotAI#2871 replaced the agent RPC aggregation layer with IAgentPluginCommandService and MoonshotAI#2700 removed IModelCatalog along with the secondary-model machinery. Main's removals are kept and this branch's additions re-applied on top of them; no removed service is resurrected. - docs/zh/reference/kimi-command.md — main unified the locale on "main agent" and "subagent", so the --agent-file paragraph this branch adds is restated in that terminology. One comment was rewritten rather than merged as-is. The rollback in createSession justified its handle-identity check with the SESSION_ALREADY_EXISTS check not being atomic, which MoonshotAI#2351 has since made false: an explicit id now runs the whole create behind a per-session queue. The check itself stays, because the engine's create still registers its handle without a duplicate-id guard of its own, but it is now described as what keeps a rollback from taking a session the call did not create. The claims the rest of the change rests on were re-verified against the merged tree: session creation still awaits the same five workspace profile loaders, still announces the finished session as its last step, and MoonshotAI#2896's move of the session lifecycle hooks onto lifecycle events leaves SessionStart and SessionEnd firing from create and close as before.
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@sailist @pvzheroes125 @7Sageer @liruifengv @wbxl2000 please review and merge this PR, it will be great help in enabling us to support Kimi Code in Codev cluesmith/codev#1203 |
Related Issue
Resolve #2767
Problem
See linked issue: launching the interactive TUI with
--agent-fileor--agentsilently starts the session on the built-in default agent. The same flags work in-pprint mode, so there is no error — just the wrong agent.What changed
The interactive TUI runs on the agent-core-v2 engine, whose SDK client dropped both agent options at session creation and always bound the default profile. Print mode takes a different path and was unaffected.
--agent-fileto the harness, which forwards it to the engine'sBootstrapInput.args.agentFilesthe same way--skills-diris already forwarded. The SDK gains a matchingagentFilesharness option (createKimiHarnessV2only; the option's docs say so).SessionStarthook runs orsession_startedis recorded — same order as the legacy engine. The rejection also carries the legacy engine's public error shape (KimiErrorwithagent.not_found) on both engines, keeping one error contract for SDK consumers.Tests: nine agent-path tests across the SDK client and CLI suites, each failing without the fix.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.