Hello ![]()
I think I found a bug with related to clearing chat history for the llm chat component. Would love to hear if anyone has a solid approach to solving it!
- My goal:
Build a chat bot for our support team to ask questions about a customer's account, when viewing that account in a Retool app
- Issue:
I have a query that calls chatbot.clearHistory() on page load. It does trigger however the state of the component still contains the previous conversation message history and data fields. If I switch to a new tab in my tabbed container that houses the chatbot and then switch back, the state is finally updated and I've got a clean state.
I've also tried not doing it on page load and hiding the chatbot on the initial load and using a button to:
- clear the history
- display the chat component
The same issue still occurs even if I wait until the page has fully loaded and all queries have been resolved. For some reason, the initial rendering of the chat component insists on retaining the message history
- Steps I've taken to troubleshoot:
Approach 1:
- Create LLM chat component within a tabbed container
- Create query that clears the history of the component. Example:
chatComponent.clearHistory() - Add console logs to ensure it's running
- Set the query to run on page load
- Send a message to the LLM via the chat component and wait for the response
- Open up the Debug console and refresh the page
- When the page loads you will see the console logs for the query but the chat content is still visible. Switching tabs in the container and switching back will remove the history. You can verify this by checking the state of the component before and after switching tabs in the tabbed container
Approach 2:
- Set up the components and queries exactly like Approach 1
- Set the
hiddenvalue for the chat component totrue - Add a button with the following event handlers when clicked
- Trigger the query that should clear the chat history
- Set chat component
hiddenvalue tofalse
- Send a message to the LLM via the chat component and wait for the response
- Open up the Debug console and refresh the page
- When the page loads you will see the console logs for the query on page load
- click the button
- You will see console logs for the query again and the chat component will be displayed, still showing the chat history
- Switching tabs in the container and switching back will remove the history. You can verify this by checking the state of the component before and after switching tabs in the tabbed container
- Additional info: (Cloud or Self-hosted, Screenshots)
- hosting: cloud
- video recording of issue: CleanShot 2025-07-23 at 17.36.05

