earendil-works/pi · error · Error

Failed to create forked session

Error message

Failed to create forked session

What it means

Wrapper error from fork: creating or preparing the forked session (SessionManager.open / new session file operations) failed with an underlying error that is rethrown or aggregated under this message.

Solutions

  1. Inspect the inner error for the filesystem or serialization cause
  2. Check disk space and write permissions for the session directory
  3. Retry the fork after fixing the underlying issue
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/coding-agent/src/core/agent-session-runtime.ts:320 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/965c9e7b101f5d05. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/core/agent-session-runtime.ts:320

						cwd: this.cwd,
						agentDir: this.services.agentDir,
						sessionManager,
						sessionStartEvent: { type: "session_start", reason: "fork", previousSessionFile },
					}),
				);
				await this.finishSessionReplacement(options?.withSession);
				return { cancelled: false, selectedText };
			}

			if (!existsSync(currentSessionFile)) {
				throw new Error(
					"This session has not been saved yet. Wait for the first assistant response before cloning or forking it.",
				);
			}
			const sessionManager = SessionManager.open(currentSessionFile, sessionDir);
			const forkedSessionPath = sessionManager.createBranchedSession(targetLeafId);
			if (!forkedSessionPath) {
				throw new Error("Failed to create forked session");
			}
			await this.teardownCurrent("fork", sessionManager.getSessionFile());
			this.apply(
				await this.createRuntime({
					cwd: sessionManager.getCwd(),
					agentDir: this.services.agentDir,
					sessionManager,
					sessionStartEvent: { type: "session_start", reason: "fork", previousSessionFile },
				}),
			);
			await this.finishSessionReplacement(options?.withSession);
			return { cancelled: false, selectedText };
		}

		const sessionManager = this.session.sessionManager;
		if (!targetLeafId) {
			sessionManager.newSession({ parentSession: this.session.sessionFile });
		} else {

View on GitHub (pinned to 4af9d21d3b)