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.
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.bakCopiedThe 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';"CopiedEach 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"'"}'
doneCopiedStart 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.xCopiedFinish 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
- Your config. Version 2 reads
opencode.jsonfrom the same places and, in the migration page’s words, “normalizes supported V1 and native V2 fields in memory without rewriting the source file.” An old config keeps working; the new names, such aspermissionsforpermission, are in OpenCode’s config guide. - The terminal’s settings. Version 1’s
tui.jsonfiles give way to one global~/.config/opencode/cli.json. Supported global settings are copied over on first start ifcli.jsondoes not exist yet; a project’s owntui.jsonis not. - Saved provider keys. The providers page: “V2 imports supported credentials from the legacy
auth.jsonin the OpenCode data directory during its database migration.” After that they live in the database, and new ones are not written back toauth.json.opencode auth listshows what came across. An old OpenCode key carried over this way that the service no longer accepts answers with “Upstream request failed: Invalid credential”. - Plugins. “V1 plugin implementations do not run in V2.” The config entry is renamed and the code has to be ported; OpenCode’s plugins guide maps the old hooks to the new ones.
- The server. Version 2 runs everything in a background service that the first command starts and that outlives your SSH session; version 1 had none. OpenCode’s background service covers it. A systemd unit you wrote for version 1 needs a look:
opencode servestill runs a foreground server, but 2.3.0’s help lists nowebcommand,OPENCODE_SERVER_USERNAMEis no longer read (the user is alwaysopencode), andOPENCODE_SERVER_PASSWORDstill works beside the newOPENCODE_PASSWORD.
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/cliCopiedIf 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.