Description
Issue details
For Markdown-defined agents (.opencode/agents/*.md), a prompt: key set in the YAML frontmatter is silently ignored. The resolved prompt always defaults to the Markdown body text, even if the body is empty.
Additionally, {file:...} and {env:...} token substitutions—which are documented for opencode.json's agent.<name>.prompt—are never applied when parsing these Markdown files. As a result, token references are never resolved.
Impact & Behavioral Cost
When an agent resolves an empty prompt:
- It falls back to OpenCode's generic default system prompt.
- On every invocation, the agent spends extra tool calls (file/glob searches across
.opencode/, ~/.config/opencode, ~/.claude, and speculative git commands) trying to discover its own missing instructions.
This results in wasted tokens, unnecessary execution turns, and context window pollution.
Expected Behavior
The agent's system prompt resolves to the file contents of .opencode/prompts/foo.md.
Actual Behavior
The resolved prompt evaluates to the empty Markdown body. The frontmatter prompt: key and its {file:...} reference are silently dropped without any warnings or errors, causing the agent to run without a system prompt.
Where It Happens
packages/opencode/src/config/agent.ts: load() / loadMode() constructs the configuration object as { ...md.data, prompt: md.content.trim() }. The body content unconditionally overwrites the frontmatter prompt field.
config/variable.ts: The {file:...} and {env:...} token substitution pass is only invoked for opencode.json configs and is never run for Markdown files parsed via ConfigMarkdown.parse().
Possible Fix
- Allow
prompt set in frontmatter to take precedence over the Markdown body (or fall back to body content only when prompt is undefined in frontmatter).
- Apply the same
{file:...} / {env:...} variable substitution pass used for opencode.json to frontmatter fields parsed from Markdown agents and commands.
Plugins
No response
OpenCode version
1.18.27
Steps to reproduce
- Create
.opencode/agent/foo.md with YAML frontmatter and an empty body:
---
mode: primary
prompt: '{file:./prompts/foo.md}'
---
- Create
.opencode/prompts/foo.md with system instructions (e.g., You are a helpful assistant.).
- Run
opencode debug agent foo (or execute opencode with foo active) to inspect the resolved configuration.
Screenshot and/or share link
Operating System
macOS 15.6
Terminal
Terminal
Description
Issue details
For Markdown-defined agents (
.opencode/agents/*.md), aprompt:key set in the YAML frontmatter is silently ignored. The resolved prompt always defaults to the Markdown body text, even if the body is empty.Additionally,
{file:...}and{env:...}token substitutions—which are documented foropencode.json'sagent.<name>.prompt—are never applied when parsing these Markdown files. As a result, token references are never resolved.Impact & Behavioral Cost
When an agent resolves an empty prompt:
.opencode/,~/.config/opencode,~/.claude, and speculativegitcommands) trying to discover its own missing instructions.This results in wasted tokens, unnecessary execution turns, and context window pollution.
Expected Behavior
The agent's system prompt resolves to the file contents of
.opencode/prompts/foo.md.Actual Behavior
The resolved prompt evaluates to the empty Markdown body. The frontmatter
prompt:key and its{file:...}reference are silently dropped without any warnings or errors, causing the agent to run without a system prompt.Where It Happens
packages/opencode/src/config/agent.ts:load()/loadMode()constructs the configuration object as{ ...md.data, prompt: md.content.trim() }. The body content unconditionally overwrites the frontmatterpromptfield.config/variable.ts: The{file:...}and{env:...}token substitution pass is only invoked foropencode.jsonconfigs and is never run for Markdown files parsed viaConfigMarkdown.parse().Possible Fix
promptset in frontmatter to take precedence over the Markdown body (or fall back to body content only whenpromptis undefined in frontmatter).{file:...}/{env:...}variable substitution pass used foropencode.jsonto frontmatter fields parsed from Markdown agents and commands.Plugins
No response
OpenCode version
1.18.27
Steps to reproduce
.opencode/agent/foo.mdwith YAML frontmatter and an empty body:.opencode/prompts/foo.mdwith system instructions (e.g.,You are a helpful assistant.).opencode debug agent foo(or executeopencodewithfooactive) to inspect the resolved configuration.Screenshot and/or share link
Operating System
macOS 15.6
Terminal
Terminal