Bug
The agent_manager tool with mode: "local" always fails on Windows with:
Agent Manager tool cannot start a local session for unknown directory: <workspace-path>
The 0/1 sessions result is returned. No session is created.
Root Cause (verified by runtime patching)
In packages/kilo-vscode/src/agent-manager/tool-start.ts, the local() function compares the tool request's directory against the workspace root via strict string equality:
const root = deps.getRoot() // vscode.workspace.workspaceFolders[0].uri.fsPath
const dir = clean(directory) ?? root // directory from SSE event (CLI backend)
if (dir !== root && !wt) { // ← BUG: case-sensitive comparison
deps.log("Agent Manager tool local request ignored unknown directory", dir)
return false
}
The chain is:
root = vscode.workspace.workspaceFolders[0].uri.fsPath → VS Code URI system stores workspace paths with lowercase drive letter on Windows (e.g., file:///c%3A/Users/... in workspace.json → c:\Users\...)
dir = SSE event directory → CLI backend AppFileSystem.resolve() → realpathSync.native() → Windows GetFinalPathNameByHandleW → uppercase drive letter (e.g., C:\Users\...)
The strict !== comparison fails because "C:\..." !== "c:\..." is true.
Verification
All alternative hypotheses were systematically eliminated:
| Hypothesis |
Result |
Casing difference between realpathSync.native() and actual path |
❌ Identical on test machine |
| Symlinks/junctions in the path chain |
❌ None found |
| MSYS2 UCRT64 path translation |
❌ Not involved — CLI is a native Bun binary, not an MSYS2 process |
Positive proof:
- VS Code
workspace.json stores file:///c%3A/Users/<user>/... (lowercase c)
fs.realpathSync.native("C:\Users\<user>\...") returns C:\Users\<user>\... (uppercase C)
"c:\..." === "C:\..." evaluates to false in JavaScript
- Patching the compiled
extension.js to use .toLowerCase() on both sides of the comparison fixed the issue — Agent Manager local mode started working immediately
Expected Behavior
The comparison should be case-insensitive on Windows (where paths are case-insensitive).
Environment
- OS: Windows 10+ (win32)
- VS Code: 1.128.0
- Kilo Code extension: 7.4.5 (win32-x64)
Suggested Fix
In tool-start.ts, use a platform-aware comparison:
import { normalize } from "path"
// In local():
const normalizedDir = normalize(dir)
const normalizedRoot = normalize(root)
if (normalizedDir !== normalizedRoot && !wt) {
Or simpler:
const pathsMatch = process.platform === "win32"
? dir.toLowerCase() === root.toLowerCase()
: dir === root
if (!pathsMatch && !wt) {
This fix should also be applied to dir === root (the positive comparison on the preceding line) since it determines whether the directory is treated as the workspace root or as a worktree path.
Related Code
packages/kilo-vscode/src/agent-manager/tool-start.ts:100-109 — the comparison
packages/kilo-vscode/src/review-utils.ts — getWorkspaceRoot() returns workspaceFolders[0].uri.fsPath
packages/kilo-vscode/src/agent-manager/vscode-host.ts — workspacePath() delegates to getWorkspaceRoot()
packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts:1716-1718 — getRoot() delegates to host.workspacePath()
packages/core/src/filesystem.ts — AppFileSystem.resolve() uses realpathSync.native()
packages/opencode/src/bus/index.ts — bus publish() adds directory from InstanceState.directory
Bug
The
agent_managertool withmode: "local"always fails on Windows with:The
0/1sessions result is returned. No session is created.Root Cause (verified by runtime patching)
In
packages/kilo-vscode/src/agent-manager/tool-start.ts, thelocal()function compares the tool request's directory against the workspace root via strict string equality:The chain is:
root=vscode.workspace.workspaceFolders[0].uri.fsPath→ VS Code URI system stores workspace paths with lowercase drive letter on Windows (e.g.,file:///c%3A/Users/...inworkspace.json→c:\Users\...)dir= SSE event directory → CLI backendAppFileSystem.resolve()→realpathSync.native()→ WindowsGetFinalPathNameByHandleW→ uppercase drive letter (e.g.,C:\Users\...)The strict
!==comparison fails because"C:\..." !== "c:\..."istrue.Verification
All alternative hypotheses were systematically eliminated:
realpathSync.native()and actual pathPositive proof:
workspace.jsonstoresfile:///c%3A/Users/<user>/...(lowercasec)fs.realpathSync.native("C:\Users\<user>\...")returnsC:\Users\<user>\...(uppercaseC)"c:\..." === "C:\..."evaluates tofalsein JavaScriptextension.jsto use.toLowerCase()on both sides of the comparison fixed the issue — Agent Manager local mode started working immediatelyExpected Behavior
The comparison should be case-insensitive on Windows (where paths are case-insensitive).
Environment
Suggested Fix
In
tool-start.ts, use a platform-aware comparison:Or simpler:
This fix should also be applied to
dir === root(the positive comparison on the preceding line) since it determines whether the directory is treated as the workspace root or as a worktree path.Related Code
packages/kilo-vscode/src/agent-manager/tool-start.ts:100-109— the comparisonpackages/kilo-vscode/src/review-utils.ts—getWorkspaceRoot()returnsworkspaceFolders[0].uri.fsPathpackages/kilo-vscode/src/agent-manager/vscode-host.ts—workspacePath()delegates togetWorkspaceRoot()packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts:1716-1718—getRoot()delegates tohost.workspacePath()packages/core/src/filesystem.ts—AppFileSystem.resolve()usesrealpathSync.native()packages/opencode/src/bus/index.ts— buspublish()addsdirectoryfromInstanceState.directory