Cancel for streaming Responses
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.6k
- Forks
- 5.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 96
Description
Confirm this is a feature request for the Python library and not the underlying OpenAI API.
- This is a feature request for the Python library
Describe the feature or improvement you're requesting
Allow for cancellation of streaming/synchronous responses.
Additional context
Currently, responses.cancel is only supported for background responses
For streaming responses one can sever the connection and start a new run from a new response_id node.
However, this could have cost implications. I.e. if a user cancels a run, we do not want to pay for extra compute on the the next ResponseCompletedEvent; this is especially notable if the LLM wants to do multiple tool calls.
Is this, canceling a streaming response, something that is already happening by default when a an OpenAI user disconnects? if not could we please have this feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/openai/resources/responses/responses.py around the responses.cancel definition at lines 1457–1458, then trace how streaming responses are handled. Determine whether disconnecting a stream already cancels server-side work or whether library support is needed. Done means a streaming or synchronous response can be cancelled without continuing unnecessary processing, with behavior confirmed by tests or documented API behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100