Repository navigation
Description
What version of Kimi Code is running?
0.38.0
Which open platform/subscription were you using?
Kimi Code (kimi.com/code)
Which model were you using?
K3-256k thinking
What platform is your computer?
Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 unknown
What issue are you seeing?
Launching the interactive TUI with --agent-file <path> silently ignores the flag: the startup session binds the built-in default agent instead of the agent defined in the file. The same flag works correctly in non-interactive print mode (kimi -p), so the agent file itself parses fine — the defect is specific to the interactive TUI startup path.
Evidence from the session wire log (~/.kimi-code/sessions/<wd>/<session>/agents/main/wire.jsonl):
profile.bindrecordsprofileName: "agent"(the default) with the stock ~20.9 KB system prompt; the agent file content appears nowhere in the log.--yolopassed on the same command line DOES take effect (a secondpermission.set_mode: "yolo"event is recorded right after the config default), so this is not a general "TUI drops all launch flags" issue — it is specific to--agent-file.- No warning is emitted to the session log or the global diagnostic log (
~/.kimi-code/logs/kimi-code.log) — the flag is dropped silently.
Print-mode control test on the same version and file binds correctly, with both syntaxes:
kimi -p "Reply with exactly: ok" --agent-file=test.md # → profileName: "codev-builder"
kimi --agent-file test.md -p "Reply with exactly: ok" # → profileName: "codev-builder"What steps can reproduce the bug?
-
Create an agent file, e.g.
test.md:--- name: codev-builder description: Codev builder role --- # Custom instructions ...
-
Launch the TUI:
kimi --yolo --agent-file test.md -
Send any prompt.
-
Inspect the session wire log:
grep -o "\"profileName\":\"[^\"]*\"" \ ~/.kimi-code/sessions/<wd>/<session>/agents/main/wire.jsonl
Reproduced across two separate TUI launches; both startup sessions bound the default agent.
What is the expected behavior?
profile.bind shows profileName: "codev-builder" and the agent file content is inlined into the system prompt, per the docs: "--agent-file registers a single agent file at the highest priority for this launch only and selects it ... in the TUI the flags bind only the startup session."
Additional information
Possibly related reports with the same "interactive TUI fails to apply agent profile configuration; -p print mode works" shape:
- [Bug]: Agent profile tools/disallowedTools ignored in interactive mode (works in -p mode with KIMI_CODE_EXPERIMENTAL_FLAG=1) #2765 — custom agent profile IS selected interactively, but its
tools/disallowedToolsfrontmatter policy is ignored in the TUI while-penforces it (same-day, v0.34.0). - kimi web: agent files written after session start are never dispatchable ("Unknown agent type") #2339 — agent file catalog is scanned once and cached per session in
kimi web(SessionAgentProfileCatalogService), so newly written agent files are never dispatchable. - secondary_model is ignored by the interactive TUI (v1 engine) #2188 (closed) — precedent for the pattern:
secondary_modelhonored in print mode, ignored by the interactive TUI (v1 engine).
Contribution
- I am willing to submit a PR for this bug fix myself (please wait for maintainer approval in this issue first)
Activity
fix: 16 verified ACP + engine + CLI regressions (post 0.36.0 sync) (#48)
mohidmakhdoomi commentedon Aug 22, 2026
@liruifengv this bug is fixed in #2770, I opened it Aug 10, before the approved-bug-fix-only policy landed in #3089 (Aug 19), so there's no /approve here yet. Requesting one so the PR is on-policy.
Source is 249 added / 20 deleted across three packages:
apps/kimi-code/src/cli/run-shell.ts+5 — forwards the flagpackages/node-sdk/src/sdk-rpc-client-v2.ts+208/-17 — the actual fixpackages/node-sdk/src/types.ts+26/-3 — newagentFilesharness option, hence the SDKminorpackages/agent-core-v2/src/program/program.ts+10Plus 347 lines of tests and one docs line each in en/zh.
--agent <name>is fixed alongside--agent-file.mohidmakhdoomi commentedon Sep 9, 2026
Hi @liruifengv any chance this will be fixed?
Einherjare commentedon Sep 11, 2026
Still reproduces on 0.42.0: the TUI's startup session ignores
--agent-fileand gets the default agent with every tool,BashincludedReproduced on 0.42.0, and still present on
mainat72dbb9bb(11 Sep).With a read-only agent file, the TUI's first session gets the full default tool list, including
Bash,WriteandEdit, so the restriction the file declares silently disappears.The same file binds correctly in print mode.
Environment
@moonshot-ai/kimi-code0.42.0 from npm;kimi --versionprints0.42.0; the release tag@moonshot-ai/[email protected]points at6954d2c8.type = "kimi", model namek3), so the result does not depend on the model.env -i) apart fromHOME,KIMI_CODE_HOME,PATH,TERM,KIMI_CODE_NO_AUTO_UPDATE=1andKIMI_DISABLE_TELEMETRY=1.Steps to reproduce
Save this as
~/project/readonly.md:Print mode, as the control:
cd ~/project && kimi -p "Reply with: ok" --agent-file readonly.mdTUI:
cd ~/project && kimi --agent-file readonly.md, sendhello, then/exit.For each of the two sessions, read the main agent's wire log:
Expected
The TUI session binds the same agent as print mode:
profileNamereadonly-probe, with toolsGlob,GrepandRead.The docs say
--agentand--agent-fileselect the agent for a new session "in both print mode (kimi -p) and the interactive TUI" (docs/en/reference/kimi-command.md:101), and "in the TUI the flags bind only the startup session" (:108).Actual
profile.bindprofileNamereadonly-probeGlob,Grep,ReadagentBash,WriteandEditNo warning is shown or logged.
/newalso starts with the default agent, whichkimi-command.md:108documents as intended, so the defect is the startup session only.Evidence from the source (at
6954d2c8, the 0.42.0 tag)apps/kimi-code/src/tui/kimi-tui.ts:886-895putsagentProfileandagentFilesinto the startupcreateSessionOptions, and:2290-2299passes them for the first lazily created session, so the TUI does hand the selection over.packages/node-sdk/src/sdk-rpc-client-v2.ts:1324-1364:doCreateSession(input: CreateSessionOptions)readsid,workDir,additionalDirs,model,thinking,permissionandmetadata.It never reads
input.agentProfileorinput.agentFiles(declared inpackages/node-sdk/src/types.ts:232-237), and it callsISessionManager.createwithout amainAgentBinding.sdk-rpc-client-v2.ts:1672-1689:materializeMainAgentalways bindsprofile: DEFAULT_AGENT_PROFILE_NAME.apps/kimi-code/src/cli/v2/run-v2-print.ts:472-479passesmainAgentBinding: { profile: agentProfileName ?? 'agent', model }tosessions.create, which is why it works.mainat72dbb9bb,sdk-rpc-client-v2.tsstill bindsDEFAULT_AGENT_PROFILE_NAMEand still does not referenceagentProfileoragentFiles.The open PRs #2770 (this issue), #2832 (#2765) and #3441 (#3417) each address this dropped binding in
createSession.Workaround
[tools] disabled = [...]inconfig.tomlis enforced in the TUI, after/newas well.It applies to the whole process, so give the restricted TUI its own
KIMI_CODE_HOMEwith its ownconfig.toml.docs/en/customization/agents.md:158,$KIMI_CODE_HOME/SYSTEM.mdreplaces the default main-agent prompt in every launch mode, the TUI included.--agent-filebinds correctly.Version
0.42.0 (npm
lateston 11 Sep 2026), and still present onmainat72dbb9bb.Related: #2765, #3417; fix PRs #2770, #2832, #3441 (all open).