#9839·pi

Custom cwd not honored by built-in tools after ctx.cwd change - restore via opt-in customCwd

Author: vmizgCreated Sep 21, 2026Updated Sep 28, 2026

What do you want to change?

PR #8627 changed the built-in tools in packages/coding-agent (read, write, edit, grep, find, ls, bash, powershell) to prefer ctx.cwd from ExtensionContext over the cwd captured at tool creation time. Restore backward compatibility: when a consumer explicitly creates tools with a custom cwd, that value must take precedence over ctx.cwd.

Why?

The change broke existing consumers. Extensions that construct the built-in tools with an explicit cwd (e.g. per-workspace or per-project instances) now have that value silently ignored in favor of the session's ExtensionContext.cwd. This was reported in https://github.com/earendil-works/pi/pull/8627#issuecomment-5580874018.

How? (optional)

Rename the tool-construction parameter from cwd to customCwd to make the intent explicit, and change the resolution logic so that:

  1. If customCwd is provided, it is always used (opt-out of the new behavior, restores backward compatibility).
  2. Otherwise, fall back to ctx.cwd from ExtensionContext (the fix introduced in #8627).
  3. Fall back to process.cwd() when neither is available.

PR: #9483