affaan-m/ECC · error · Error
No OpenCode sessions found
Error message
No OpenCode sessions found
What it means
resolveSessionInfoPath was called with target 'latest' (or opencode:latest) but findLatestSessionInfo(storageDir) returned null. The OpenCode adapter found no session-info JSON files in the resolved OpenCode storage directory.
Source
Thrown at scripts/lib/session-adapters/opencode.js:130
return files
.map(filePath => ({ filePath, updatedMs: readSessionUpdatedMs(filePath) }))
.sort((a, b) => b.updatedMs - a.updatedMs)[0].filePath;
}
function findSessionInfoById(storageDir, sessionId) {
return listSessionInfoFiles(storageDir)
.find(filePath => path.basename(filePath, '.json') === sessionId) || null;
}
function resolveSessionInfoPath(target, cwd, options, context) {
const explicitTarget = parseOpencodeTarget(target);
const storageDir = resolveStorageDir(options, context);
if (explicitTarget) {
if (explicitTarget === 'latest') {
const latest = findLatestSessionInfo(storageDir);
if (!latest) {
throw new Error('No OpenCode sessions found');
}
return { sessionInfoPath: latest, sourceTarget: { type: 'opencode', value: 'latest' } };
}
const absoluteExplicit = path.resolve(cwd, explicitTarget);
if (fs.existsSync(absoluteExplicit) && isSessionInfoFile(absoluteExplicit)) {
return { sessionInfoPath: absoluteExplicit, sourceTarget: { type: 'opencode-session-file', value: absoluteExplicit } };
}
const byId = findSessionInfoById(storageDir, explicitTarget);
if (byId) {
return { sessionInfoPath: byId, sourceTarget: { type: 'opencode', value: explicitTarget } };
}
throw new Error(`OpenCode session not found: ${explicitTarget}`);
}
View on GitHub (pinned to 01e15490f0)
Solutions
- Run OpenCode at least once so it creates a session-info file, then retry 'latest'.
- Verify the storage directory resolveStorageDir points at exists and contains session info JSON files.
- If the storage root or project id is overridden, set them to the values that actually hold the sessions.
- Pass an explicit session id or absolute path instead of 'latest'.
Example fix
// before
adapter.open('opencode:latest', { cwd });
// after
adapter.open('opencode:<known-session-id>', { cwd });
// or run `opencode` once to seed the storage directory, then retry 'latest' Defensive patterns
Strategy: validation
Validate before calling
const latest = findLatestSessionInfo(storageDir);
if (!latest) {
throw new Error(`No OpenCode sessions in ${storageDir}; run 'opencode' first or pass an explicit session id.`);
} Type guard
function hasAnyOpencodeSession(storageDir) {
return listSessionInfoFiles(storageDir).length > 0;
} Try / catch
try { return resolveSessionInfoPath('latest', cwd, options, context); }
catch (err) {
if (err.message === 'No OpenCode sessions found') {
throw new Error('No OpenCode sessions found. Pass an explicit session id or session-info path.');
}
throw err;
} Prevention
- Run OpenCode once before scripting against 'latest'.
- Confirm the storage root and project id resolve to the dir holding session-info files.
- Prefer explicit ids in automation.
When it happens
Trigger: Requesting the latest OpenCode session on a machine where OpenCode has never run, or where the storage directory is set to an empty/non-existent path. OPENCODE storage root or the project id is overridden so resolveStorageDir points elsewhere.
Common situations: Fresh environment with no OpenCode sessions. CI container with isolated HOME lacking the OpenCode storage dir. Project id passed via context does not match any stored session. OpenCode version writes to a different storage layout.
Related errors
- No Claude session history found
- No Codex rollout sessions found
- OpenCode session not found: ${explicitTarget}
- Unsupported OpenCode session target: ${target}
- No install profile, module IDs, or included component IDs we
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/205ee5cc49618046.
Report an issue: GitHub.