earendil-works/pi · error · SessionError

already_exists

already_exists

Error message

Session already exists: ${destination.id}

What it means

Error "Session already exists: ${destination.id}" thrown in earendil-works/pi.

Source

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

	private async resolveCreateDestination(options: JsonlSessionCreateOptions): Promise<{ id: string; cwd: string }> {
		const id = options.id ?? uuidv7();
		validateSessionId(id);
		const cwd = fileResult(await this.fs.absolutePath(options.cwd), `Failed to resolve session cwd ${options.cwd}`);
		return { id, cwd };
	}

	/**
	 * Prevent same-process create/fork races for one logical destination. The durable filename includes a
	 * timestamp, so the async filesystem existence check alone can let two concurrent calls both decide the
	 * same {cwd, id} is free and publish duplicate sessions.
	 */
	private async claimCreateDestination<T>(
		destination: { id: string; cwd: string },
		operation: () => Promise<T>,
	): Promise<T> {
		const key = `${destination.cwd}\0${destination.id}`;
		if (this.activeCreateDestinations.has(key)) {
			throw new SessionError("already_exists", `Session already exists: ${destination.id}`);
		}
		this.activeCreateDestinations.add(key);
		try {
			return await operation();
		} finally {
			this.activeCreateDestinations.delete(key);
		}
	}

	private async prepareCreate(
		destination: { id: string; cwd: string },
		options: JsonlSessionCreateOptions,
	): Promise<{
		header: JsonlV4Header;
		path: string;
	}> {
		const { id, cwd } = destination;
		if (await this.sessionIdExists(id, cwd)) {

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Choose a new destination session id, or delete the existing session before copying.

When it happens

Trigger: Thrown at packages/agent/src/harness/session/jsonl/repo.ts:180 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/09e24dc7bd5e4492. Report an issue: GitHub.