anomalyco / anomalyco/opencode
agents: project .opencode/agents/ ignored; global agents leak across projects
Open
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:
- Project-level
.opencode/agents/directory is ignored — file-based agents not discovered - 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
- 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... - Start OpenCode in that project (
opencode --standalone) - Run
opencode debug agents - Observe:
content-agentNOT in list — only built-ins (build, explore, general, plan, summary, title, compaction)
Bug 2: Global agents leak across projects
- Place agent files in
~/.config/opencode/agents/*.md(with proper frontmatter) - Start OpenCode in Project A → agents appear in
debug agents - Start OpenCode in Project B (different directory, no agents) → same agents appear
- 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_agentshould 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
agentsobject (JSON) — works but duplicates prompt from.mdfiles
Additional Context
- This worked in v1. Project
.opencode/agents/(oragent/,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
agentsobject (JSON) works correctly for project scoping - Source agent
.mdfiles preserved in.opencode/agents/withid,name,model,mode,color,descriptionfrontmatter - Config:
/mnt/share/TwoTimesTwo/opencode.jsonchasdefault_agent: "content-agent"andagentsobject with 6 agents (content-agent, daily-agent, deploy-agent, infra-agent, research-agent, visual-agent) - Each agent in config has
// Source: .opencode/agents/<name>.mdcomment linking to source file
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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