Skip to content

fix(node-sdk): honor --agent disallowedTools in the interactive TUI - #3441

Open
astraltrekkin wants to merge 1 commit into
MoonshotAI:mainfrom
astraltrekkin:cursor/oss-buddy-moonshotai-kimi-code-3417-fc71
Open

fix(node-sdk): honor --agent disallowedTools in the interactive TUI#3441
astraltrekkin wants to merge 1 commit into
MoonshotAI:mainfrom
astraltrekkin:cursor/oss-buddy-moonshotai-kimi-code-3417-fc71

Conversation

@astraltrekkin

Copy link
Copy Markdown

Related Issue

#3417

Problem

A custom agent's disallowedTools policy is applied in print mode (kimi --agent dev -p) but ignored in the interactive TUI (kimi --agent dev). With ~/.kimi-code/agents/dev.md denying Read/Write/Edit, the TUI main agent still exposes those tools (63 tools in llm.tools_snapshot) and can execute Read. Print mode correctly drops them (60 tools).

Root cause: the TUI creates sessions through SDKRpcClientV2.createSession, which discarded agentProfile / agentFiles and bound the default agent profile. Print mode binds the named profile via ISessionManager.create({ mainAgentBinding }).

What changed

SDKRpcClientV2.createSession now binds the startup --agent / --agent-file profile the same way print mode does:

  • Resolve the profile name (--agent, or the first --agent-file frontmatter name).
  • Register --agent-file paths on the workspace explicit loader before bind.
  • Pass mainAgentBinding into session create so tools / disallowedTools apply to the interactive main agent.
  • Reject an unknown --agent name at create (profile.unknown) instead of silently using the default profile.

Regression tests in packages/node-sdk/test/sdk-rpc-client-v2.test.ts cover the --agent denylist, an --agent-file that is not in user/project agent dirs, and unknown-name failure.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Interactive TUI sessions created through the v2 SDK dropped agentProfile
and agentFiles, so a custom agent's disallowedTools list never applied.

Co-authored-by: Noa <rainbowgore@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d3f7068

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d3f7068854

ℹ️ 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".

const next =
agentFiles !== undefined && agentFiles.length > 0 ? [...agentFiles] : undefined;
if (next === undefined && hostArgs.agentFiles === undefined) return;
hostArgs.agentFiles = next;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep explicit agent files scoped to each session

When two createSession calls with different agentFiles overlap, both mutate the App-shared IBootstrapService.args before awaiting an asynchronous workspace-loader reload. A reload can therefore read the other call's files, causing creation to fail with profile.unknown or, when the files define the same profile name, binding the wrong tools/disallowedTools policy. Sequential calls also replace or clear the workspace-wide explicit contribution even though agentFiles is documented as session-specific; pass the files through a session-scoped input rather than shared bootstrap state.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants