Repository navigation
desktop: opening a subfolder roots new sessions at the git repo root, so its .opencode agents are not found #57583
Description
Summary
In OpenCode Desktop v2.1.x, opening a subfolder of a git repository that has its own .opencode/opencode.json (defining custom agents) still roots newly created sessions at the git repo root instead of the opened subfolder. Agents defined in the subfolder's config are therefore not registered for those sessions, and using them fails with Session.AgentNotFoundError: Agent not found. The same setup worked in 2.0.x, where sessions were rooted at the opened folder.
Environment
- opencode version: 2.1.1 (also reproduced on 2.1.0)
- OS: Microsoft Windows [Version 10.0.17763.737] (win32 x64)
- Terminal: N/A (desktop app,
@opencode-aidesktop) - Shell: C:\Windows\system32\cmd.exe
- Install/channel: latest (desktop app auto-update; service versions observed: 2.0.32 → 2.1.0 → 2.1.1)
- Active plugins:
superpowers@git+https://github.com/obra/superpowers.git(project config). Note: 4 legacy V1 plugin files under~/.config/opencode/plugins/fail to load withCannot find package '@opencode-ai/plugin'— unrelated to this issue.
Reproduction
- Have a git repo
<repo>containing a subfolder<repo>/docs/with its own.opencode/opencode.jsonthat defines an agent (e.g.wiki-agent,mode: primary) and sets"default_agent": "wiki-agent". - In OpenCode Desktop, open the
docs/folder directly as a window/project. - Create a new session in that window and use
wiki-agent(either explicitly selected or viadefault_agent). - Send any message.
Expected Behavior
The new session's location is <repo>/docs, the subfolder config is discovered, and wiki-agent is available. This was the behavior in 2.0.x — sessions created this way had directory = <repo>/docs.
Actual Behavior
- The server does boot the subfolder location and registers its agents there (log:
location services booted directory="<repo>\docs", followed byagent.updatedevents withevent.location.directory="<repo>\docs"). - However, the newly created session is persisted with
directory = <repo>(git repo root), not the opened subfolder. - Sending a message fails:
level=ERROR message="Failed to drain Session" cause="Session.AgentNotFoundError: Agent not found: \"wiki-agent\""
Control experiments showing the server side works correctly when the session location is actually the subfolder:
GET /api/agent?location[directory]=<repo>/docs→wiki-agentis present (modeprimary, permissions parsed).POST /api/sessionwith{"agent":"wiki-agent","location":{"directory":"<repo>/docs"}}+ a prompt → session completes withoutcome: "succeeded".- Running the CLI from
<repo>/docs(opencode run "ping") → session runs aswiki-agentand succeeds.
Additional Context
- Reproduced consistently over two consecutive days across two service instances (v2.1.0 and v2.1.1), multiple attempts, including after explicitly re-opening the subfolder.
- The desktop app does request the subfolder location:
location services booted directory="<repo>\docs"is logged immediately before session creation, yet the created session row hasdirectory = <repo>and emptypath. - Historical 2.0.x sessions created in the same subfolder have
directory = <repo>/docs, so this appears to be a behavior change introduced in 2.1.x (session location now resolves to the git project root). - Workaround: run the CLI/TUI with cwd set to the subfolder — sessions are then rooted correctly and the subfolder agent works as expected.
Activity
opencode-agent commentedon Oct 21, 2026
Thanks for the detailed report and the control experiments, @TheSilverLord! I think this is a duplicate of #51191. In both, a new session for a folder inside a git repository is created at the repository root, so that folder's
.opencodeconfig is never discovered. #51191 is about skills in the web UI, but the web UI and the desktop app share the same session-creation code.Possible duplicates and related issues, ordered from most to least likely:
.opencodecontents are not loaded. Open PR fix(app): keep local sessions in the selected directory #57358 targets it and also covers the desktop subfolder case.subpath) and a regression around v2.0.26.Until it's fixed, besides starting the CLI/TUI from the subfolder, you can move an existing session to the subfolder with
POST /api/session/{id}/move(the workaround reported in #51992).The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. Please follow #51191 for updates.
opencode-agent commentedon Oct 22, 2026
Closing this as a duplicate of #51191, since a day has passed with no reply saying how it differs. In both, a new session for a subfolder of a git repository is created at the repository root, so the subfolder's
.opencodeconfig (yourwiki-agenthere) is not found.Please follow #51191 for updates. Open PR #57358 targets it and also covers the desktop subfolder case. If you think your problem is different, reply here and we can reopen it.