Write and Edit Tools Constantly Return TypeError #2757

Closed
opened 2026-02-16 17:37:07 -05:00 by yindo · 9 comments
Owner

Originally created by @dotunwrap on GitHub (Nov 10, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty returns consistently when working on an Astro project using TypeScript and Front Matter. It seems as if the commands do actually edit files. Funnily, depending on the tool attempted to use first, when it receives the feedback from the error, it will then attempt to use the opposite tool. I.e. if the agent attempts first to use the edit tool and receives that error, it will then attempt to use the write tool, or vise-versa. After attempting the second tool, I always see the following output:

File loremIpsum.astro has been modified since it was last read.
Last modification: 2025-11-10T16:44:35.174Z
Last read: 2025-11-10T16:43:34.366Z
Please read the file again before modifying it.

My opencode config is as follows:

{
  "$schema": "https://opencode.ai/config.json",
  "formatter": {
    "prettier": {
      "extensions": [".js", ".jsx", ".ts", ".tsx", ".astro"]
    }
  },
  "model": "anthropic/claude-sonnet-4-5-20250929",
  "permission": {
    "bash": {
      "git commit*": "ask",
      "git push*": "ask",
      "rm *": "deny",
      "*": "allow"
    }
  },
  "agent": {
    "code-reviewer": {
      "description": "Read-only agent for reviewing code changes",
      "mode": "subagent",
      "temperature": 0.1,
      "prompt": "{file:./prompts/code-reviewer.txt}",
      "tools": {
        "bash": true,
        "edit": false,
        "write": false,
        "read": true,
        "grep": true,
        "glob": true,
        "list": true,
        "patch": false,
        "todowrite": true,
        "todoread": true,
        "webfetch": true,
        "task": true
      }
    },
    "brainstorm": {
      "description": "Creative brainstorming for efficient solutions with focus on performance and Core Web Vitals",
      "mode": "subagent",
      "temperature": 0.6,
      "prompt": "{file:./prompts/brainstorm.txt}",
      "tools": {
        "bash": false,
        "edit": false,
        "write": false,
        "read": true,
        "grep": true,
        "glob": true,
        "list": true,
        "patch": false,
        "todowrite": true,
        "todoread": true,
        "webfetch": true,
        "task": false
      }
    }
  },
  "mcp": {
    "figma-remote": {
      "enabled": false,
      "type": "remote",
      "url": "https://mcp.figma.com/mcp"
    },
    "figma-desktop": {
      "enabled": true,
      "type": "remote",
      "url": "http://127.0.0.1:3845/mcp"
    }
  }
}

OpenCode version

1.0.20

Steps to reproduce

  1. Utilize the opencode.json above with dummy prompts for the two defined subagents
  2. Use the built-in build agent to implement a code change
  3. Observe errors on edit and write tools

Screenshot and/or share link

No response

Operating System

macOS Sequoia 15.7.1

Terminal

WezTerm

Originally created by @dotunwrap on GitHub (Nov 10, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description `TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty` returns consistently when working on an Astro project using TypeScript and Front Matter. It seems as if the commands do actually edit files. Funnily, depending on the tool attempted to use first, when it receives the feedback from the error, it will then attempt to use the opposite tool. I.e. if the agent attempts first to use the edit tool and receives that error, it will then attempt to use the write tool, or vise-versa. After attempting the second tool, I always see the following output: > File loremIpsum.astro has been modified since it was last read. > Last modification: 2025-11-10T16:44:35.174Z > Last read: 2025-11-10T16:43:34.366Z > Please read the file again before modifying it. My opencode config is as follows: ```json { "$schema": "https://opencode.ai/config.json", "formatter": { "prettier": { "extensions": [".js", ".jsx", ".ts", ".tsx", ".astro"] } }, "model": "anthropic/claude-sonnet-4-5-20250929", "permission": { "bash": { "git commit*": "ask", "git push*": "ask", "rm *": "deny", "*": "allow" } }, "agent": { "code-reviewer": { "description": "Read-only agent for reviewing code changes", "mode": "subagent", "temperature": 0.1, "prompt": "{file:./prompts/code-reviewer.txt}", "tools": { "bash": true, "edit": false, "write": false, "read": true, "grep": true, "glob": true, "list": true, "patch": false, "todowrite": true, "todoread": true, "webfetch": true, "task": true } }, "brainstorm": { "description": "Creative brainstorming for efficient solutions with focus on performance and Core Web Vitals", "mode": "subagent", "temperature": 0.6, "prompt": "{file:./prompts/brainstorm.txt}", "tools": { "bash": false, "edit": false, "write": false, "read": true, "grep": true, "glob": true, "list": true, "patch": false, "todowrite": true, "todoread": true, "webfetch": true, "task": false } } }, "mcp": { "figma-remote": { "enabled": false, "type": "remote", "url": "https://mcp.figma.com/mcp" }, "figma-desktop": { "enabled": true, "type": "remote", "url": "http://127.0.0.1:3845/mcp" } } } ``` ### OpenCode version 1.0.20 ### Steps to reproduce 1. Utilize the `opencode.json` above with dummy prompts for the two defined subagents 2. Use the built-in build agent to implement a code change 3. Observe errors on edit and write tools ### Screenshot and/or share link _No response_ ### Operating System macOS Sequoia 15.7.1 ### Terminal WezTerm
yindo added the bug label 2026-02-16 17:37:07 -05:00
yindo closed this issue 2026-02-16 17:37:07 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 10, 2025):

This issue might be a duplicate of existing issues. Please check:

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Nov 10, 2025): This issue might be a duplicate of existing issues. Please check: - #2255: [write and edit tools return spurious 'cmd must not be empty' error despite successful operations](https://github.com/sst/opencode/issues/2255) - This issue describes the exact same TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty error occurring with write and edit tools, where operations succeed but display misleading error messages. Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Nov 11, 2025):

@dotunwrap just to make sure I have everything can u do opencode debug config and show me output?

@rekram1-node commented on GitHub (Nov 11, 2025): @dotunwrap just to make sure I have everything can u do `opencode debug config` and show me output?
Author
Owner

@dotunwrap commented on GitHub (Nov 11, 2025):

@rekram1-node

{
  "$schema": "https://opencode.ai/config.json",
  "theme": "gruvbox",
  "autoupdate": true,
  "model": "anthropic/claude-sonnet-4-5-20250929",
  "agent": {
    "code-reviewer": {
      "temperature": 0.1,
      "prompt": "<PROMPT>",
      "tools": {
        "bash": true,
        "edit": false,
        "write": false,
        "read": true,
        "grep": true,
        "glob": true,
        "list": true,
        "patch": false,
        "todowrite": true,
        "todoread": true,
        "webfetch": true,
        "task": true
      },
      "description": "Read-only agent for reviewing code changes",
      "mode": "subagent"
    },
    "brainstorm": {
      "temperature": 0.6,
      "prompt": "<PROMPT>",
      "tools": {
        "bash": false,
        "edit": false,
        "write": false,
        "read": true,
        "grep": true,
        "glob": true,
        "list": true,
        "patch": false,
        "todowrite": true,
        "todoread": true,
        "webfetch": true,
        "task": false
      },
      "description": "Creative brainstorming for efficient solutions with focus on performance and Core Web Vitals",
      "mode": "subagent"
    }
  },
  "mcp": {
    "figma-remote": {
      "type": "remote",
      "url": "https://mcp.figma.com/mcp",
      "enabled": false
    },
    "figma-desktop": {
      "type": "remote",
      "url": "http://127.0.0.1:3845/mcp",
      "enabled": true
    }
  },
  "formatter": {
    "prettier": {
      "extensions": [
        ".js",
        ".jsx",
        ".ts",
        ".tsx",
        ".astro"
      ]
    }
  },
  "permission": {
    "bash": {
      "git commit*": "ask",
      "git push*": "ask",
      "rm *": "deny",
      "*": "allow"
    }
  },
  "mode": {},
  "plugin": [],
  "command": {},
  "username": "<EMAIL>",
  "keybinds": {
    "leader": "ctrl+x",
    "app_exit": "ctrl+c,ctrl+d,<leader>q",
    "editor_open": "<leader>e",
    "theme_list": "<leader>t",
    "sidebar_toggle": "<leader>b",
    "status_view": "<leader>s",
    "session_export": "<leader>x",
    "session_new": "<leader>n",
    "session_list": "<leader>l",
    "session_timeline": "<leader>g",
    "session_share": "none",
    "session_unshare": "none",
    "session_interrupt": "escape",
    "session_compact": "<leader>c",
    "messages_page_up": "pageup",
    "messages_page_down": "pagedown",
    "messages_half_page_up": "ctrl+alt+u",
    "messages_half_page_down": "ctrl+alt+d",
    "messages_first": "ctrl+g,home",
    "messages_last": "ctrl+alt+g,end",
    "messages_copy": "<leader>y",
    "messages_undo": "<leader>u",
    "messages_redo": "<leader>r",
    "messages_toggle_conceal": "<leader>h",
    "model_list": "<leader>m",
    "model_cycle_recent": "f2",
    "model_cycle_recent_reverse": "shift+f2",
    "command_list": "ctrl+p",
    "agent_list": "<leader>a",
    "agent_cycle": "tab",
    "agent_cycle_reverse": "shift+tab",
    "input_clear": "ctrl+c",
    "input_forward_delete": "ctrl+d",
    "input_paste": "ctrl+v",
    "input_submit": "return",
    "input_newline": "shift+return,ctrl+j",
    "history_previous": "up",
    "history_next": "down",
    "session_child_cycle": "ctrl+right",
    "session_child_cycle_reverse": "ctrl+left"
  }
}

I redacted my username and the two prompts due to them being related to my employer. Otherwise this is the raw output.

@dotunwrap commented on GitHub (Nov 11, 2025): @rekram1-node ```json { "$schema": "https://opencode.ai/config.json", "theme": "gruvbox", "autoupdate": true, "model": "anthropic/claude-sonnet-4-5-20250929", "agent": { "code-reviewer": { "temperature": 0.1, "prompt": "<PROMPT>", "tools": { "bash": true, "edit": false, "write": false, "read": true, "grep": true, "glob": true, "list": true, "patch": false, "todowrite": true, "todoread": true, "webfetch": true, "task": true }, "description": "Read-only agent for reviewing code changes", "mode": "subagent" }, "brainstorm": { "temperature": 0.6, "prompt": "<PROMPT>", "tools": { "bash": false, "edit": false, "write": false, "read": true, "grep": true, "glob": true, "list": true, "patch": false, "todowrite": true, "todoread": true, "webfetch": true, "task": false }, "description": "Creative brainstorming for efficient solutions with focus on performance and Core Web Vitals", "mode": "subagent" } }, "mcp": { "figma-remote": { "type": "remote", "url": "https://mcp.figma.com/mcp", "enabled": false }, "figma-desktop": { "type": "remote", "url": "http://127.0.0.1:3845/mcp", "enabled": true } }, "formatter": { "prettier": { "extensions": [ ".js", ".jsx", ".ts", ".tsx", ".astro" ] } }, "permission": { "bash": { "git commit*": "ask", "git push*": "ask", "rm *": "deny", "*": "allow" } }, "mode": {}, "plugin": [], "command": {}, "username": "<EMAIL>", "keybinds": { "leader": "ctrl+x", "app_exit": "ctrl+c,ctrl+d,<leader>q", "editor_open": "<leader>e", "theme_list": "<leader>t", "sidebar_toggle": "<leader>b", "status_view": "<leader>s", "session_export": "<leader>x", "session_new": "<leader>n", "session_list": "<leader>l", "session_timeline": "<leader>g", "session_share": "none", "session_unshare": "none", "session_interrupt": "escape", "session_compact": "<leader>c", "messages_page_up": "pageup", "messages_page_down": "pagedown", "messages_half_page_up": "ctrl+alt+u", "messages_half_page_down": "ctrl+alt+d", "messages_first": "ctrl+g,home", "messages_last": "ctrl+alt+g,end", "messages_copy": "<leader>y", "messages_undo": "<leader>u", "messages_redo": "<leader>r", "messages_toggle_conceal": "<leader>h", "model_list": "<leader>m", "model_cycle_recent": "f2", "model_cycle_recent_reverse": "shift+f2", "command_list": "ctrl+p", "agent_list": "<leader>a", "agent_cycle": "tab", "agent_cycle_reverse": "shift+tab", "input_clear": "ctrl+c", "input_forward_delete": "ctrl+d", "input_paste": "ctrl+v", "input_submit": "return", "input_newline": "shift+return,ctrl+j", "history_previous": "up", "history_next": "down", "session_child_cycle": "ctrl+right", "session_child_cycle_reverse": "ctrl+left" } } ``` I redacted my username and the two prompts due to them being related to my employer. Otherwise this is the raw output.
Author
Owner

@rekram1-node commented on GitHub (Nov 11, 2025):

can u export a session of this happening? opencode export > session.json I haven't heard anyone else have this so im trying to see what it could be

@rekram1-node commented on GitHub (Nov 11, 2025): can u export a session of this happening? `opencode export > session.json` I haven't heard anyone else have this so im trying to see what it could be
Author
Owner

@dotunwrap commented on GitHub (Nov 13, 2025):

can u export a session of this happening? opencode export > session.json I haven't heard anyone else have this so im trying to see what it could be

session.json

I created a new "test" session inside of a dummy project for this as to not leak any company information, but the issue is still present.

@dotunwrap commented on GitHub (Nov 13, 2025): > can u export a session of this happening? `opencode export > session.json` I haven't heard anyone else have this so im trying to see what it could be [session.json](https://github.com/user-attachments/files/23532108/session.json) I created a new "test" session inside of a dummy project for this as to not leak any company information, but the issue is still present.
Author
Owner

@rekram1-node commented on GitHub (Nov 13, 2025):

yeah i found bug fixing shortly

@rekram1-node commented on GitHub (Nov 13, 2025): yeah i found bug fixing shortly
Author
Owner

@rekram1-node commented on GitHub (Nov 13, 2025):

Okay try 1.0.64 and lmk if it fixed it for u

@rekram1-node commented on GitHub (Nov 13, 2025): Okay try 1.0.64 and lmk if it fixed it for u
Author
Owner

@dotunwrap commented on GitHub (Nov 14, 2025):

That did fix the error! Thanks so much :)

@dotunwrap commented on GitHub (Nov 14, 2025): That did fix the error! Thanks so much :)
Author
Owner

@rekram1-node commented on GitHub (Nov 14, 2025):

no prob!

@rekram1-node commented on GitHub (Nov 14, 2025): no prob!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2757