{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreife6mqgibb2z46ixli272hqh3daadetw2ayp5ti3kjkdig4awwshm",
"uri": "at://did:plc:lk3jfj3zq4k4wxnk474axylu/app.bsky.feed.post/3mkkg3tzdekk2"
},
"path": "/t/how-to-handling-parallel-response-branches-with-the-openai-responses-api/1379948#post_1",
"publishedAt": "2026-04-28T09:37:25.000Z",
"site": "https://community.openai.com",
"textContent": "I am building an AI chatbot using the Response API to reply to customer messages. Each time a customer sends a message, the AI generates a new response as a reply. I use the previous_response_id mechanism to maintain conversation state — every time a new\nresponse is created, the system overwrites previous_response_id with the newly returned response_id for that customer, so future turns inherit the prior context.\n\nHandling Rapid Consecutive Messages\n\nBecause I do not want any delay, the system must call the API immediately whenever a message arrives from the customer. As a result, when a customer sends another message before the previous response has finished generating, I merge the messages and fire a\nnew parallel API call to produce a fresh response.\n\nExample:\n\n * The customer sends message M1. The system fires an API call with previous_response_id = R0 → in progress → will return responseA.\n * Before responseA completes, the customer sends message M2. The system immediately fires a second API call with previous_response_id = R0 and input [M1, M2] → will return responseB.\n * The output of responseA is discarded and never sent to the customer.\n * Once responseB completes, the chatbot sends its output to the customer and saves previous_response_id = responseB.\n * Subsequent customer messages then form a chain: responseB → responseC → responseD → …\n\n\n\nThe Problem\n\n * In responseA, the AI invokes the function call create_order → an order is created in the database.\n * In responseB, the AI decides not to call create_order (perhaps because the merged content of M1 + M2 led to a different decision).\n * The conversation state now follows the branch R0 → B → C → … and completely bypasses responseA.\n * After several more turns, at some responseX (a descendant of B), the AI decides to call create_order. Since the conversation chain through B has no record of responseA, the model has no way to know that the order was already created. It calls create_order\nagain → the order is duplicated.\n\n\n\nQuestion\n\nIs there a way to handle this scenario where parallel responses are created under the same parent?\n\nConstraints\n\n 1. Due to specific business requirements, the chatbot must call the API to generate a reply immediately upon receiving a message — it cannot wait a few seconds to see whether the customer is going to send a follow-up.\n 2. Creating responses in parallel is mandatory when the customer sends messages in rapid succession.\n\n",
"title": "How to handling Parallel Response Branches with the OpenAI Responses API"
}