Cancel request in responses api

Hi, I have a question regarding the Responses API. If I wanted to pause a request mid-run, would that be possible? I’m finding that when I get an error, I have to delete the context ID. I don’t want to delete the context, but rather pause the previous request. thx! :smile:

1 Like

Same question!

@edwinarbus any idea?

Can’t you just continue from the id previous to the error? It will fork the conversation and continue normally.

Ah. Not sure if this helps you… but helps me at least.

await openai.responses.create(
{
…body
},
{
signal: controller.signal
}
);

Doesn’t actually cancel the stream, but makes it much easier handle canceling the stream on the client.

Currently, it doesn’t look like it’s implemented, but the promise of the responses API is to adopt practically all functionalities from the Assistants API. But i wouldn’t recommend that anyway, i tested that strategy just a couple of weeks ago as a kind of fallback mechanism. You can only cancel runs, that are in progress, which is already a risky thing, because runs can end the moment you start cancelling. And in some cases that ends in a crash (Server error) on its own.

But more important, If you cancel a run, with no real reason (i for example did it even automated, a watcher script cancelled any run that took longer than 40 sec, and started a new run). But that strategy has practically broken the “history”, assistants use as their “short-term memory”. The user messages are getting deleted, when you cancel them while in_progress. But the Assistant completes the request anyway. The assistant responses then appear in the next runs in their memory, but without the user questions that has triggered the responses. The assistant runs can’t be cancelled the same way, like user messages in mid run, the API needs to do that, but at least in my case, it refused. The history ended up with mostly assistants messages, some broken, some missing.