Add Guardrails support to AI Automators
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3585690. -->
Reported by: [breidert](https://www.drupal.org/user/135619)
Related to !1528
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>[One-line status update for stakeholders]<br>
<strong>Short Description: </strong>[One-line issue summary for stakeholders]<br>
<strong>Check-in Date: </strong>MM/DD/YYYY<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>Currently, the AI Automators module allows for automated content generation and field processing, but it does not natively integrate with the AI module's Guardrails system.</p>
<p>Site builders using Automators (e.g., for automatic translation, summarization, or SEO generation) should be able to apply Guardrail Sets to these processes. This ensures that automated content adheres to safety, liability, and quality standards (e.g., preventing PII leaks or blocking forbidden topics) before the content is saved to the entity.</p>
<h3 id="summary-remaining-tasks">Todo</h3>
<ul>
<li>Update the AI Automator configuration form to allow selecting one or more Guardrail Sets.</li>
<li>Modify the Automator execution logic to attach the selected Guardrail Sets to the ChatInput or PromptInput before sending it to the provider.</li>
<li>Handle StopResult responses from guardrails gracefully by logging a warning and preventing the field from being updated with "unsafe" content.</li>
<li>Ensure that "global guardrails" (if configured in the AI module) are also correctly respected during Automator runs.</li>
</ul>
<h3>Accept</h3>
<ul>
<li>When configuring an AI Automator on a field, there is a "Guardrails" section to select a Guardrail Set.</li>
<li>If an Automator triggers a guardrail (e.g., a "Legal Advice" guardrail), the field update is aborted.</li>
<li>The user/admin receives feedback (via logs or message) when an automation is blocked by a guardrail.</li>
<li>The implementation uses the standard AiGuardrailHelper or event-based approach consistent with the core AI module.</li>
</ul>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<p>[x] AI Assisted Issue<br>
This issue was generated with AI assistance, but was reviewed and refined by the creator.</p>
<p>[ ] AI Assisted Code<br>
This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</p>
<p>[ ] AI Generated Code<br>
This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.</p>
<p>[ ] Vibe Coded<br>
This code was generated by an AI and has only been functionally tested.</p>
issue