
openai
#6710000
thread_operation_error
Cannot add messages to a thread while an active run is in progress.
This error has been identified and solved.
Reason
The error you are encountering, "Can't add messages to thread_DGLEaUgn2GcoePBT3OIBwt2g while a run run_P6Ym01xOZJsFmhTL7b5zfJVY is active," is due to the following reasons:
Active Run: The error indicates that there is an active run associated with the thread you are trying to add messages to. OpenAI's API does not allow adding new messages to a thread while a run is still in progress.
Invalid Request: This is a type of "invalid_request_error" where the API cannot process the request because the thread is currently engaged in an active run, making it invalid to add new messages at that time.
Solution
To resolve the error "Can't add messages to thread while a run is active," you need to ensure that there are no active runs associated with the thread before attempting to add new messages. Here are the steps to follow:
Check for Active Runs: Verify if there are any active runs associated with the thread using the API's
active_runs
endpoint.Cancel or Wait for Active Run: If an active run is found, either cancel it or wait for it to complete before adding new messages to the thread.
Validate Thread Status: Ensure the thread is in a state that allows new messages to be added, meaning no active runs are in progress.
Retry the Request: Once the active run is no longer in progress, retry adding the message to the thread.
Suggested Links
https://cheatsheet.md/chatgpt-cheatsheet/openai-api-error-axioserror-request-failed-status-code-400 https://community.openai.com/t/troubleshooting-api-integration-with-openais-language-model/627096 https://community.openai.com/t/issue-with-assistant-api-cannot-add-message-to-thread-due-to-active-run/1090639 https://community.openai.com/t/getting-400-response-with-already-working-code/509212 https://help.openai.com/en/articles/6897213-openai-library-error-types-guidance