I had implemented a temporary solution which what this does is to re-write the history when PermissionDenied exception occurs by re-iterating the existing ChatSession.history object and use the new history within the new ChatSession object history parameter without all the file references, although it involves some redundant code