Skip to content

opencode attach --session fails with 'Session not found' since v1.1.1 #7149

Closed

Description

@rmk40

Description

opencode attach with --session flag fails with "Session not found" error when the client's current working directory differs from the directory where the session was created.

This is a regression introduced in v1.1.1 by commit 401b498 (PR #6715).

OpenCode version

v1.1.1 and later (worked in v1.0.223)

Steps to reproduce

  1. Start opencode server in directory A (e.g., /Users/me/project-a)
  2. Create a session, note the session ID (e.g., ses_abc123)
  3. From a different directory B, run:
    opencode attach "http://localhost:4096" --session "ses_abc123"
  4. Error: "Session not found: ses_abc123"

The same session works fine when accessed via browser at http://localhost:4096/<base64-encoded-directory>/session/ses_abc123.

Root cause

PR #6715 added directory: process.cwd() to the attach command, which sends the client's current working directory as the x-opencode-directory header. Sessions are stored per-project (keyed by directory), so when the client's cwd differs from the session's directory, the server looks in the wrong project and fails to find the session.

Before v1.1.1, no directory was sent, so the server fell back to its own process.cwd() (where the session was created).

Activity

  1. added a commit that references this issue on Jan 7, 2026
    08401af
  2. github-actions commented on Jan 7, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    Both issues describe attach failures in v1.1.1 with session-related errors, though #6874 focuses on the parentID crash during attach while #7149 focuses on the session not being found due to directory mismatch. However, they both appear to be v1.1.1 regressions involving the attach command and session handling.

    Feel free to ignore if this doesn't address your specific case.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions