Skip to content

Can't run tools in OpenCode Desktop - tools executed from / instead of project cwd #9077

@iliferov

Description

@iliferov

Description

In OpenCode Desktop, tools are executed as if the working directory is / (system root), not the current project directory. This breaks tools that rely on relative paths (e.g. .opencode/tool/**). In OpenCode CLI the same tools run correctly.

Plugins

no plugins

OpenCode version

CLI - 1.1.20, Desktop - 1.1.25

Steps to reproduce

  1. Create an empty project folder.
  2. In the project folder create the tool files:
    .opencode/tool/python-add.ts
import {tool} from "@opencode-ai/plugin"
import path from "path"
export default tool({
  description: "Add two numbers using Python",
  args: {
    a: tool.schema.number().describe("First number"),
    b: tool.schema.number().describe("Second number"),
  },
  async execute(args) {
    const cwd = process.cwd()
    const script_path = path.resolve(".opencode/tool/add.py")
    const p = Bun.spawn(
      ["python3", script_path, String(args.a), String(args.b)],
      { stdout: "pipe", stderr: "pipe" }
    )
    const stdout = await new Response(p.stdout).text()
    const stderr = await new Response(p.stderr).text()
    const exitCode = await p.exited
    return [
      "===TOOL_RAW===",
      JSON.stringify({ cwd, script_path, stdout, stderr, exitCode }, null, 2),
      "===/TOOL_RAW===",
    ].join("\n")
  }
})

.opencode/tool/add.py

import sys
a = float(sys.argv[1])
b = float(sys.argv[2])
print(a + b)
  1. Open this project in OpenCode Desktop.
  2. Run the prompt:
    Use python-add tool (provide any arguments) and print verbatim everything between TOOL_RAW markers
  3. Observe the tool output:
    • Desktop sets cwd to /
    • script_path resolves to /.opencode/tool/add.py
    • Python fails with "No such file or directory"

Screenshot and/or share link

✅ Expected behavior (OpenCode CLI)

Tools run with cwd set to the project directory, so .opencode/tool/** resolves correctly.
Image

❌ Actual behavior (OpenCode Desktop)

Tools run with cwd set to / (system root). Relative path lookups fail, so the tool cannot be found.

Image

Operating System

macOS Tahoe 26.1

Terminal

Terminal (macOS)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwebRelates to opencode on web / desktop

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions