Repository navigation
Description
what happens
session import accepts a session and reports success, but the imported session can never be continued. every subsequent message fails within ~500ms with:
AI.Error.Authentication: OpenCode's free tier can only be used from within OpenCode. Download it at https://opencode.ai and keep building.
both from the TUI and from opencode run --session <id> "...". the error text then lands in the transcript as assistant messages, so the session fills with repeats of it.
the same session continued via opencode run --session <id> --fork "..." works — the fork is created through the normal path, carries the full imported history, and the model resumes context correctly. so the imported history itself is fine; something about how imported sessions come into existence breaks the free-tier auth path.
repro (minimal, fully synthetic)
{
"info": { "id": "<fresh ses id>", "projectID": "global", "title": "probe", "time": { "created": 0, "updated": 0, "idle": 0, "viewed": 0 }, "cost": 0, "tokens": { "input": 0, "output": 0, "reasoning": 0, "cache": { "read": 0, "write": 0 } }, "outcome": "succeeded", "agent": "build", "model": { "id": "mimo-v2.6-flash-free", "providerID": "opencode" }, "subpath": "Users/Admin", "location": { "directory": "C:/Users/Admin" } },
"messages": [ { "id": "<fresh msg id>", "time": { "created": 0 }, "type": "user", "text": "hello" } ]
}opencode session import probe.json # -> Imported session: ses_...
opencode run --session ses_... "say ok" # -> identity error, every time
opencode run --session ses_... --fork "say ok" # -> works
fresh CLI-created sessions and run --session <cli-session-id> resumes work every time, on the same server process, same model, same config. 100% deterministic: imported fails, native works, across ~10 probes.
what was ruled out (each still fails identically)
- history size: a 51-message / 688KB slice fails the same as a 6661-message / 69MB one
- content: a synthetic
hellofails; original session content fails - info fields: fresh minimal info fails; copied info fails
- model variant: with and without
"variant": "default"ininfo.model - message id scheme: random hex ids and native-shaped
format(ms, "012x") + 14 alnumids both fail
db rows of imported vs native sessions are near-identical (session_v2 / session_message; parts=0, events=0 for both). the request is actually sent — an assistant row is written with the model ref, ~460ms round trip — and comes back rejected.
workaround
fork once after import (run --session <imported-id> --fork "<msg>") and continue in the fork; the imported original is disposable. ideal fix: register imported sessions on the same path as native ones, or fail import loudly if the session cannot be used.
environment
- opencode 2.0.23, windows x64, background service (
opencode serve --service) - model
opencode/mimo-v2.6-flash-free(zen free tier) with a capabilities override in project config - related: session: importing a session whose message IDs already exist returns HTTP 500 instead of a conflict #54336 (the import-500 variant), sessions with image parts in history wedge forever in an endless 'model does not support images' loop #55309 / session: provider image rejection bricks session — generic 400 error, no recovery path #52042 (wedge family)
Activity
opencode-agent commentedon Oct 14, 2026
Thanks for the detailed report. I couldn't reproduce this on 2.0.23 (Linux x64) against the real Zen free tier with
opencode/mimo-v2.6-flash-free:probe.json: freshly generatedses_/msg_IDs, times set to 0, agentbuild, onehellomessage, with and withoutsubpath. Then I ranopencode run --session <id> "say ok"and got a normal reply.--forkworked too.So your setup must be different in some way. These would help us narrow it down:
opencode.json/.jsonc) with any secrets removed, especially the capabilities override. Do you also have aproviderentry pointing athttps://opencode.ai/zen/v1? Several people saw this same error today because of that entry (OpenCode's free tier can only be used from within OpenCode. Download it at https://opencode.ai and keep building. #55443, OpenCode's free tier can only be used from within OpenCode. Download it at https://opencode.ai and keep building. #55435).run --sessionfrom an empty directory with no project config, or with--standaloneinstead of the background service?ses_/msg_IDs forprobe.json? Could you attach the exact file that fails?You can reply here or edit the issue. If you edit it, please also leave a comment so we know you're done.
Related issues, ordered by likelihood:
bash: deny)opencode.ai/zen/v1provider entry in the configFahadBinHussain commentedon Oct 14, 2026
thanks for looking. results from my side (windows x64, 2.0.23):
opencode.ai/zen/v1entry anywhere (0 matches). the provider block is minimal -provider.opencode.models."mimo-v2.6-flash-free".capabilities = {tools: true, input: ["text"], output: ["text"]}(the session: provider image rejection bricks session — generic 400 error, no recovery path #52042 workaround) plus unrelated custom providers.permissionis the string form"allow".location.directoryis the empty dir (a first pass with only the client cwd moved was inconclusive: the session row's directory pointed back at the project). so no project config is involved at all.prefix + token_hex(6) + 14 alnum; I also tried native-shaped message ids (format(<ms>, "012x") + 14 alnum) - same failure either way.opencode serve --service(~10h uptime, several config rewrites today). haven't tried 2.0.29 yet - restarting the service kills live sessions on this box, so before I do: is there a known change to the import/session-registration path between 2.0.23 and 2.0.29?--standalone: skipping for now - this box has a documented two-process-on-one-sqlite hazard (a v1 importer incident), so I don't spawn a second opencode against the live db while sessions are running. happy to test with a throwaway data dir if that would help.one more data point: fresh
run(new session) andrun --session <cli-created-id>resumes work every time on the same service, same model, same config - the rejection is strictly imported sessions, ~10/10 deterministic, ~460ms round trip (the request is sent - an assistant row with the model ref gets written, outcomefailed).json{"info": {"id": "ses_337b1f84e5c1go74AcDxAHZvNV", "projectID": "global", "title": "probe-p6-emptydir", "time": {"created": 1792003000000, "updated": 1792003000000, "idle": 1792003000000, "viewed": 1792003000000}, "cost": 0, "tokens": {"input": 0, "output": 0, "reasoning": 0, "cache": {"read": 0, "write": 0}}, "outcome": "succeeded", "agent": "build", "model": {"id": "mimo-v2.6-flash-free", "providerID": "opencode"}, "subpath": "tmp/oc-empty", "location": {"directory": "C:\\\\tmp\\\\oc-empty"}}, "messages": [{"id": "msg_87a89ae7a7cdv26eooEcyquOwr", "time": {"created": 1792003000000}, "type": "user", "text": "hello"}]}opencode-agent commentedon Oct 14, 2026
Thanks, the exact probe file was the missing piece. I can reproduce this now, on 2.0.23 and on the latest release, 2.0.29.
The trigger is the session ID format, not the history or the other info fields:
probe.jsonas is (ses_337b1f84e5c1go74AcDxAHZvNV), thenopencode run --session <id> "say ok"fails with "OpenCode's free tier can only be used from within OpenCode…".--forkworks.ses_+ 12 hex digits encoding an inverted timestamp + 14 letters/digits, as OpenCode generates them.ses_+ random-hex-prefix ID fails every time.OpenCode accepts any ID that starts with
seson import, but the free-tier check on the server appears to reject IDs without a valid embedded timestamp. A fork gets a freshly generated native ID, which would explain why forking works. The script below reproduces both cases.To answer your question: nothing between 2.0.23 and 2.0.29 changes this, so restarting your service to upgrade won't fix it. Until it's fixed, you can keep forking after import, or generate session IDs the native way (
ses_+(~(ms * 0x1000 + counter))as 12 hex digits + 14 letters/digits). Exporting a session from OpenCode also gives you a valid ID. Related: #50627 is another case where the free-tier check rejects requests built from inside OpenCode.Reproduction script (repro.sh)
Run it:
bash repro.sholcanaskar commentedon Oct 19, 2026
Adding a data point from #57147 that sharpens this and questions the "fork works" workaround.
Environment: Desktop app / background service 2.0.32, Windows 11, model
opencode/deepseek-v4.1-flash-free, agentplan.An imported session (
ses_Ddv16i0l55Ptn7tNW6rUg3wL4n— note the ID is not in the nativeses_+ 12 hex + 14 alphanumeric form) fails on every prompt with the free-tier error. A brand-new session in the same project, same agent and model, works at the same moment.Forking does not rescue it here:
POST /api/session/<imported>/fork {"before": "<first message id>"}-> a fork with 0 messages.FreeTierError, pre-inference (~1 s, 0 tokens).That matches
SessionAffinity.get(parentID ?? fork.sessionID ?? id): a fork keeps reporting the fork source's session ID for provider cache routing, so the gateway still sees the imported ID even though the fork's own ID is native.So
opencode run --session <id> --forkmay have worked in the original report for a different reason (the fork path at that time, or a native-ID source). As of 2.0.32 on 2026-10-19, forking an imported session does not avoid the rejection.FahadBinHussain commentedon Oct 20, 2026
the fork workaround in the report doesn't hold on current builds, and the source explains why.
packages/core/src/session/affinity.ts(from #51931):model-request.tsbuilds the provider identity headers from that value:so a fork keeps presenting the fork source's id in
x-opencode-session, and its own (native) id only goes inx-opencode-session-id. an empty fork of an imported session still carries the imported id, which is what olcanaskar measured on 2.0.32: empty fork of the imported session fails, empty fork of a native session works, seconds apart.one more detail on the id itself: the check decodes the timestamp, it isn't a shape check.
ses_337b1f84e5c1go74AcDxAHZvNVmatchesses_+ 12 hex + 14 alnum, but the prefix decodes to an implausible time and gets rejected. an id minted with the generator in the bot's repro works.so the only workaround that survives is re-importing under a freshly minted native id. longer term,
session importshould mint one when the incoming id doesn't decode, instead of storing it as-is.