Skip to content

agents: V1 name: in frontmatter silently forks an agent from its config entry (delegation fails, permissions land on a prompt-less twin) #67356

Done

Description

@SamuGasto

Summary

A Markdown agent file that still carries V1-only frontmatter (emoji, vibe) is parsed as V1, where the deprecated name: field becomes the agent ID. If name: differs from the file stem, the file and its agents.<stem> entry in opencode.json register as two separate agents instead of merging — with no warning. Delegating to the config key then fails with Agent <stem> cannot run as a subagent, while the permissions from the config entry sit on a twin that has no system prompt.

Environment

  • opencode version: 2.4.3
  • Client: TUI
  • Model and provider: opencode-go/deepseek-v4.1-flash; not relevant to the bug
  • OS: Linux 6.18.56-125.164.amzn2023.aarch64 (linux arm64)
  • Terminal: TERM_PROGRAM=Orca, TERM=xterm-256color, COLORTERM=truecolor
  • Shell: /bin/bash
  • Install/channel: latest
  • Active plugins: local TUI plugins orca-opencode-status, orca-opencode2-status (not config-registered); none relevant

Reproduction

mkdir -p .opencode/agents

cat > .opencode/agents/widget.md <<'EOF'
---
name: Widget
description: probe seat
emoji: 🧪
mode: subagent
steps: 20
---
# Body
EOF

cat > opencode.json <<'EOF'
{
  "$schema": "https://opencode.ai/config.json",
  "agents": {
    "widget": { "permissions": [{ "action": "read", "resource": "*", "effect": "allow" }] }
  }
}
EOF

opencode debug agents

Then ask a primary agent to delegate to widget.

Expected Behavior

Per the docs (/agents#locations), the agent ID is path-derived: .opencode/agents/widget.md → widget. The opencode.json entry should merge into that definition. name: is listed under "Accepted but unsupported fields" and should either be ignored for the ID or warn at load.

Actual Behavior

opencode debug agents lists two agents:

{"id": "widget", "mode": "primary", "system": null, "description": null,
 "permissions": [ ...the opencode.json rules... ]}
{"id": "Widget", "mode": "subagent", "system": "# Body", "description": "probe seat",
 "permissions": [ ...global rules only... ]}
  • Delegating to widget fails: Agent widget cannot run as a subagent. widget is primary because a config-only entry defaults to primary.
  • The prompt-bearing Widget is a separate agent nothing in the config refers to.
  • default_agent: "widget" silently selects the prompt-less twin.
  • No warning is emitted at load; the log has no frontmatter/agent lines at all.
  • If the widget entry instead sets "mode": "subagent", delegation succeeds — into an agent with no system prompt and no model, inheriting the parent's. That is a silent-wrong-answer failure mode, not a fix.

Removing the name: line merges everything into one widget with prompt + model + config permissions (verified in an isolated config root).

Additional Context

Hit on a 22-agent kit: every seat had a display name: (Architect) alongside a hyphenated config key (architect), so 22 of 22 seats were duplicated. The bundle's loader:

let c = typeof s.data.name === "string" ? s.data.name
        : relative(filepath).replace(/\.md$/, "")

combined with the "one file is read as one format" rule (a file using only V1 fields is read as V1) is what makes name win.

Note the docs' unsupported-fields list scopes this to "Agent name inside V1 JSON configuration", which reads as if files are unaffected. If V1 file parsing staying active is intended, a load-time warning when a file-derived ID and a config key diverge would make this discoverable; today debug agents is the only way to see it.

Reproducible consistently. Workaround: drop name: from agent frontmatter (or make it exactly equal to the file stem, at the cost of keeping the file on the V1 parser).

Activity

  1. added
    area/core
    type/bug
    version/v2
    on Nov 30, 2026
  2. opencodejr commented on Nov 30, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I reproduced this on the unmodified 2.4.3 release with your exact files, and it still happens on the latest dev (259e7cb). No model is needed to see it.

    opencode debug agents lists two agents:

    • widget: mode: primary, system: null, with the read rule from opencode.json.
    • Widget: mode: subagent, with # Body as its system prompt and the description, and only the global rules.

    With the same files, 2.4.2 gives a single merged widget subagent, so this is a regression. It looks like it comes from #67051, which made a string name: in agent frontmatter override the ID taken from the file path. The Agent widget cannot run as a subagent error follows from that: subagent delegation refuses agents whose mode is primary, and the config-only widget gets primary.

    The script below reproduces it with opencode debug agents in an isolated config root. Until this is resolved, your workaround of removing name: from the frontmatter avoids it.

    Reproduction script (repro.sh)
    #!/bin/sh
    # Reproduces anomalyco/opencode#67356. Usage: OPENCODE="opencode" sh repro.sh
    OPENCODE=${OPENCODE:-opencode}
    T=$(mktemp -d)
    export HOME="$T/home" XDG_CONFIG_HOME="$T/home/.config" XDG_DATA_HOME="$T/home/.local/share" XDG_STATE_HOME="$T/home/.local/state" XDG_CACHE_HOME="$T/home/.cache"
    mkdir -p "$HOME" "$T/proj/.opencode/agents"
    cd "$T/proj" && git init -q
    cat > .opencode/agents/widget.md <<'MD'
    ---
    name: Widget
    description: probe seat
    emoji: 🧪
    mode: subagent
    steps: 20
    ---
    # Body
    MD
    cat > opencode.json <<'JSON'
    {
      "$schema": "https://opencode.ai/config.json",
      "agents": {
        "widget": { "permissions": [{ "action": "read", "resource": "*", "effect": "allow" }] }
      }
    }
    JSON
    $OPENCODE --version
    $OPENCODE --standalone debug agents > "$T/agents.json" 2>&1
    python3 - "$T/agents.json" <<'PY'
    import json,sys,re
    txt=open(sys.argv[1]).read()
    data=json.loads(txt[txt.index("["):]) if txt.lstrip().startswith("[") or "[" in txt else None
    for a in data:
        if a.get("id","").lower()=="widget":
            print(json.dumps({k:a.get(k) for k in ("id","mode","system","description","permissions")}))
    PY

    Run it: sh repro.sh

  3. archit15singh commented on Nov 30, 2026

    @archit15singh

    I checked the published 2.4.2 and 2.4.3 macOS binaries with debug agents using only descriptions and prompts. On 2.4.3 the name override also applies to native-v2 Markdown and nested files. Switching the JSON key to the declared name joins the definitions on 2.4.3 but splits them on 2.4.2. Omitting name kept the relative-path ID and one merged definition on both versions.

    Could I take a docs-only follow-up for /agents and the v1 migration guide to explain the precedence and the cross-version migration path?

  4. four1er commented on Nov 30, 2026

    @four1er

    I'm picking this up — reproducing the issue now and will open a PR with a fix.

  5. rekram1-node commented on Dec 1, 2026

    @rekram1-node
    Member

    name: in agent Markdown frontmatter overriding the path-derived ID is intentional (added in #67051). To merge with opencode.json, either omit name: to keep the file-path ID or match the agents.<id> key to name:.

    Opened #67431 to document this on the Agents page.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreplatform/linuxreproducedstatus/regressiontype/bugversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions