AI Chatbot: Always create new thread in deep chat api
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3519627. --> Reported by: [ipumpkin](https://www.drupal.org/user/2279442) Related to !559 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>AiAssistantApiRunner setAssistant method will check thread id is empty and create new thread.<br> set request thread id after setAssistant cause create new thread every request.</p> <pre>&nbsp;&nbsp;&nbsp; // Set the assistant in the AiAssistantApiRunner.<br>&nbsp;&nbsp;&nbsp; $this-&gt;aiAssistantClient-&gt;setAssistant($assistant);<br><br>&nbsp;&nbsp;&nbsp; if (isset($data['stream']) &amp;&amp; $data['stream'] === 1) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this-&gt;aiAssistantClient-&gt;streamedOutput(TRUE);<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; // Optionally, set the thread_id if provided.<br>&nbsp;&nbsp;&nbsp; if (isset($data['thread_id'])) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this-&gt;aiAssistantClient-&gt;setThreadsKey($data['thread_id']);<br>&nbsp;&nbsp;&nbsp; }</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>move set request thread id before setAssistant</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>N/A</p> <h3 id="summary-ui-changes">User interface changes</h3> <p>N/A</p> <h3 id="summary-api-changes">API changes</h3> <p>N/A</p> <h3 id="summary-data-model-changes">Data model changes</h3> <p>N/A</p> > Related issue: [Issue #3458832](https://www.drupal.org/node/3458832)
issue