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> // Set the assistant in the AiAssistantApiRunner.<br> $this->aiAssistantClient->setAssistant($assistant);<br><br> if (isset($data['stream']) && $data['stream'] === 1) {<br> $this->aiAssistantClient->streamedOutput(TRUE);<br> }<br><br> // Optionally, set the thread_id if provided.<br> if (isset($data['thread_id'])) {<br> $this->aiAssistantClient->setThreadsKey($data['thread_id']);<br> }</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