Skip to content

Agent Manager local mode fails on Windows: VS Code URI lowercase drive letter vs realpathSync uppercase #12138

Description

@Theadd

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.jsonc:\Users\...)
  • dir = SSE event directory → CLI backend AppFileSystem.resolve()realpathSync.native() → Windows GetFinalPathNameByHandleWuppercase 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:

  1. VS Code workspace.json stores file:///c%3A/Users/<user>/... (lowercase c)
  2. fs.realpathSync.native("C:\Users\<user>\...") returns C:\Users\<user>\... (uppercase C)
  3. "c:\..." === "C:\..." evaluates to false in JavaScript
  4. 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.tsgetWorkspaceRoot() returns workspaceFolders[0].uri.fsPath
  • packages/kilo-vscode/src/agent-manager/vscode-host.tsworkspacePath() delegates to getWorkspaceRoot()
  • packages/kilo-vscode/src/agent-manager/AgentManagerProvider.ts:1716-1718getRoot() delegates to host.workspacePath()
  • packages/core/src/filesystem.tsAppFileSystem.resolve() uses realpathSync.native()
  • packages/opencode/src/bus/index.ts — bus publish() adds directory from InstanceState.directory

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions