Commands are not executed properly with proper markdown
Description
I have noticed a strange behavior in 1.0.222, not sure if it was before. I had an x in front of the first --- in my command markdown file. After consulting the docs I have noticed that it shouldn't be there, so I have removed it. I was surprised to notice, that such command doesn't work correctly.
I have prepared a minimal example:
---
description: "Just a simple test prompt"
agent: agent
---
Write "hello" in a response and finish.
The result of running it is as below, and it just stays there forever:
Once I have added back the x as a first character of the file, the command works:
It is the same behavior in the TUI and Opnecode Desktup.
OpenCode version
1.0.222
Steps to reproduce
Create a file with the following content at .opencode/command/test-prompt.md, and run /test-prompt.
---
description: "Just a simple test prompt"
agent: agent
---
Write "hello" in a response and finish.
Operating System
Zorin OS (based on Ubuntu 22.04)
Terminal
No response
This issue might be a duplicate of existing issues. Please check:
- #3537: Custom slash commands can crash opencode on startup (YAML parsing issues with frontmatter)
- #2460/#2461:
modelfield in slash command frontmatter appears to be ignored - #3329: Custom commands with agents should change to the agent session
Feel free to ignore if none of these address your specific case.
The issue is not the formatting. It's that in this case the agent agent doesn't exist. Adding a x technically fixes it cause its an invalid markdown then, so the default agent is used.
Anyway I created a PR to at least show an error when an agent name is invalid (https://github.com/sst/opencode/pull/6578)
Oh, that makes sense. I was converting the prompt from Github Copilot, and the agent: agent is perfectly valid there. A meaningful error would be very helpful here.