Skip to content

bug(edit): edit tool crashes with 'undefined is not an object (evaluating output.args.filePath)' on existing file modification #24529

@SuyeshBadge

Description

@SuyeshBadge

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

  1. Have OpenCode call the edit tool with a non-empty oldString (e.g., changing a line in nuxt.config.ts)
  2. The tool fails instantly (~6ms) with the TypeError above
  3. Reproducible across different files and edit patterns
  4. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions