Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 29, 2025

Remove leftover Gemini CLI code

… Anthropic API usage

- Remove gemini-cli from provider names list and discriminated union
- Fix buildApiHandler default case to use claude-code instead of anthropic when provider is undefined
- Add proper error handling for unknown providers instead of silently defaulting to Anthropic
- This prevents Claude Code from incorrectly using user Anthropic API keys

Fixes #6382
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 29, 2025 19:42
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Jul 29, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 29, 2025
roomote[bot]

This comment was marked as outdated.

@daniel-lxs
Copy link
Member

@roomote-agent revert the change to the default case completely please, do not create a new PR

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 31, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Jul 31, 2025

I understand. I will revert the change to the default case completely and push the changes to this same PR branch.

@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 31, 2025
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jul 31, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Jul 31, 2025

Done! I have reverted the default case in buildApiHandler back to its original state as requested. The change restores the original behavior:

default:
    apiProvider satisfies "gemini-cli" | undefined
    return new AnthropicHandler(options)

The modification has been pushed to this PR branch and CI checks are running. Local tests passed successfully.

@daniel-lxs
Copy link
Member

@roomote-agent Now make it look like this:

default:
    return new AnthropicHandler(options)

Push to this PR, do not create a new one

@roomote
Copy link
Contributor Author

roomote bot commented Jul 31, 2025

I see the request to change the default case to return new AnthropicHandler(options). Let me check out the PR branch and make this change.

@roomote
Copy link
Contributor Author

roomote bot commented Jul 31, 2025

Done! ✅

I have simplified the default case in the buildApiHandler function as requested. The change removes the TypeScript satisfies check and now simply returns new AnthropicHandler(options).

Changes made:

  • Modified src/api/index.ts lines 118-120
  • Removed the apiProvider satisfies "gemini-cli" | undefined line
  • Simplified to just return new AnthropicHandler(options)

Testing:

  • All API tests passed successfully
  • Linting and type checking completed without errors
  • Changes have been pushed to this PR branch

The modification aligns with the PR's goal of cleaning up references to the removed gemini-cli provider.

@daniel-lxs daniel-lxs changed the title fix: remove gemini-cli provider and fix fallback to prevent incorrect Anthropic API usage remove: Cleanup gemini cli remains Jul 31, 2025
@daniel-lxs daniel-lxs changed the title remove: Cleanup gemini cli remains remove: Cleanup gemini cli leftovers Jul 31, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 31, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jul 31, 2025
@daniel-lxs
Copy link
Member

@roomote-agent make sure no errors occur if a user has a removed provider selected, make sure it fallback to the first provider in the list, do not create a new PR, push to this one

@roomote
Copy link
Contributor Author

roomote bot commented Aug 4, 2025

Hi @daniel-lxs! I see your request. I will implement the fallback logic to ensure that if a user has a removed provider (like gemini-cli) selected, it will gracefully fallback to the first available provider in the list. Working on this now and will push the changes to this PR branch.

- Add validation in webviewDidLaunch to check if current provider is still supported
- Add validation in activateProviderProfile to prevent activation of removed providers
- Automatically fallback to first available valid provider when removed provider is detected
- Show warning message to user when provider is switched due to removal
- Add comprehensive tests for provider fallback behavior

This ensures users with removed providers (like gemini-cli) will automatically
be switched to a valid provider instead of encountering errors.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Aug 4, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Aug 4, 2025

@daniel-lxs I've implemented the fallback mechanism as requested! 🎯

Implementation Summary

I added validation logic to ensure users with removed providers (like "gemini-cli") are automatically switched to a valid provider:

Changes Made:

  1. Webview Launch Validation (webviewMessageHandler.ts):

    • Added provider validation in the webviewDidLaunch handler
    • Checks if the current provider exists in the providerNames array
    • Automatically finds and activates the first configuration with a valid provider
  2. Provider Activation Safeguard (ClineProvider.ts):

    • Modified activateProviderProfile to validate providers before activation
    • Implements recursive fallback if an invalid provider is detected
    • Shows a warning message to notify users when their provider is switched
  3. Comprehensive Test Coverage (webviewMessageHandler.spec.ts):

    • Added tests for provider fallback scenarios
    • Covers edge cases like all providers being invalid
    • Ensures graceful handling when no valid providers exist

How It Works:

When a user with "gemini-cli" (or any removed provider) selected opens the extension:

  1. The system detects the invalid provider
  2. Searches for the first configuration with a valid provider
  3. Automatically switches to that configuration
  4. Displays a warning: "Provider 'gemini-cli' is no longer supported. Falling back to first available provider."

All tests are passing ✅ and the changes have been pushed to this PR branch as requested!

@daniel-lxs daniel-lxs closed this Aug 18, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Aug 18, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 18, 2025
@daniel-lxs daniel-lxs deleted the fix/remove-gemini-cli-provider-fallback branch August 18, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants