opencode
opencode copied to clipboard
Can't run tools in OpenCode Desktop - tools executed from / instead of project cwd
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
- Create an empty project folder.
- 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)
- Open this project in OpenCode Desktop.
- Run the prompt:
Use python-add tool (provide any arguments) and print verbatim everything between TOOL_RAW markers - 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.
❌ Actual behavior (OpenCode Desktop)
Tools run with cwd set to / (system root). Relative path lookups fail, so the tool cannot be found.
Operating System
macOS Tahoe 26.1
Terminal
Terminal (macOS)