Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 16, 2026

This PR attempts to address Issue #10779.

Problem

The Stop button in Roo Code does not work for OpenAI Compatible API providers (llama.cpp, LM Studio, etc.). When users press the Stop button, the UI shows stop but the inference continues running on the server because no abort/cancellation signal is sent to the API.

Root Cause

The OpenAiHandler and BaseOpenAiCompatibleProvider classes were missing AbortController support. When the Task class calls cancelCurrentRequest(), there was no abort signal being passed to the underlying OpenAI SDK calls.

Solution

Added AbortController support to both handler classes:

  1. OpenAiHandler (src/api/providers/openai.ts):

    • Added abortController property
    • Create abort controller at the start of createMessage() and completePrompt()
    • Pass signal: this.abortController.signal to all SDK calls
    • Check for abort signal in stream loops to break early when cancelled
    • Clean up controller in finally blocks
  2. BaseOpenAiCompatibleProvider (src/api/providers/base-openai-compatible-provider.ts):

    • Same pattern applied for consistency across all OpenAI-compatible providers

This mirrors the existing implementation in OpenAiNativeHandler which already has proper abort support.

Testing

  • Updated existing tests to expect the abort signal in request options
  • All 61 tests pass

Feedback and guidance are welcome.


Important

Add AbortController support to OpenAiHandler and BaseOpenAiCompatibleProvider for request cancellation, updating tests accordingly.

  • Behavior:
    • Add AbortController support to OpenAiHandler and BaseOpenAiCompatibleProvider classes for request cancellation.
    • In createMessage() and completePrompt(), create and clean up AbortController.
    • Pass abortController.signal to SDK calls in openai.ts and base-openai-compatible-provider.ts.
    • Check for abort signal in stream loops to break early if cancelled.
  • Testing:
    • Update tests in openai.spec.ts and base-openai-compatible-provider.spec.ts to expect AbortSignal in request options.
    • Ensure all tests pass with the new abort functionality.

This description was created by Ellipsis for 5d606ba. You can customize this summary. It will automatically update as commits are pushed.

Fixes #10779 - Stop button now properly cancels requests for OpenAI
Compatible API providers (llama.cpp, LM Studio, etc.)

Changes:
- Add abortController property to OpenAiHandler and BaseOpenAiCompatibleProvider
- Pass abort signal to all SDK calls in createMessage and completePrompt methods
- Check for abort signal in stream loops to break early when cancelled
- Update tests to expect abort signal in request options
@roomote
Copy link
Contributor Author

roomote bot commented Jan 16, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly adds AbortController support to OpenAI-compatible providers, following the established pattern from OpenAiNativeHandler. All SDK calls now receive abort signals, and stream loops properly check for abort conditions.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants