File paths are randomly interpreted in subagents. #1955

Closed
opened 2026-02-16 17:33:25 -05:00 by yindo · 7 comments
Owner

Originally created by @RuminationScape on GitHub (Oct 4, 2025).

Originally assigned to: @rekram1-node on GitHub.

It seems the most reliable way to specify file paths is "bare", ie without any markup, such as path/to/some/where.

Using the following sometimes get it right but sometimes the characters are escaped and folders are created with round brackets, backtick, etc:

  • {file:path/to/some/file.txt}
  • folder_name (backticks -> github doesn't show the backticks)
  • {folder_name}
  • "folder_name"

I tested it in subagents and it would just take each of these file paths literally, rather than stripping the special characters.

Is this due to Grok or due to Opencode?

Originally created by @RuminationScape on GitHub (Oct 4, 2025). Originally assigned to: @rekram1-node on GitHub. It seems the most reliable way to specify file paths is "bare", ie without any markup, such as path/to/some/where. Using the following sometimes get it right but sometimes the characters are escaped and folders are created with round brackets, backtick, etc: - {file:path/to/some/file.txt} - `folder_name` (backticks -> github doesn't show the backticks) - {folder_name} - "folder_name" I tested it in subagents and it would just take each of these file paths literally, rather than stripping the special characters. Is this due to Grok or due to Opencode?
yindo closed this issue 2026-02-16 17:33:25 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 4, 2025):

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

  • #797: CLI argument parsing fails with unescaped special characters (?, ', (, etc.) - deals with how special characters in file paths are interpreted by the shell/system
  • #2311: Pasting in a relative path to a folder results in an error - specifically about how paths with special formatting are handled
  • #2799: ENOENT error when referencing file paths in OpenCode AI CLI (windows) - similar file path resolution issues in subagents/agents
  • #1583: On windows, referencing a file puts linux root / before it - another case of file paths being incorrectly interpreted

Feel free to ignore if none of these address your specific case with subagents treating markup literally instead of stripping special characters.

@github-actions[bot] commented on GitHub (Oct 4, 2025): This issue might be a duplicate of existing issues. Please check: - #797: CLI argument parsing fails with unescaped special characters (?, ', (, etc.) - deals with how special characters in file paths are interpreted by the shell/system - #2311: Pasting in a relative path to a folder results in an error - specifically about how paths with special formatting are handled - #2799: ENOENT error when referencing file paths in OpenCode AI CLI (windows) - similar file path resolution issues in subagents/agents - #1583: On windows, referencing a file puts linux root `/` before it - another case of file paths being incorrectly interpreted Feel free to ignore if none of these address your specific case with subagents treating markup literally instead of stripping special characters.
Author
Owner

@rekram1-node commented on GitHub (Oct 4, 2025):

I tested it in subagents and it would just take each of these file paths literally, rather than stripping the special characters.

I just wanna make sure I am following you correctly, how are you testing this with subagents? Are you including file paths in their .md definitions? Or in the opencode.json file? Or are you saying you can't get them to read files correctly? I am just trying to make sure I understand correctly

@rekram1-node commented on GitHub (Oct 4, 2025): > I tested it in subagents and it would just take each of these file paths literally, rather than stripping the special characters. I just wanna make sure I am following you correctly, how are you testing this with subagents? Are you including file paths in their .md definitions? Or in the opencode.json file? Or are you saying you can't get them to read files correctly? I am just trying to make sure I understand correctly
Author
Owner

@RuminationScape commented on GitHub (Oct 4, 2025):

I was setting up a workflow with subagents. I want them to read and write to certain folders, so I wrote tests. Sometimes the agent correctly parses file paths, other times it creates folders including the special characters (the shell showed it escaped these characters with backslash). The behavior was random/intermittent. Claude Code exhibited the same behavior. Generally writing file paths without any markup worked best, but that will cause problems if file paths includes spaces.

Sample content below.

Shell: do agent-Subagent1

Subagent1.md content:

  • do agent-Subagent2
  • do agent-Subagent3
  • do agent-Subagent4
    etc

Subagent2.md content:
put file test.txt in folder @Folder1 ==> creates folder @Folder1 (ie. folder name includes @ sign)

Subagent3.md content:
put file "test.txt" in folder "Folder2" ==> creates folder "Folder2" (includes quotes in folder name)

Subagent4.md content:
put file test.txt in {file:Folder3} ==> creates folder {file:Folder3}

@RuminationScape commented on GitHub (Oct 4, 2025): I was setting up a workflow with subagents. I want them to read and write to certain folders, so I wrote tests. Sometimes the agent correctly parses file paths, other times it creates folders including the special characters (the shell showed it escaped these characters with backslash). The behavior was random/intermittent. Claude Code exhibited the same behavior. Generally writing file paths without any markup worked best, but that will cause problems if file paths includes spaces. Sample content below. --------------------------------------------------------- Shell: do agent-Subagent1 Subagent1.md content: - do agent-Subagent2 - do agent-Subagent3 - do agent-Subagent4 etc Subagent2.md content: put file test.txt in folder @Folder1 ==> creates folder @Folder1 (ie. folder name includes @ sign) Subagent3.md content: put file "test.txt" in folder "Folder2" ==> creates folder "Folder2" (includes quotes in folder name) Subagent4.md content: put file test.txt in {file:Folder3} ==> creates folder {file:Folder3}
Author
Owner

@rekram1-node commented on GitHub (Oct 4, 2025):

i mean to me this just looks like prompting, if you want it to create specific files then just tell it how to name and what to do given specific characters, this doesnt seem like an opencode problem necessarily especially given your comment about this also happening in claude code.

Not sure if there is anything to do on our end but it doesnt seem like there is

@rekram1-node commented on GitHub (Oct 4, 2025): i mean to me this just looks like prompting, if you want it to create specific files then just tell it how to name and what to do given specific characters, this doesnt seem like an opencode problem necessarily especially given your comment about this also happening in claude code. Not sure if there is anything to do on our end but it doesnt seem like there is
Author
Owner

@RuminationScape commented on GitHub (Oct 4, 2025):

In Linux shell, if I say mkdir "Folder1", it will create the folder Folder1 without the double quotes.

This is useful when the folder has spaces. For example, if I write mkdir This is my folder, this will create 4 folders, which is not what I want. To me, it seems to be a convention that the quotes are not part of the folder name unless it is escaped with a backslash, ie. \"Folder1\".

The other issue is that the behavior is not deterministic. The outcome changes from one run to the next.

The third issue is that online examples of subagent markdown files use the notation I wrote above. That's going to cause confusion/problems for people.

@RuminationScape commented on GitHub (Oct 4, 2025): In Linux shell, if I say `mkdir "Folder1"`, it will create the folder Folder1 without the double quotes. This is useful when the folder has spaces. For example, if I write `mkdir This is my folder`, this will create 4 folders, which is not what I want. To me, it seems to be a convention that the quotes are not part of the folder name unless it is escaped with a backslash, ie. \\"Folder1\\". The other issue is that the behavior is not deterministic. The outcome changes from one run to the next. The third issue is that online examples of subagent markdown files use the notation I wrote above. That's going to cause confusion/problems for people.
Author
Owner

@RuminationScape commented on GitHub (Oct 4, 2025):

Maybe you're right, this could be an LLM problem. The LLM doesn't have a convention for file paths, so its interpretation varies. In any case, I haven't seen any subagent code examples where they specify what the convention for file paths are, they just use one of the methods I gave. I'll try adding instructions in the prompt regarding the file path and see how it goes.

@RuminationScape commented on GitHub (Oct 4, 2025): Maybe you're right, this could be an LLM problem. The LLM doesn't have a convention for file paths, so its interpretation varies. In any case, I haven't seen any subagent code examples where they specify what the convention for file paths are, they just use one of the methods I gave. I'll try adding instructions in the prompt regarding the file path and see how it goes.
Author
Owner

@rekram1-node commented on GitHub (Oct 4, 2025):

if you continue having prompting issues lmk

@rekram1-node commented on GitHub (Oct 4, 2025): if you continue having prompting issues lmk
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1955