UAT: ProviderType.GEMINI not handled in create_ai_provider() — falls through to generic path #5501

Open
opened 2026-04-09 07:06:27 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Additional LLM Backends — Gemini Provider Integration
Severity: Medium (functional gap for Gemini-specific provider type)
Found by: UAT Testing (uat-pool-1, worker: additional-llm-backends)


What Was Tested

The ProviderRegistry.create_ai_provider() method and its handling of the GEMINI provider type.

Expected Behavior

When a user sets CLEVERAGENTS_DEFAULT_PROVIDER=gemini (using ProviderType.GEMINI), the registry should return a GoogleChatProvider instance — the same dedicated adapter used for ProviderType.GOOGLE.

Actual Behavior

In registry.py, the create_ai_provider() method has explicit handling for:

  • ProviderType.OPENAI → returns OpenAIChatProvider
  • ProviderType.ANTHROPIC → returns AnthropicChatProvider
  • ProviderType.GOOGLE → returns GoogleChatProvider
  • ProviderType.OPENROUTER → returns OpenRouterChatProvider

But ProviderType.GEMINI is NOT handled. It falls through to the generic LangChainChatProvider factory path at the bottom of the method, which creates a generic provider using _create_provider_llm().

While _create_provider_llm() does handle GEMINI (it maps it to ChatGoogleGenerativeAI), the resulting object is a plain LangChainChatProvider rather than a GoogleChatProvider. This means:

  1. The provider name will be "gemini" instead of "google" — inconsistent with the GoogleChatProvider which hardcodes name="google"
  2. Any GoogleChatProvider-specific behavior or future overrides won't apply

Code Location

src/cleveragents/providers/registry.py, method create_ai_provider():

# Lines handling GOOGLE but NOT GEMINI:
if provider_type == ProviderType.GOOGLE:
    from cleveragents.providers.llm.google_provider import GoogleChatProvider
    ...
    return GoogleChatProvider(...)

# GEMINI falls through to generic path below:
resolved_provider_type: ProviderType = provider_type
def llm_factory(mid: str) -> BaseLanguageModel:
    ...
return LangChainChatProvider(...)

Steps to Reproduce

from cleveragents.providers.registry import ProviderRegistry, ProviderType
from cleveragents.config.settings import Settings

settings = Settings(gemini_api_key="test-key")
registry = ProviderRegistry(settings)
provider = registry.create_ai_provider(provider_type=ProviderType.GEMINI)

# Expected: GoogleChatProvider with name="google"
# Actual: LangChainChatProvider with name="gemini"
print(type(provider))  # LangChainChatProvider, not GoogleChatProvider
print(provider.name)   # "gemini", not "google"

Impact

Users who configure CLEVERAGENTS_DEFAULT_PROVIDER=gemini (using the GEMINI_API_KEY env var) get a different provider object than users who configure CLEVERAGENTS_DEFAULT_PROVIDER=google. This inconsistency can cause subtle behavioral differences.

Suggested Fix

Add a GEMINI case to create_ai_provider() that mirrors the GOOGLE case:

if provider_type in (ProviderType.GOOGLE, ProviderType.GEMINI):
    from cleveragents.providers.llm.google_provider import GoogleChatProvider
    key_attr = self.PROVIDER_KEY_ATTRS.get(provider_type)
    api_key = getattr(self._settings, key_attr, None) if key_attr else None
    if not api_key:
        ...raise ValueError...
    return GoogleChatProvider(
        api_key=api_key,
        model=model_id or self.DEFAULT_MODELS.get(provider_type, "gemini-2.0-flash"),
        max_retries=max_retries,
    )

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area**: Additional LLM Backends — Gemini Provider Integration **Severity**: Medium (functional gap for Gemini-specific provider type) **Found by**: UAT Testing (uat-pool-1, worker: additional-llm-backends) --- ## What Was Tested The `ProviderRegistry.create_ai_provider()` method and its handling of the `GEMINI` provider type. ## Expected Behavior When a user sets `CLEVERAGENTS_DEFAULT_PROVIDER=gemini` (using `ProviderType.GEMINI`), the registry should return a `GoogleChatProvider` instance — the same dedicated adapter used for `ProviderType.GOOGLE`. ## Actual Behavior In `registry.py`, the `create_ai_provider()` method has explicit handling for: - `ProviderType.OPENAI` → returns `OpenAIChatProvider` - `ProviderType.ANTHROPIC` → returns `AnthropicChatProvider` - `ProviderType.GOOGLE` → returns `GoogleChatProvider` - `ProviderType.OPENROUTER` → returns `OpenRouterChatProvider` But **`ProviderType.GEMINI` is NOT handled**. It falls through to the generic `LangChainChatProvider` factory path at the bottom of the method, which creates a generic provider using `_create_provider_llm()`. While `_create_provider_llm()` does handle `GEMINI` (it maps it to `ChatGoogleGenerativeAI`), the resulting object is a plain `LangChainChatProvider` rather than a `GoogleChatProvider`. This means: 1. The provider name will be `"gemini"` instead of `"google"` — inconsistent with the `GoogleChatProvider` which hardcodes `name="google"` 2. Any `GoogleChatProvider`-specific behavior or future overrides won't apply ## Code Location `src/cleveragents/providers/registry.py`, method `create_ai_provider()`: ```python # Lines handling GOOGLE but NOT GEMINI: if provider_type == ProviderType.GOOGLE: from cleveragents.providers.llm.google_provider import GoogleChatProvider ... return GoogleChatProvider(...) # GEMINI falls through to generic path below: resolved_provider_type: ProviderType = provider_type def llm_factory(mid: str) -> BaseLanguageModel: ... return LangChainChatProvider(...) ``` ## Steps to Reproduce ```python from cleveragents.providers.registry import ProviderRegistry, ProviderType from cleveragents.config.settings import Settings settings = Settings(gemini_api_key="test-key") registry = ProviderRegistry(settings) provider = registry.create_ai_provider(provider_type=ProviderType.GEMINI) # Expected: GoogleChatProvider with name="google" # Actual: LangChainChatProvider with name="gemini" print(type(provider)) # LangChainChatProvider, not GoogleChatProvider print(provider.name) # "gemini", not "google" ``` ## Impact Users who configure `CLEVERAGENTS_DEFAULT_PROVIDER=gemini` (using the `GEMINI_API_KEY` env var) get a different provider object than users who configure `CLEVERAGENTS_DEFAULT_PROVIDER=google`. This inconsistency can cause subtle behavioral differences. ## Suggested Fix Add a `GEMINI` case to `create_ai_provider()` that mirrors the `GOOGLE` case: ```python if provider_type in (ProviderType.GOOGLE, ProviderType.GEMINI): from cleveragents.providers.llm.google_provider import GoogleChatProvider key_attr = self.PROVIDER_KEY_ATTRS.get(provider_type) api_key = getattr(self._settings, key_attr, None) if key_attr else None if not api_key: ...raise ValueError... return GoogleChatProvider( api_key=api_key, model=model_id or self.DEFAULT_MODELS.get(provider_type, "gemini-2.0-flash"), max_retries=max_retries, ) ``` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.6.0 milestone 2026-04-09 07:13:00 +00:00
Author
Owner

Label compliance fix applied:

  • Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

Label compliance fix applied: - Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#5501
No description provided.