MoonshotAI / MoonshotAI/kimi-code
--agent custom agent's disallowedTools policy is ignored in the interactive TUI (works in print mode)
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.39.1
Which open platform/subscription were you using?
kimi code
Which model were you using?
k3
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
A custom agent file's `disallowedTools` policy is applied in print mode but silently ignored in the interactive TUI.
With `~/.kimi-code/agents/dev.md` declaring `disallowedTools: [Read, Write, Edit]`, `kimi --agent dev` starts a TUI session without error, but the main
agent's tool list still contains Read/Write/Edit and the agent successfully executes Read on the first prompt.
Verified via the session wire log (`agents/main/wire.jsonl` → `llm.tools_snapshot`):
- TUI session started with `--agent dev`: 63 tools, Read/Write/Edit present
- Print session started with `kimi --agent dev -p`: 60 tools, Read/Write/Edit absent
- Print session without `--agent`: 63 tools (control)
What steps can reproduce the bug?
- Create
~/.kimi-code/agents/dev.md:
---
name: dev
description: Default agent with Read/Write/Edit disabled
disallowedTools:
- Read
- Write
- Edit
---
${base_prompt}
2. Run `kimi --agent dev` (interactive TUI) and prompt: read @AGENTS.md
→ the agent calls the Read tool and succeeds (unexpected).
3. Compare with `kimi --agent dev -p "Reply with exactly: ok"`, then inspect the
new session's wire.jsonl: Read/Write/Edit are absent from llm.tools_snapshot.
What is the expected behavior?
Per https://www.kimi.com/code/docs/en/kimi-code-cli/customization/agents.html, --agent works in both print mode and the interactive TUI, and an agent's
tools/disallowedTools "shape the tools shown to the model and are enforced again before execution". The TUI startup session should bind the qwen profile
and exclude Read/Write/Edit from the main agent's tool set, exactly as print mode does. An unknown agent name should fail at startup on both paths.
Additional information
No response
Contribution
- I am willing to submit a PR for this bug fix myself (please wait for maintainer approval in this issue first)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the startup paths for kimi --agent dev and kimi --agent dev -p, using the custom agent definition in ~/.kimi-code/agents/dev.md and each session's agents/main/wire.jsonl tools snapshot. Done means the interactive TUI excludes Read, Write, and Edit just like print mode, and an unknown agent name fails at startup in both modes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100