Bug Description
The edit tool crashes immediately when modifying existing files (oldString !== "") with:
undefined is not an object (evaluating 'output.args.filePath')
Steps to Reproduce
- Have OpenCode call the
edit tool with a non-empty oldString (e.g., changing a line in nuxt.config.ts)
- The tool fails instantly (~6ms) with the TypeError above
- Reproducible across different files and edit patterns
- New file creation (
oldString === "") works fine
Expected Behavior
The edit tool should find oldString, replace with newString, and write the file successfully.
Environment
- OpenCode version: 1.14.25
- OS: GNU/Linux Arch Linux
- Terminal: kitty
Logs
tool: "edit"
callID: "call_00_MvWilnmtVEEDIAXjoRydlm6K"
state:
status: "error"
input:
filePath: "/home/.../nuxt.config.ts"
oldString: " apiBase: 'http://localhost:3001',"
newString: " apiBase: '/api',"
error: "undefined is not an object (evaluating 'output.args.filePath')"
time:
start: 1777223543093
end: 1777223543099
Same error replicated 3 times with different files (nuxt.config.ts, docker-compose.staging.yml, docker-compose.prod.yml).
RCA
The edit tool's execute returns { title, metadata, output } for the modified-file path. The AI SDK's toModelOutput/convertToModelMessages pipeline then tries output.args.filePath where output.args is undefined — the tool result doesn't have a .args property.
New file creation (oldString === "") works because that path has a different return flow. The bug is in the tool output processing layer where the result shape is assumed to have .args.filePath.
Bug Description
The
edittool crashes immediately when modifying existing files (oldString !== "") with:Steps to Reproduce
edittool with a non-emptyoldString(e.g., changing a line innuxt.config.ts)oldString === "") works fineExpected Behavior
The
edittool should findoldString, replace withnewString, and write the file successfully.Environment
Logs
Same error replicated 3 times with different files (nuxt.config.ts, docker-compose.staging.yml, docker-compose.prod.yml).
RCA
The
edittool'sexecutereturns{ title, metadata, output }for the modified-file path. The AI SDK'stoModelOutput/convertToModelMessagespipeline then triesoutput.args.filePathwhereoutput.argsisundefined— the tool result doesn't have a.argsproperty.New file creation (
oldString === "") works because that path has a different return flow. The bug is in the tool output processing layer where the result shape is assumed to have.args.filePath.