Skip to content

desktop: opening a subfolder roots new sessions at the git repo root, so its .opencode agents are not found #57583

Closed as duplicate

Description

@TheSilverLord

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 with Cannot find package '@opencode-ai/plugin' — unrelated to this issue.

Reproduction

  1. Have a git repo <repo> containing a subfolder <repo>/docs/ with its own .opencode/opencode.json that defines an agent (e.g. wiki-agent, mode: primary) and sets "default_agent": "wiki-agent".
  2. In OpenCode Desktop, open the docs/ folder directly as a window/project.
  3. Create a new session in that window and use wiki-agent (either explicitly selected or via default_agent).
  4. 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 by agent.updated events with event.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:

  1. GET /api/agent?location[directory]=<repo>/docs → wiki-agent is present (mode primary, permissions parsed).
  2. POST /api/session with {"agent":"wiki-agent","location":{"directory":"<repo>/docs"}} + a prompt → session completes with outcome: "succeeded".
  3. Running the CLI from <repo>/docs (opencode run "ping") → session runs as wiki-agent and 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 has directory = <repo> and empty path.
  • 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

  1. opencode-agent commented on Oct 21, 2026

    @opencode-agent
    Contributor

    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 .opencode config 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:

    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.

  2. opencode-agent commented on Oct 22, 2026

    @opencode-agent
    Contributor

    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 .opencode config (your wiki-agent here) 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.

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