Skip to content

opencode run --attach ignores OPENCODE_SERVER_PASSWORD #16096

Closed

Description

@ericclemmons

Description

When using opencode run --attach=localhost:<port> with
OPENCODE_SERVER_USERNAME and OPENCODE_SERVER_PASSWORD env vars, the
command fails with "Error: Session not found".

The run command in packages/opencode/src/cli/cmd/run.ts (~line 650) does
not pass auth headers to createOpencodeClient:

if (args.attach) {
  const sdk = createOpencodeClient({ baseUrl: args.attach, directory })
  // No auth headers passed!
  return await execute(sdk)
}

The attach TUI command correctly builds Basic auth headers from the env vars
(in packages/opencode/src/cli/cmd/tui/attach.ts), but run does not.

Plugins

No response

OpenCode version

1.2.17

Steps to reproduce

  1. Start a server with auth: OPENCODE_SERVER_PASSWORD=secret opencode serve --port 4096
  2. Run: OPENCODE_SERVER_USERNAME=opencode OPENCODE_SERVER_PASSWORD=secret opencode --attach=localhost:4096 run hello
  3. Get: Error: Session not found
  4. Compare with opencode attach localhost:4096 -p secret which works fine
    because attach.ts passes auth headers to the SDK client.

Screenshot and/or share link

No response

Operating System

macOS 15.5

Terminal

Ghostty, zsh, cmux

Activity

  1. changed the title [-]`opencode run --attach` ignores OPENCODE_SERVER_PASSWORD auth[/-] [+]`opencode run --attach` ignores OPENCODE_SERVER_PASSWORD[/+] on Mar 5, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 5, 2026
  3. github-actions commented on Mar 5, 2026

    @github-actions
    Contributor

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

  4. added a commit that references this issue on Mar 5, 2026
    66e81a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions