You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Agent .md files with invalid YAML frontmatter are silently skipped without warning #45876
When a custom agent markdown file (for example .opencode/agents/test.md or ~/.config/opencode/agents/test.md) contains invalid YAML frontmatter — such as an indentation error — the file is silently skipped. The user sees no warning, no error, and no indication that the agent failed to load.
This is inconsistent with skill loading, which logs an error and publishes a Session.Event.Error when a skill file fails to parse.
Reproduction steps
Create .opencode/agents/test.md with malformed frontmatter indentation:
---name: testdescription: test agent---
You are a helpful assistant.
Start OpenCode or run opencode agent list.
Observe that test does not appear, and no warning or error is shown.
Root cause
In packages/opencode/src/config/agent.ts, the parse result is swallowed:
Skill files record the cause, but only at debug level (skill.ts#L128-L135).
A duplicate key is one more cause. gray-matter 4.0.3 throws duplicated mapping key, and sanitize does not change duplicate keys, so the retry also throws. For example, this file does not load and the log has no entry for it:
---description: Test agentmode: subagentmode: primary---
Reply with OK.
We found this when four agent files were missing from the agent list on 2.1.1. Each file had one key two times in its frontmatter, and nothing showed which files were missing or why. A warn log entry that names the file and the parse or schema error can show this.
Thanks for the report. I reproduced this on 2.2.0, and it still happens on the latest dev (506ac20c).
What I did:
In a fresh project, added three files to .opencode/agents/: a valid good.md, badindent.md with the mis-indented frontmatter from your report, and dupkey.md with mode: set twice (the example from the comment above).
Ran opencode debug agents --standalone --log-level debug --print-logs.
Only good is listed. The other two are missing, and no log line mentions either file, even at debug level.
The same loader does log a warning when an agent uses unsupported fields, but a file that fails to parse is dropped silently. The script below reproduces it on the release and from source.
Activity
iceteaSA commentedon Oct 22, 2026
This continues to occur on OpenCode 2.1.1 and on
devat27cdf5fb. The V2 code is inpackages/core, and it has the same silent returns:ConfigMarkdown.parseretries withsanitizewhen YAML parsing fails. If the retry also throws,parseOptionreturnsundefined(markdown.ts#L16-L22).undefinedwith no log (agent.ts#L176-L178). It does the same when the schema decode fails (agent.ts#L193-L202).A duplicate key is one more cause. gray-matter 4.0.3 throws
duplicated mapping key, andsanitizedoes not change duplicate keys, so the retry also throws. For example, this file does not load and the log has no entry for it:We found this when four agent files were missing from the agent list on 2.1.1. Each file had one key two times in its frontmatter, and nothing showed which files were missing or why. A
warnlog entry that names the file and the parse or schema error can show this.opencodejr commentedon Oct 28, 2026
Thanks for the report. I reproduced this on 2.2.0, and it still happens on the latest
dev(506ac20c).What I did:
.opencode/agents/: a validgood.md,badindent.mdwith the mis-indented frontmatter from your report, anddupkey.mdwithmode:set twice (the example from the comment above).opencode debug agents --standalone --log-level debug --print-logs.goodis listed. The other two are missing, and no log line mentions either file, even at debug level.The same loader does log a warning when an agent uses unsupported fields, but a file that fails to parse is dropped silently. The script below reproduces it on the release and from source.
Related:
descriptionstarting with[)Reproduction script (repro.sh)
Run it:
bash repro.sh