You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--agent custom agent's disallowedTools policy is ignored in the interactive TUI (works in print mode) #3417
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.
I'd like to contribute a bug fix for this issue. I reproduced the dropped profile binding with a regression test on a checkout based on 6de0cec and have a local fix ready.
The CLI already forwards --agent to the TUI. The loss occurs in SDKRpcClientV2.createSession: it does not forward agentProfile to the engine, and its model/permission initialization binds the default agent profile. Separately, lazy TUI session creation postpones validation of an unknown agent name until the first input.
The proposed fix passes the selected profile, model, and thinking settings through the engine's existing mainAgentBinding, avoids subsequently rebinding it to the default profile, and creates the startup session immediately when an agent was explicitly selected. Ordinary startup retains lazy session creation. This contribution is scoped to named agents selected with --agent; it does not implement the separate explicit agent-file loading path.
Validation on macOS with Node 24.19.0 / pnpm 10.33.0:
181 tests passed across the SDK wiring, SDK prompt events, TUI startup, CLI run-shell, and print-mode test files.
Regression coverage checks disallowedTools and tools against the actual model request, rejects a simulated Read tool call, preserves the selected policy on resume, and reports unknown names during startup.
SDK and CLI package typechecks passed; pnpm lint passed with 0 errors (existing repository warnings remain).
A CLI patch changeset is included locally. No Windows-specific execution has been performed.
Per CONTRIBUTING.md, could a maintainer approve a bug-fix PR for this scope with an /approve comment? No PR has been opened; I will wait for approval before opening one.
Activity
535628443 commentedon Sep 8, 2026
I'd like to contribute a bug fix for this issue. I reproduced the dropped profile binding with a regression test on a checkout based on 6de0cec and have a local fix ready.
The CLI already forwards
--agentto the TUI. The loss occurs inSDKRpcClientV2.createSession: it does not forwardagentProfileto the engine, and its model/permission initialization binds the defaultagentprofile. Separately, lazy TUI session creation postpones validation of an unknown agent name until the first input.The proposed fix passes the selected profile, model, and thinking settings through the engine's existing
mainAgentBinding, avoids subsequently rebinding it to the default profile, and creates the startup session immediately when an agent was explicitly selected. Ordinary startup retains lazy session creation. This contribution is scoped to named agents selected with--agent; it does not implement the separate explicit agent-file loading path.Validation on macOS with Node 24.19.0 / pnpm 10.33.0:
disallowedToolsandtoolsagainst the actual model request, rejects a simulated Read tool call, preserves the selected policy on resume, and reports unknown names during startup.pnpm lintpassed with 0 errors (existing repository warnings remain).Per CONTRIBUTING.md, could a maintainer approve a bug-fix PR for this scope with an
/approvecomment? No PR has been opened; I will wait for approval before opening one.