earendil-works/pi · error · SessionError

not_found

not_found

Error message

Session not found: ${metadata.id}

What it means

Error "Session not found: ${metadata.id}" thrown in earendil-works/pi.

Source

Thrown at packages/agent/src/harness/session/jsonl/repo.ts:94

			const [firstLine] = fileResult(
				await options.fs.readTextLines(file.path, { maxLines: 1 }),
				`Failed to read session header ${file.path}`,
			);
			if (!firstLine) continue;
			const headerResult = parseHeader(firstLine);
			if (!headerResult.ok) continue;
			metadata.push(metadataFromHeader(headerResult.value, file.path, file.mtimeMs));
		}
	}
	return metadata.sort((left, right) => right.modifiedAt - left.modifiedAt);
}

export async function loadJsonlSessionStorage(
	options: JsonlSessionRepoOptions,
	metadata: JsonlSessionMetadata,
): Promise<JsonlSessionStorage> {
	if (!fileResult(await options.fs.exists(metadata.path), `Failed to check session ${metadata.path}`)) {
		throw new SessionError("not_found", `Session not found: ${metadata.id}`);
	}
	const storage = await JsonlSessionStorage.load(options.fs, metadata.path);
	const loadedMetadata = await storage.getMetadata();
	if (loadedMetadata.id !== metadata.id) {
		throw new SessionError("invalid_entry", `Session id does not match header: ${metadata.id}`);
	}
	return storage;
}

function sessionFileName(createdAt: number, id: string): string {
	const timestamp = new Date(createdAt).toISOString().replace(/[:.]/g, "-");
	return `${timestamp}_${id}.jsonl`;
}

export class JsonlSessionRepo
	implements SessionRepo<JsonlSessionMetadata, JsonlSessionCreateOptions, JsonlSessionListOptions>
{
	private readonly fs: JsonlSessionRepoFileSystem;

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Check the session id and that the session file exists in the sessions directory; create or restore the session first.

When it happens

Trigger: Thrown at packages/agent/src/harness/session/jsonl/repo.ts:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/43cdd61cf8008be0. Report an issue: GitHub.