Add excluded tags support to AI logging
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3564296. -->
Reported by: [jhedstrom](https://www.drupal.org/user/208732)
Related to !1066 !1157
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>Add excluded tags support to AI logging<br>
<strong>Short Description: </strong>Allow administrators to exclude specific tags from automated AI logging<br>
<strong>Check-in Date: </strong>12/20/2024<br>
<em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>The AI logging module currently supports restricting logging to specific tags via <code>prompt_logging_tags</code> (allowlist), but there's no way to exclude certain tags from logging (blocklist).</p>
<p>This creates issues when you want to log most operations but exclude high-volume tags like <code>embeddings</code> or <code>ai_search</code> that would fill the database unnecessarily.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Add a new <code>prompt_logging_excluded_tags</code> configuration option that works as a blocklist. If a request has any excluded tag, it won't be logged regardless of included tags settings.</p>
<p>Changes:</p>
<ul>
<li>Add <code>prompt_logging_excluded_tags</code> form field to AI logging settings</li>
<li>Update <code>LogPostRequestEventSubscriber::shouldLoggingHappen()</code> to check excluded tags first</li>
<li>Add configuration schema for the new setting</li>
</ul>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<ul>
<li>Review patch</li>
<li>Commit to dev branch</li>
<li>Add test coverage (optional)</li>
</ul>
<h3>Optional: Other details as applicable</h3>
<p><strong>User interface changes:</strong><br><br>
New text field "Exclude automated logging by request tags" on <code>/admin/config/ai/logging</code></p>
<p><strong>API changes:</strong></p>
<ul>
<li>New configuration key: <code>ai_logging.settings.prompt_logging_excluded_tags</code></li>
<li>Behavior: Excluded tags take precedence over included tags</li>
</ul>
issue