anomalyco / anomalyco/opencode

agents: project .opencode/agents/ ignored; global agents leak across projects

Open
#50,134 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

Two agent discovery regressions in v2:

  1. Project-level .opencode/agents/ directory is ignored — file-based agents not discovered
  2. Global ~/.config/opencode/agents/ agents leak across all projects — no project scoping

Environment

  • opencode version: 2.0.10
  • OS: Linux 6.18.33.2-microsoft-standard-WSL2 (WSL2 Ubuntu)
  • Terminal: xterm-256color (truecolor)
  • Shell: /usr/bin/zsh
  • Install/channel: latest (curl installer)
  • Active plugins: ./.opencode/plugins/observer.cjs (local)

Reproduction

Bug 1: Project .opencode/agents/ ignored
  1. Create a project with .opencode/agents/content-agent.md:
    ---
    id: content-agent
    name: Content Agent
    model: openrouter/nvidia/nemotron-3-ultra-550b-a55b:free
    mode: primary
    ---
    System prompt here...
    
  2. Start OpenCode in that project (opencode --standalone)
  3. Run opencode debug agents
  4. Observe: content-agent NOT in list — only built-ins (build, explore, general, plan, summary, title, compaction)
Bug 2: Global agents leak across projects
  1. Place agent files in ~/.config/opencode/agents/*.md (with proper frontmatter)
  2. Start OpenCode in Project A → agents appear in debug agents
  3. Start OpenCode in Project B (different directory, no agents) → same agents appear
  4. Set default_agent: "content-agent" in Project B config → picks up Project A's agent

Expected Behavior

  • Bug 1: Project .opencode/agents/ should be discovered automatically (v1 behavior worked)
  • Bug 2: Global agents should be namespaced or project config should isolate agent scope. Project-specific default_agent should not resolve to another project's agents.

Actual Behavior

  • Project file-based agents completely ignored
  • Global agents are truly global — visible and usable in every project
  • Workaround: Define agents in project config agents object (JSON) — works but duplicates prompt from .md files

Additional Context

  • This worked in v1. Project .opencode/agents/ (or agent/, mode/) were discovered
  • Migration guide says: "V2 discovers all four directories" and "V2 translates legacy agent frontmatter automatically"
  • File-based discovery from global config dir works, but creates cross-project leakage
  • Project config agents object (JSON) works correctly for project scoping
  • Source agent .md files preserved in .opencode/agents/ with id, name, model, mode, color, description frontmatter
  • Config: /mnt/share/TwoTimesTwo/opencode.jsonc has default_agent: "content-agent" and agents object with 6 agents (content-agent, daily-agent, deploy-agent, infra-agent, research-agent, visual-agent)
  • Each agent in config has // Source: .opencode/agents/<name>.md comment linking to source file

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the agent discovery path exercised by opencode debug agents, comparing project .opencode/agents/ with the global ~/.config/opencode/agents/ directory and project agents configuration. Trace how default_agent resolves across projects; done means project Markdown agents are discovered and global agents do not leak into unrelated projects, with the documented reproduction cases covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.