Repository navigation
Description
Summary
When a markdown agent's frontmatter contains any key that is not a V2 agent field (version:, tools:, or any custom key), the frontmatter parser moves that key and the whole permissions: block into request.body (the provider request overlay) and the agent's permission rules are silently dropped. A read-only agent that declares edit: deny ends up able to write files.
Environment
- opencode version: 2.1.2 (release)
- OS: Linux 7.0.0-38-generic docs: add clearer bedrock instructions #40-Ubuntu SMP PREEMPT_DYNAMIC x86_64 GNU/Linux (hostname omitted)
- Terminal: TERM=xterm-256color, COLORTERM=truecolor, TERM_PROGRAM unset
- Shell: /usr/bin/zsh
- Install/channel: release
- Active plugins: none configured
Reproduction
-
Create
~/.config/opencode/agents/example-agent.md:--- description: example agent mode: subagent permissions: - action: edit resource: "*" effect: deny - action: webfetch resource: "*" effect: deny --- example agent body
-
Add one key that is not part of the V2 agent schema to the same frontmatter, for example
version: 1.0.0(any unknown key works, includingfoo: bar). -
Inspect the resolved agent:
opencode debug agents, oropencode api get /api/agentand look at thepermissionsandrequest.bodyfields. -
Compare against the same file without the unknown key.
Expected Behavior
The unknown key should be ignored (or reported with a warning) and the permissions: block should still be applied. The resolved agent keeps edit: deny / webfetch: deny, and request.body stays empty.
Actual Behavior
With the unknown key present, the resolved agent has no agent-specific permission rules, and request.body holds the unknown key plus the permissions array:
{
"request": {
"settings": {},
"headers": {},
"body": {
"version": "1.0.0",
"permissions": [
{ "action": "edit", "resource": "*", "effect": "deny" }
]
}
},
"permissions": [
{ "action": "*", "resource": "*", "effect": "allow" },
{ "action": "read", "resource": "*.env", "effect": "ask" },
{ "action": "read", "resource": "*.env.*", "effect": "ask" },
{ "action": "read", "resource": "*.env.example", "effect": "allow" },
{ "action": "browser", "resource": "*", "effect": "deny" }
]
}description and mode are still parsed correctly — only the permission rules are lost. The effect is silent: nothing is logged as a warning, and request.body would forward those values to the provider once request bodies are sent.
Additional Context
Measured on 2.1.2 by reading the resolved agents through /api/agent:
| agent frontmatter | edit: deny applied |
resolved request.body |
|---|---|---|
permissions: native, no unknown key |
yes | {} |
permissions: native + version: |
no | {version, permissions} |
permissions: native + tools: |
no | {version, permissions} |
permissions: native + foo: bar |
no | {foo, permissions} |
permissions: native + unknown key placed after the block |
no | {permissions, version} |
permissions: inline JSON + version: |
no | {version, permissions} |
request: block + permissions: (no unknown key) |
yes | {...request body...} |
legacy permission: map (V1 syntax), no unknown key |
yes | {} |
Notes:
- The breakage is triggered by the unknown key, not by having
permissionsandrequesttogether — an explicitrequest:block withpermissions:in the same frontmatter works. - It affects both the block-list form and the inline JSON form of
permissions. - The V2 agent schema documents
permissions:as a block list, and the JSON schema for anagentsentry setsadditionalProperties: false, so unknown keys are not part of the contract. The expected behavior for an unknown key is to ignore it, not to swallow a known field with it. - Workaround: keep only schema fields in the agent frontmatter.
What this evidence does not cover: it is read from the resolved agent definitions via the API, not from a live subagent run that attempts a write.
Activity
opencode-agent commentedon Oct 21, 2026
Thanks for the detailed report and the comparison table. I think this is a duplicate of #50598. Its later comments narrow that issue to the same root cause: any frontmatter key the V2 agent schema doesn't know makes the markdown agent parse as a V1 agent, and the V1 migration then moves
permissions:intorequest.body, so the rules are dropped.Possible duplicates and related issues, ordered by likelihood:
permissions:in agent frontmatter end up inrequest.body.permissionsand are never applied. The comments there show the trigger is an unknown key such asname:ortools:, the same as here.permissions:silently discarded when frontmatter has a stray v1 key #51669: a PR that fixed exactly this by narrowing the legacy-format detection. It was closed without being merged.Your finding that it also happens with the inline JSON form, and wherever the unknown key sits in the frontmatter, would be useful to add on #50598. Until it's fixed, your workaround still holds: keep only V2 schema fields in agent frontmatter.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
rekram1-node commentedon Oct 21, 2026
Same root cause as #50598: an unrecognized frontmatter key sends the whole agent file through the V1 path, so V2
permissionsend up inrequest.bodyinstead of being applied. Tracking there.opencode-agent commentedon Oct 22, 2026
Closing this as a duplicate of #50598, since there was no reply in the past day about how it differs. #50598 has the same root cause: any unknown frontmatter key makes the markdown agent parse in the legacy V1 format, and the V1 migration moves
permissions:intorequest.body, so the rules are dropped. Please follow #50598 for updates. Your extra findings (the inline JSON form is affected too, the position of the unknown key doesn't matter, and an explicitrequest:block works) would be useful added there. Until it's fixed, keep only V2 schema fields in agent frontmatter. If your problem turns out to be different, reply here and we can reopen. Thanks again for the thorough report.