Run one OpenCode server per state folder and workspace #83

Closed
opened 2026-11-22 15:07:35 +01:00 by motoko · 0 comments
Collaborator

What happens

Each opencode launch starts a container of its own (podman run --rm --init, bin/azkaban), and every launch of an identity mounts the same
state folder. OpenCode 2.x expects one background server per user to own
the sessions, permissions, and tool execution, registered in
~/.local/state/opencode/service.json with its database in
~/.local/share/opencode/opencode.db
(CLI, Background service). Both paths
lie in the shared state, so two launches either meet a registration they
cannot reach or, with --standalone, run two private servers on one
database.

Seen on Azkaban's master of 2026-11-20, with OpenCode 2.x on rootless
Podman: two sessions of one identity on one checkout, each with its own
opencode serve --stdio --port 0. Session lists and tabs of every
project mix, since each workspace is /workspace.

Proposal

One server per state folder and workspace:

  1. A launch that finds a running container for the same state folder and
    workspace joins it with podman exec -it and runs the client there,
    which discovers the server already registered.
  2. The container starts detached and stops when its last client exits.

Open decisions

  • The memory limit then covers a project's sessions together.
  • A supervisor that signals the launcher, as a tmux pane's end does,
    must end the client inside the container.
  • Projects need state of their own first, which --account gives today;
    whether a launch derives it from the workspace.

Untried on a host.

## What happens Each `opencode` launch starts a container of its own (`podman run --rm --init`, `bin/azkaban`), and every launch of an identity mounts the same state folder. OpenCode 2.x expects one background server per user to own the sessions, permissions, and tool execution, registered in `~/.local/state/opencode/service.json` with its database in `~/.local/share/opencode/opencode.db` ([CLI, Background service](https://opencode.ai/docs/cli/)). Both paths lie in the shared state, so two launches either meet a registration they cannot reach or, with `--standalone`, run two private servers on one database. Seen on Azkaban's `master` of 2026-11-20, with OpenCode 2.x on rootless Podman: two sessions of one identity on one checkout, each with its own `opencode serve --stdio --port 0`. Session lists and tabs of every project mix, since each workspace is `/workspace`. ## Proposal One server per state folder and workspace: 1. A launch that finds a running container for the same state folder and workspace joins it with `podman exec -it` and runs the client there, which discovers the server already registered. 2. The container starts detached and stops when its last client exits. ## Open decisions - The memory limit then covers a project's sessions together. - A supervisor that signals the launcher, as a tmux pane's end does, must end the client inside the container. - Projects need state of their own first, which `--account` gives today; whether a launch derives it from the workspace. Untried on a host.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/azkaban#83
No description provided.