967
throw new Error(`Cannot fork session ${sourceSessionId}: turn ${fork.turnId} not found in transcript`);
968
}
969
>
const { sessionId: newSessionId } = await this._sdkService.forkSession(sourceSessionId, { upToMessageId });
claudeAgent.ts
970
>
const newSessionUri = AgentSession.uri(this.id, newSessionId);
971
>
972
>
// Inherit the source's model / permissionMode / agent (create-config
973
>
// overrides win) so the lazy `_resumeSession` seeds `Options` from
974
>
// it. `customizationDirectory` is NOT inherited — it is the source's
975
>
// per-session synced plugin dir (Phase 11); the fork re-syncs its own.
976
>
let sourceOverlay: IClaudeSessionOverlay = {};
977
>
try {
978
>
sourceOverlay = await this._metadataStore.read(fork.session);
979
>
} catch (err) {
980
this._logService.warn(`[Claude] fork: source overlay read failed for ${sourceSessionId}; continuing with defaults`, err);
981
}
982
>
const model = config.model ?? sourceOverlay.model;
claudeAgent.ts
983
const agent = config.agent ?? sourceOverlay.agent;
984
const permissionMode = narrowClaudePermissionMode(config.config?.[ClaudeSessionConfigKey.PermissionMode]) ?? sourceOverlay.permissionMode;