Create AI assistant API session only after the first message
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3554797. --> Reported by: [omarlopesino](https://www.drupal.org/user/2853043) Related to !978 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Currently, when the chatbot is added in the site for anonymous users, a new session is started in order to create the thread. This is necessary, but it can be optimized. Creating a session invalidates reverse proxy caches like Varnish or any kind of CDN, decreasing the site's performance. The session may be only created after the first interaction with the chatbot.</p> <h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4> <ol> <li>Create an assistant with AI assistant API and AI agents setting up 'Session' in Advanced -&gt; Allow History.</li> <li>Add an ai chatbot block to any page (block layout, layout builder, etc).</li> <li>Enter to the page as anonymous. </li> </ol> <p>After this , a session is started.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Only store thread ID after the first message is added by user / system.</p>
issue