Skip to content

agents: an unknown frontmatter key swallows the permissions block into request.body and drops the rules #57819

Closed as duplicate

Description

@Marx-pixel

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

  1. 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
  2. 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, including foo: bar).

  3. Inspect the resolved agent: opencode debug agents, or opencode api get /api/agent and look at the permissions and request.body fields.

  4. 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 permissions and request together — an explicit request: block with permissions: 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 an agents entry sets additionalProperties: 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

  1. opencode-agent commented on Oct 21, 2026

    @opencode-agent
    Contributor

    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: into request.body, so the rules are dropped.

    Possible duplicates and related issues, ordered by likelihood:

    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.

  2. rekram1-node commented on Oct 21, 2026

    @rekram1-node
    Member

    Same root cause as #50598: an unrecognized frontmatter key sends the whole agent file through the V1 path, so V2 permissions end up in request.body instead of being applied. Tracking there.

  3. opencode-agent commented on Oct 22, 2026

    @opencode-agent
    Contributor

    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: into request.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 explicit request: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions