Access check is making page to be uncacheable
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3525900. -->
Reported by: [emacoti](https://www.drupal.org/user/2930721)
Related to !627
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Found that when the ai.admin_providers and the ai.admin_vdb_providers menu links are rendered, like on the admin toolbar, the page cache becomes uncacheable. After some research I found that the access checker for providers and vdb_providers are trying to add user account cache metadata to the result but the user account does not implement the `CacheableDependencyInterface` and so it is just setting max-age to 0. That is making the page cache to become uncacheable.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Enable the ai module and load pages with a user that has permission to render ai menu links. When these menu items are rendered, the page cache should be uncacheable.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>The main reason to add user cache metadata at this point is to make the result vary based on user. This can also be achieved by adding the `user.permissions` cache context.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Remove the `addCacheableDependency` for the user account and add the `user.permissions` cache context instead.</p>
issue