Serious question: Why not use source control to identify the files with changes and limit the scope of your formatter run to just those files. If the unchanged files met the formatter rules when they were committed, then repeated runs should be guaranteed to pass. Why introduce a cache when you could just do less work?
Because on CI there's no guarantee that the parent commit has already passed. It might be unchecked, in progress, or CI failed despite being a parent commit.
Now you could query the CI from the CI but that seems to be a dubious dependency to me, and user would need to set up an access token.