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->getStructuredOutput() (line 305 of modules/contrib/aiagents/src/PluginBase/AiAgentBase.php).<br><br>Drupal\aiagents\Plugin\AiAssistantAction\AgentAction->triggerAction() (Line: 406)<br>Drupal\aiassistantapi\AiAssistantApiRunner->process() (Line: 127)<br>Drupal\aichatbot\Form\ChatForm->submitForm()<br>calluserfuncarray() (Line: 129)<br>Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)<br>Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 597)<br>Drupal\Core\Form\FormBuilder->processForm() (Line: 144)<br>Drupal\autosaveform\Form\AutosaveFormBuilder->processForm() (Line: 326)<br>Drupal\Core\Form\FormBuilder->buildForm() (Line: 97)<br>Drupal\autosaveform\Form\AutosaveFormBuilder->buildForm() (Line: 242)<br>Drupal\aichatbot\Plugin\Block\ChatFormBlock->build() (Line: 171)<br>Drupal\block\BlockViewBuilder::preRender()<br>calluserfunc_array() (Line: 113)<br>Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 870)<br>Drupal\Core\Render\Renderer->doCallback() (Line: 432)<br>Drupal\Core\Render\Renderer->doRender() (Line: 504)<br>Drupal\Core\Render\Renderer->doRender() (Line: 248)<br>Drupal\Core\Render\Renderer->render() (Line: 476)<br>Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 163)<br>_TwigTemplatea6daddf5db7afd38bdd7a28820cbf4a7->doDisplay() (Line: 393)<br>Twig\Template->yield() (Line: 349)<br>Twig\Template->display() (Line: 364)<br>Twig\Template->render() (Line: 35)<br>Twig\TemplateWrapper->render() (Line: 33)<br>twigrendertemplate() (Line: 348)<br>Drupal\Core\Theme\ThemeManager->render() (Line: 491)<br>Drupal\Core\Render\Renderer->doRender() (Line: 248)<br>Drupal\Core\Render\Renderer->render() (Line: 476)<br>Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 92)<br>_TwigTemplatec80b4cee356caa7a247354cd1c770e6b->doDisplay() (Line: 393)<br>Twig\Template->yield() (Line: 349)<br>Twig\Template->display() (Line: 364)<br>Twig\Template->render() (Line: 35)<br>Twig\TemplateWrapper->render() (Line: 33)<br>twigrendertemplate() (Line: 348)<br>Drupal\Core\Theme\ThemeManager->render() (Line: 491)<br>Drupal\Core\Render\Renderer->doRender() (Line: 248)<br>Drupal\Core\Render\Renderer->render() (Line: 158)<br>Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent{closure}() (Line: 638)<br>Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 153)<br>Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)<br>Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()<br>calluserfunc() (Line: 111)<br>Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)<br>Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)<br>Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)<br>Drupal\Core\StackMiddleware\Session->handle() (Line: 48)<br>Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)<br>Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)<br>Drupal\big¨C13Ccache\StackMiddleware\PageCache->pass() (Line: 90)<br>Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)<br>Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)<br>Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)<br>Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)<br>Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)<br>Drupal\Core\DrupalKernel->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