nanocoai/nanoclaw · error · Error
session not found: ${sessionId}
Error message
session not found: ${sessionId} What it means
Thrown by `ownSession` in the tasks resource when `getSession(sessionId)` returns no row — no session with that id exists in the central DB. The id may have been mistyped, deleted, or never created; the tasks CLI refuses to operate on it.
Source
Thrown at src/cli/resources/tasks.ts:77
}
function statusFilter(args: Record<string, unknown>): TaskStatus | undefined {
const status = str(args.status);
if (!status) return undefined;
if (status !== 'pending' && status !== 'paused') {
throw new Error('--status must be pending or paused');
}
return status;
}
function groupArg(args: Record<string, unknown>, ctx: CallerContext): string | undefined {
if (ctx.caller === 'agent') return ctx.agentGroupId;
return str(args.group) ?? str(args.agent_group_id);
}
async function ownSession(sessionId: string, ctx: CallerContext): Promise<ScopedSession> {
const session = await getSession(sessionId);
if (!session) throw new Error(`session not found: ${sessionId}`);
if (ctx.caller === 'agent' && session.agent_group_id !== ctx.agentGroupId) {
throw new Error(`session not found: ${sessionId}`);
}
return { id: session.id, agent_group_id: session.agent_group_id };
}
async function selectedSessions(
args: Record<string, unknown>,
ctx: CallerContext,
includeClosed = false,
): Promise<ScopedSession[]> {
const sessionId = str(args.session);
if (sessionId) return [await ownSession(sessionId, ctx)];
const group = groupArg(args, ctx);
if (group) {
// One session per live task series — the loops below already fan out across them.
return (await findTaskSessions(group, includeClosed)).map((s) => ({View on GitHub (pinned to 294ef2aee8)
Solutions
- List real sessions with `ncl sessions list` (or `ncl sessions list --json`) and copy the exact id
- If scripting, resolve the session id dynamically instead of hardcoding it
- Confirm you are pointed at the right install/DB if the session came from another environment
Example fix
# before ncl tasks list --session sess_typo123 # after ncl sessions list # copy exact id ncl tasks list --session sess_ab12cd34
Defensive patterns
Strategy: validation
Validate before calling
const sessions = await execNclJson(['sessions', 'list']);
const ok = sessions.some(s => s.id === sessionId);
if (!ok) throw new Error(`unknown session ${sessionId}; run ncl sessions list`);
await execNcl(['tasks', 'list', '--session', sessionId]); Type guard
const isExistingSessionId = (id: string, known: {id: string}[]) =>
known.some(s => s.id === id); Try / catch
catch (e) { if (e.message.startsWith('session not found:')) { refresh session cache and retry once } else throw e; } Prevention
- Never hardcode session ids in long-lived scripts — resolve them at runtime
- Sessions are ephemeral; re-resolve after restarts or rewiring
- Validate ids against `ncl sessions list --json` before use
When it happens
Trigger: `ncl tasks list --session <bad-id>`, `ncl tasks create --session <bad-id> ...`, or any tasks verb that routes through selectedSessions with a nonexistent session id.
Common situations: Copy/paste of a truncated session id; session was cleaned up (sessions are runtime artifacts and can disappear); referencing a session from another install or environment; typo in a scripted id variable.
Related errors
- ${def.name} not found: ${id}
- group not found: ${id}
- No container config for group: ${id}
- MCP server "${name}" not found
- member not found
AI-assisted analysis of nanocoai/nanoclaw@294ef2aee8 (2026-08-28).
Data as JSON: /api/errors/3aaec00514094bf9.
Report an issue: GitHub.