Skip to content

opencode -s resumes sessions from the launch directory instead of the stored session directory #28581

Closed

Description

@ualtinok

Description

Running opencode -s <session-id> should resume the session in that session's stored working directory. Today, local resume can keep using the directory where the command was launched instead.

That makes the resumed session look correct in history, but the active execution context can be wrong:

  • prompts report the launch directory rather than the session directory
  • relative file paths resolve from the launch directory
  • tools and shell commands run against the wrong project
  • TUI resume starts the worker with the launch/project directory even when the session was created elsewhere

This is easy to hit when resuming a known session from a different terminal directory, or when continuing sessions across worktrees/subdirectories.

Plugins

None required.

OpenCode version

Current dev.

Steps to reproduce

  1. Create a session in directory A.
  2. From directory B, run opencode -s <session-id-from-A>.
  3. Ask opencode for the current working directory or run a relative file/tool operation.

Expected: the resumed session uses directory A, the stored session.directory.

Actual: the resumed session can continue using directory B, the launch directory.

Screenshot and/or share link

No response

Operating System

macOS, but this is CLI/session directory handling and should not be OS-specific.

Terminal

Any terminal.

Activity

  1. github-actions commented on May 21, 2026

    @github-actions
    Contributor

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

    • [BUG]: Session switching doesn't change working directory context #6697: [BUG]: Session switching doesn't change working directory context — describes the same root cause: when resuming/switching sessions, the execution context remains bound to the launch directory (Instance.directory) rather than the session's stored directory. That issue was closed but the behaviour you describe appears to still be present.
  2. jensenojs commented on Jun 2, 2026

    @jensenojs
    Contributor

    At present, it seems that this issue has been "resolved" in a certain sense. If you resume through a different path, the conversation cannot continue, and the interface will freeze (though the conversation itself continues). I believe this is still a bug, but unfortunately, I sometimes rely on this "feature."

    My experience is that current large models don't seem to be easily confused by path switching, but switching paths allows them to correctly utilize the AGENTS.md files I've set up in other paths.

  3. ualtinok commented on Jun 2, 2026

    @ualtinok
    ContributorAuthor

    Oh I forgot to link the PR which solves this issue:

    #28582

  4. self-assigned this
    on Jun 2, 2026
  5. jlongster commented on Jun 2, 2026

    @jlongster
    Contributor

    Yes, this should be fixed! Unfortunately the TUI had a bug so this didn't fully work properly but that bug has been fixed in #30281 and will be out in the next release

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

Metadata

Metadata

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