-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(openai-native): add abort controller for request cancellation #9276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add instance-level abort controller for external cancellation support - Pass abort signal to SDK and fetch requests - Check abort signal in streaming loops to stop yielding immediately - Update tests to expect abort signal parameter - All tests pass (32/32)
Review complete. Found 1 issue that should be addressed:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| // Last top-level response id from Responses API (for troubleshooting) | ||
| private lastResponseId: string | undefined | ||
| // Abort controller for cancelling ongoing requests | ||
| private abortController?: AbortController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an instance-level abort controller creates a concurrency hazard. If multiple requests are made concurrently (which can happen in tests or when the handler is reused), they would all share the same abortController instance. This means:
- Starting a new request would overwrite the abort controller from a previous in-flight request
- Aborting one request could unintentionally abort another concurrent request
- The finally block of one request could clear the abort controller while another request is still using it
The Bedrock provider uses method-scoped abort controllers (see bedrock.ts:403-413) which avoids this issue. Consider either:
- Making the abort controller method-scoped like Bedrock
- Or if instance-level cancellation is truly needed, implement proper concurrency control (e.g., tracking multiple in-flight requests)
Fix it with Roo Code or mention @roomote and request a fix.
Summary
Adds abort controller support to the OpenAI Native provider to enable proper stream cancellation when tasks are cancelled.
Changes
Testing
Fixes issue where OpenAI Native provider continues yielding after task cancellation.