Telling AI Assistant with Module Agent available to turn off the AI module causes fatal error
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3487501. --> Reported by: [mrdalesmith](https://www.drupal.org/user/2612656) >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>This command should be expected to cause issues, but this wasn't the one I expected so I've added it as low priority.</p> <pre>The website encountered an unexpected error. Try again later.<br><br>TypeError: Drupal\aiagents\PluginBase\AiAgentBase::getStructuredOutput(): Return value must be of type Drupal\aiagents\Output\StructuredResultData, null returned in Drupal\aiagents\PluginBase\AiAgentBase-&gt;getStructuredOutput() (line 305 of modules/contrib/aiagents/src/PluginBase/AiAgentBase.php).<br><br>Drupal\aiagents\Plugin\AiAssistantAction\AgentAction-&gt;triggerAction() (Line: 406)<br>Drupal\aiassistantapi\AiAssistantApiRunner-&gt;process() (Line: 127)<br>Drupal\aichatbot\Form\ChatForm-&gt;submitForm()<br>calluserfuncarray() (Line: 129)<br>Drupal\Core\Form\FormSubmitter-&gt;executeSubmitHandlers() (Line: 67)<br>Drupal\Core\Form\FormSubmitter-&gt;doSubmitForm() (Line: 597)<br>Drupal\Core\Form\FormBuilder-&gt;processForm() (Line: 144)<br>Drupal\autosaveform\Form\AutosaveFormBuilder-&gt;processForm() (Line: 326)<br>Drupal\Core\Form\FormBuilder-&gt;buildForm() (Line: 97)<br>Drupal\autosaveform\Form\AutosaveFormBuilder-&gt;buildForm() (Line: 242)<br>Drupal\aichatbot\Plugin\Block\ChatFormBlock-&gt;build() (Line: 171)<br>Drupal\block\BlockViewBuilder::preRender()<br>calluserfunc_array() (Line: 113)<br>Drupal\Core\Render\Renderer-&gt;doTrustedCallback() (Line: 870)<br>Drupal\Core\Render\Renderer-&gt;doCallback() (Line: 432)<br>Drupal\Core\Render\Renderer-&gt;doRender() (Line: 504)<br>Drupal\Core\Render\Renderer-&gt;doRender() (Line: 248)<br>Drupal\Core\Render\Renderer-&gt;render() (Line: 476)<br>Drupal\Core\Template\TwigExtension-&gt;escapeFilter() (Line: 163)<br>_TwigTemplatea6daddf5db7afd38bdd7a28820cbf4a7-&gt;doDisplay() (Line: 393)<br>Twig\Template-&gt;yield() (Line: 349)<br>Twig\Template-&gt;display() (Line: 364)<br>Twig\Template-&gt;render() (Line: 35)<br>Twig\TemplateWrapper-&gt;render() (Line: 33)<br>twigrendertemplate() (Line: 348)<br>Drupal\Core\Theme\ThemeManager-&gt;render() (Line: 491)<br>Drupal\Core\Render\Renderer-&gt;doRender() (Line: 248)<br>Drupal\Core\Render\Renderer-&gt;render() (Line: 476)<br>Drupal\Core\Template\TwigExtension-&gt;escapeFilter() (Line: 92)<br>_TwigTemplatec80b4cee356caa7a247354cd1c770e6b-&gt;doDisplay() (Line: 393)<br>Twig\Template-&gt;yield() (Line: 349)<br>Twig\Template-&gt;display() (Line: 364)<br>Twig\Template-&gt;render() (Line: 35)<br>Twig\TemplateWrapper-&gt;render() (Line: 33)<br>twigrendertemplate() (Line: 348)<br>Drupal\Core\Theme\ThemeManager-&gt;render() (Line: 491)<br>Drupal\Core\Render\Renderer-&gt;doRender() (Line: 248)<br>Drupal\Core\Render\Renderer-&gt;render() (Line: 158)<br>Drupal\Core\Render\MainContent\HtmlRenderer-&gt;Drupal\Core\Render\MainContent{closure}() (Line: 638)<br>Drupal\Core\Render\Renderer-&gt;executeInRenderContext() (Line: 153)<br>Drupal\Core\Render\MainContent\HtmlRenderer-&gt;renderResponse() (Line: 90)<br>Drupal\Core\EventSubscriber\MainContentViewSubscriber-&gt;onViewRenderArray()<br>calluserfunc() (Line: 111)<br>Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch() (Line: 186)<br>Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw() (Line: 76)<br>Symfony\Component\HttpKernel\HttpKernel-&gt;handle() (Line: 53)<br>Drupal\Core\StackMiddleware\Session-&gt;handle() (Line: 48)<br>Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle() (Line: 28)<br>Drupal\Core\StackMiddleware\ContentLength-&gt;handle() (Line: 32)<br>Drupal\big&uml;C13Ccache\StackMiddleware\PageCache-&gt;pass() (Line: 90)<br>Drupal\page_cache\StackMiddleware\PageCache-&gt;handle() (Line: 48)<br>Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle() (Line: 51)<br>Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle() (Line: 36)<br>Drupal\Core\StackMiddleware\AjaxPageState-&gt;handle() (Line: 51)<br>Drupal\Core\StackMiddleware\StackedHttpKernel-&gt;handle() (Line: 741)<br>Drupal\Core\DrupalKernel-&gt;handle() (Line: 19)</pre><p>AI module still enabled after command.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>Prompts:</p> <p>Turn off AI module</p> <p>(assistant ask for action to be confirmed)</p> <p>Yes</p> <p>(Error generated)</p>
issue