MoonshotAI / MoonshotAI/kimi-code

TUI ignores --agent-file at launch; startup session binds default agent (works in -p print mode)

Open
#2,767 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

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.bind records profileName: "agent" (the default) with the stock ~20.9 KB system prompt; the agent file content appears nowhere in the log.
  • --yolo passed on the same command line DOES take effect (a second permission.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?
  1. Create an agent file, e.g. test.md:

    ---
    name: codev-builder
    description: Codev builder role
    ---
    # Custom instructions
    ...
    
  2. Launch the TUI: kimi --yolo --agent-file test.md

  3. Send any prompt.

  4. 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:

  • #2765 — custom agent profile IS selected interactively, but its tools/disallowedTools frontmatter policy is ignored in the TUI while -p enforces it (same-day, v0.34.0).
  • #2339 — agent file catalog is scanned once and cached per session in kimi web (SessionAgentProfileCatalogService), so newly written agent files are never dispatchable.
  • #2188 (closed) — precedent for the pattern: secondary_model honored 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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace the --agent-file handling from CLI argument parsing into the interactive TUI startup path, then compare it with the working kimi -p print-mode path. Use the session wire log's profile.bind event to verify that the custom profile is selected and its content is included in the system prompt, while confirming existing flags such as --yolo still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.