Add ai_runtime/asyc background execution as a processing mode for ai_automators
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3579310. -->
Reported by: [harivansh](https://www.drupal.org/user/3678656)
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>Add an optional <code>ai_runtime</code>-backed async processing mode for <code>ai_automators</code>.<br>
<strong>Check-in Date: </strong><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-<br%20/>%0A%20%20dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>
<code>ai_automators</code> already supports several processing modes, including direct execution,<br>
batch processing, queue/cron processing, and field widget processing. These are useful, but none<br>
of them cleanly solve the case where AI field generation is too slow to run inside the original<br>
request and still needs a better user experience than cron-based processing.
</p>
<p>
Direct processing blocks the request and risks timeouts. Batch processing is tied to interactive<br>
batch UX. Queue/cron processing runs later, but does not provide an immediate background-runtime<br>
style execution model. What is missing is a processing mode that starts immediately, runs in the<br>
background, and can persist execution state and final results.
</p>
<p>
This is especially important for larger AI automations and future agentic workflows, where field<br>
generation may involve multiple steps or longer provider response times.
</p>
<h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4>
<p>Not applicable. This is a feature request.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>
Add a new <code>ai_automators</code> worker type backed by <code>ai_runtime</code>, using<br>
<code>runner</code> for detached/background execution.
</p>
<p>The integration should:</p>
<ul>
<li>add a new automator processor option such as <code>AI Runtime Async</code></li>
<li>dispatch automator field generation through <code>runner</code> in detached mode</li>
<li>attach the <code>ai_runtime</code> execution storage observer so execution state can be tracked</li>
<li>update automator status correctly while work is running in the background</li>
<li>save generated field values back onto the entity once execution completes</li>
<li>avoid nested entity saves during entity save hooks, especially for revisionable entities like nodes</li>
</ul>
<p>
To keep responsibilities clear, the integration should live in a dedicated bridge module rather<br>
than hard-coupling core <code>ai_runtime</code> directly to <code>ai_automators</code>.
</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<ul>
<li>finalize the bridge module implementation and review the service boundaries</li>
<li>ensure automator status updates behave correctly for multi-field async executions</li>
<li>validate the integration end to end on revisionable entities such as nodes</li>
<li>document the new worker type and when to choose it over direct, batch, or queue processing</li>
<li>optionally expose execution IDs or execution-state visibility for better debugging and UX</li>
</ul>
<h3>Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)</h3>
<p><strong>User interface changes</strong></p>
<ul>
<li>adds a new worker option in the <code>ai_automators</code> field configuration UI</li>
</ul>
<p><strong>Architecture changes</strong></p>
<ul>
<li>introduces an optional bridge between <code>ai_automators</code> and <code>ai_runtime</code></li>
<li>uses <code>runner</code> as the generic background execution engine</li>
<li>uses <code>ai_runtime</code> for async execution storage and lifecycle tracking</li>
</ul>
<p><strong>Behavioral changes</strong></p>
<ul>
<li>field generation can begin immediately while continuing in the background</li>
<li>provides a clearer execution model for long-running AI automations than queue/cron alone</li>
</ul>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<p>[x] AI Assisted Issue<br><br>
This issue was generated with AI assistance, but was reviewed and refined by the creator.</p>
<p>[ ] AI Assisted Code<br><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><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><br>
This code was generated by an AI and has only been functionally tested.</p>
issue