GuidesHosting choices

OpenCode 1 to 2: old sessions missing after upgrade --major

Old sessions are in the database, filed under "global". Move them back, and what else the OpenCode 1 to 2 upgrade changes: config, keys, plugins, npm.

November 15, 2026The Everpod team
The short answer

If your old conversations vanished after opencode upgrade --major, they are still in OpenCode’s database. Version 1 filed every session started outside a git repository, your home folder included, under one project called global, and version 2 shows only the project of the folder you are in. OpenCode 2.1.4 imports them to the right project, but only on a machine that had not upgraded yet; if yours already had, move each session back with opencode api post /api/session/<id>/move --data '{"directory":"<dir>"}'. The rest of the move: your config keeps working, saved keys come across, version 1 plugins stop working, and a package-manager install changes package.

Why the sessions look gone

The first time version 2 starts, it imports version 1’s sessions into its own tables in ~/.local/share/opencode/opencode.db. Version 1 kept sessions from folders that were not git repositories in a single project, global. Version 2 has a project per folder, and until 2.1.4 the import left those sessions under global, which no folder’s session list shows. The issue that tracks it puts it plainly: “The history is still in the database”. It is open, reproduced, and has more than thirty duplicates closed into it.

On a server this catches nearly everyone, because the usual way to work there is to SSH in and start OpenCode in your home folder or a scratch directory, neither of which is a repository. Sessions from inside a git repository were imported under that repository’s project and show as before.

The changelog for 2.1.4 (October 23, 2026) says “Imported V1 global sessions are now attributed to the correct project.” That only changes imports that happen from then on. OpenCode’s triage bot says it outright: “upgrading alone won’t bring back history for people who already upgraded.” As of 2.3.0 (November 13, 2026) nothing repairs an earlier import by itself; a repair that would run once on server start is an open pull request.

Bringing them back after you upgraded

Back up the database first. A maintainer’s command moves one session into a folder’s project, and it has a cost he names himself: “it resets each session’s updated time,” so moved sessions all sort as if from today.

opencode debug paths db       # where the database is
opencode service stop
cp ~/.local/share/opencode/opencode.db ~/opencode.db.bak
Copied

The stranded sessions are the ones still under global. Reading the database is safe; OpenCode’s troubleshooting page warns against editing it, and the move below goes through OpenCode instead. On Ubuntu, sudo apt install sqlite3 first:

sqlite3 -readonly ~/.local/share/opencode/opencode.db \
  "SELECT id || '|' || directory FROM session_v2 WHERE project_id='global';"
Copied

Each line is a session id and the folder it was started in. Move them with the background service running (any opencode command starts it):

sqlite3 -readonly ~/.local/share/opencode/opencode.db \
  "SELECT id || '|' || directory FROM session_v2 WHERE project_id='global';" |
while IFS='|' read -r sid dir; do
  opencode api post "/api/session/$sid/move" --data '{"directory":"'"$dir"'"}'
done
Copied

Start OpenCode in one of those folders and its sessions are in the list again. To look before moving anything, the bot’s reproduction found that Ctrl+X then L (“List all sessions”) lists every session, though one reporter found that list scoped to the folder too. The maintainer has said he will add a way to repair already-migrated sessions “so you don’t need the move command or SQL”; once that ships, check the changelog before running the loop.

Before you upgrade

If you are still on version 1, opencode upgrade --major installs the newest version 2, which imports correctly. OpenCode’s migration page asks you to “Keep a copy of your V1 setup while validating the migration,” which on Linux is two folders:

opencode --version          # 1.x.x means version 1
cp -a ~/.local/share/opencode ~/opencode-v1-data
cp -a ~/.config/opencode ~/opencode-v1-config
opencode upgrade --major
opencode --version          # opencode v2.x.x
Copied

Finish with version 1 first. The import runs once, and a separate open issue, #50130, reports that sessions version 1 creates after that are never imported, still on 2.3.0. A cron job or a second shell that keeps running an old opencode binary after the upgrade is how a server ends up there.

What the upgrade carries across, and what it leaves

Installed with npm, pnpm, bun or Homebrew

The two versions are different packages: version 1 is opencode-ai on npm, version 2 is @opencode/cli. The migration page asks you to “Remove a package-managed V1 installation before installing V2”. On a current version 1, opencode upgrade --major does that itself, by the version 1 branch’s source as of November 15, 2026: it uninstalls opencode-ai and installs @opencode/cli with npm, pnpm or bun, swaps Homebrew’s formula for anomalyco/tap/opencode-v2, and puts the old package back if the install fails. By hand with npm:

npm uninstall -g opencode-ai
npm install -g @opencode/cli
Copied

If it guesses the method wrong, opencode upgrade --major --method npm names it. A curl install needs nothing removed, since the version 2 installer replaces the binary at ~/.opencode/bin/opencode in place. If a machine has both a curl install and a package-manager one, command -v opencode shows which one your shell runs.

Free models on version 1, and on old sessions

Staying on version 1 is no longer free of cost. The maintainers’ pinned thread says “v1 no longer supports free models and only gets fixes for critical bugs,” and the short install line, curl -fsSL https://opencode.ai/install | bash, still redirects to version 1’s script as of November 15, 2026. A free model refused on version 1 prints “OpenCode’s free tier can only be used from within OpenCode”, and the upgrade is the fix. One report after upgrading had old sessions refused on a free model while a new session worked; a maintainer closed it into the free-tier thread, saying the limit follows imported sessions. Starting a new session was the reporter’s way through.

For a fresh server rather than an upgrade, installing OpenCode on Linux covers both install lines and the PATH line a cron job does not see.

Run OpenCode on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.