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
When a VS Code window is opened as a multi-root workspace (.code-workspace with several folders), the Kimi Code extension starts the agent session with only the first workspace folder as its working directory. All other workspace folders are invisible to the agent: file tools cannot read or write them, and the model is not told they exist.
The CLI already supports this scenario (--add-dir, /add-dir, [workspace] additional_dir in local.toml), and the Node SDK exposes CreateSessionOptions.additionalDirs — but the VS Code extension never passes the remaining workspaceFolders through. In apps/vscode/src/bridge-handler.ts only workspace.workspaceFolders?.[0] is read to compute workDir; folders [1..] are dropped.
What steps can reproduce the bug?
In VS Code: File → Add Folder to Workspace…, add a second folder; save as a .code-workspace and reopen it (two or more root folders in the Explorer).
Open Kimi Code in that window and start a new session.
Ask the agent to read a file that lives in the second workspace folder (by absolute path), or to list the workspace roots.
Actual: the agent's working directory is the first folder only; files in the other folders are outside its scope (path access denied / not visible) unless the user manually runs /add-dir for each folder.
What is the expected behavior?
On session start the extension should pass workspaceFolders[1..] to the session as additional directories (ephemeral, per-session — same semantics as /add-dir), so the agent can work with all workspace roots without any manual setup. cwd stays on the primary folder, which is correct as the anchor for terminals and file pickers.
This matches what other agent extensions do — e.g. Claude Code's VS Code extension collects vscode.workspace.workspaceFolders, keeps the first as cwd, and passes the rest as additionalDirectories to its SDK at spawn time.
Additional information
Root cause (current main): apps/vscode/src/bridge-handler.ts computes workDir from workspace.workspaceFolders?.[0]?.uri only; KimiRuntime.openSession (apps/vscode/src/runtime/kimi-runtime.ts) calls harness.createSession({ workDir, ... }) without additionalDirs. Same for the resume path.
The engine side needs no changes: CreateSessionOptions.additionalDirs / ResumeSessionInput.additionalDirs already merge into the session and surface as the ## Additional Directories system-prompt section.
Proposed fix (2 files, VS Code app only): read workspace.workspaceFolders.slice(1) in bridge-handler.ts, add additionalDirs to OpenSessionOptions in kimi-runtime.ts, and pass it to both createSession and resumeSession (the additional-dirs set is ephemeral in v2, so it must be re-sent on every create/resume).
For comparison, this is what Claude Code's VS Code extension puts into the agent's system prompt in a multi-root window (verified on all current Claude models; paths anonymized):
# Environment
You have been invoked in the following environment:
- Primary working directory: /path/to/primary-folder
- Is a git repository: false
- Additional working directories:
- /path/to/second-folder
- /path/to/third-folder
- Platform: darwin
All workspace folders reach the model as plain system-prompt lines, uniformly across models — a good target behavior for Kimi Code as well.
Contribution
I am willing to submit a PR for this bug fix myself (please wait for maintainer approval in this issue first)
What version of Kimi Code is running?
VS Code extension 0.7.0 (moonshot-ai.kimi-code)
Which open platform/subscription were you using?
Kimi Allegro
Which model were you using?
K3 High
What platform is your computer?
Darwin 24.6.0 arm64 arm
What issue are you seeing?
When a VS Code window is opened as a multi-root workspace (
.code-workspacewith several folders), the Kimi Code extension starts the agent session with only the first workspace folder as its working directory. All other workspace folders are invisible to the agent: file tools cannot read or write them, and the model is not told they exist.The CLI already supports this scenario (
--add-dir,/add-dir,[workspace] additional_dirinlocal.toml), and the Node SDK exposesCreateSessionOptions.additionalDirs— but the VS Code extension never passes the remainingworkspaceFoldersthrough. Inapps/vscode/src/bridge-handler.tsonlyworkspace.workspaceFolders?.[0]is read to computeworkDir; folders[1..]are dropped.What steps can reproduce the bug?
.code-workspaceand reopen it (two or more root folders in the Explorer).Actual: the agent's working directory is the first folder only; files in the other folders are outside its scope (path access denied / not visible) unless the user manually runs
/add-dirfor each folder.What is the expected behavior?
On session start the extension should pass
workspaceFolders[1..]to the session as additional directories (ephemeral, per-session — same semantics as/add-dir), so the agent can work with all workspace roots without any manual setup.cwdstays on the primary folder, which is correct as the anchor for terminals and file pickers.This matches what other agent extensions do — e.g. Claude Code's VS Code extension collects
vscode.workspace.workspaceFolders, keeps the first ascwd, and passes the rest asadditionalDirectoriesto its SDK at spawn time.Additional information
main):apps/vscode/src/bridge-handler.tscomputesworkDirfromworkspace.workspaceFolders?.[0]?.urionly;KimiRuntime.openSession(apps/vscode/src/runtime/kimi-runtime.ts) callsharness.createSession({ workDir, ... })withoutadditionalDirs. Same for the resume path.CreateSessionOptions.additionalDirs/ResumeSessionInput.additionalDirsalready merge into the session and surface as the## Additional Directoriessystem-prompt section.workspace.workspaceFolders.slice(1)inbridge-handler.ts, addadditionalDirstoOpenSessionOptionsinkimi-runtime.ts, and pass it to bothcreateSessionandresumeSession(the additional-dirs set is ephemeral in v2, so it must be re-sent on every create/resume).All workspace folders reach the model as plain system-prompt lines, uniformly across models — a good target behavior for Kimi Code as well.
Contribution