Skip to content

feat(queue): Adding gemini/gemini cli#217

Open
RomuloGatto wants to merge 6 commits intoTinyAGI:mainfrom
RomuloGatto:gemini
Open

feat(queue): Adding gemini/gemini cli#217
RomuloGatto wants to merge 6 commits intoTinyAGI:mainfrom
RomuloGatto:gemini

Conversation

@RomuloGatto
Copy link

@RomuloGatto RomuloGatto commented Mar 14, 2026

Add support for the Google Gemini provider and its models in the agent configuration. Enhance error logging for custom providers during message processing. Remove deprecated Gemini model references from the provider and CLI options.

Changes

  • Added Google provider and models to the configuration

  • Enhanced error logging for custom providers

  • Removed deprecated Gemini model references

Testing

  • Tested the integration of the Google provider and its models

  • Verified error logging for custom providers

Checklist

  • PR title follows conventional commit format (type(scope): description)

  • I have tested these changes locally

  • My changes don't introduce new warnings or errors

  • I have updated documentation if needed

@vercel
Copy link

vercel bot commented Mar 14, 2026

@RomuloGatto is attempting to deploy a commit to the AGI Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link

greptile-apps bot commented Mar 14, 2026

Greptile Summary

This PR adds first-class support for the Google Gemini CLI as a provider across the entire stack — core invocation logic, CLI tooling, server API validation, and the TinyOffice UI. The implementation follows the existing patterns established for Anthropic, OpenAI/Codex, and OpenCode.

Key changes:

  • New google provider and gemini CLI harness added to types, config, CLI, server, and UI
  • resolveGeminiModel helper and GEMINI_MODEL_IDS lookup table added in core
  • Full Gemini invocation path in invokeAgent: writes a system.md, manages a per-agent home directory, handles session-resume with a fallback retry, and parses JSON output
  • Error logging in packages/main enhanced to resolve provider labels for custom providers (claude/codex/gemini harness variants)
  • auth_token fields added to the anthropic and openai frontend type stubs in tinyoffice/src/lib/api.ts (previously missing)

Issues found:

  • Custom Gemini harness silently drops base_url (packages/core/src/invoke.ts lines 115–119): Unlike the claude harness (ANTHROPIC_BASE_URL) and codex harness (OPENAI_BASE_URL), the gemini harness does not map customProvider.base_url to any environment variable, making custom Gemini proxy endpoints non-functional.
  • GEMINI_SANDBOX=true set only for custom harness (packages/core/src/invoke.ts line 118): The built-in google provider never sets this variable, creating an inconsistency in runtime behaviour between the two paths.

Confidence Score: 3/5

  • Safe to merge for built-in Google provider usage; custom Gemini harness has functional gaps.
  • The built-in google provider path is well-implemented and consistent with existing providers. However, the custom Gemini harness has two concrete issues: base_url is silently ignored (breaking proxy/custom-endpoint use cases), and GEMINI_SANDBOX=true is applied asymmetrically. These don't affect the standard google provider path, so the feature is usable, but custom Gemini provider configurations will behave incorrectly.
  • packages/core/src/invoke.ts — custom Gemini harness env-var handling (lines 115–119)

Important Files Changed

Filename Overview
packages/core/src/invoke.ts Core change: adds a full Gemini CLI invocation path. Two logic issues: custom Gemini harness drops base_url entirely (unlike Claude/Codex counterparts), and GEMINI_SANDBOX=true is set only for custom providers, creating inconsistent behaviour vs. the built-in google provider.
packages/core/src/types.ts Adds GEMINI_MODEL_IDS constant, extends CustomProvider.harness union, updates Settings with a google models section, and updates comments. Straightforward and consistent with existing patterns.
packages/core/src/config.ts Adds resolveGeminiModel, extends auto-detection to recognise google provider, and adds a fallback default model. Clean, consistent with the existing pattern for other providers.
packages/main/src/index.ts Improves error logging by resolving the provider label for custom providers (including the new gemini harness). Logic is correct and matches the built-in provider cases.
packages/cli/src/provider.ts Refactors provider/model label helpers and adds Google/Gemini support throughout. Helper functions getModelSection and getProviderLabel improve maintainability. Changes are consistent.
packages/cli/src/shared.ts Adds googleModelOptions(), extends providerOptions() and harnessOptions() with Google/Gemini entries, and adds model-selection logic for the google provider. Clean additions.
packages/server/src/routes/agents.ts Extends custom-provider harness validation to accept 'gemini'. Single-line, well-targeted change.
tinyoffice/src/app/setup/page.tsx Adds Google/Gemini to the setup wizard constants and model spreads. Consistent with how other providers are handled.
tinyoffice/src/app/agents/page.tsx Adds google option to the provider dropdown and a badge colour for Google agents. Straightforward UI addition.
tinyoffice/src/lib/api.ts Adds auth_token to the existing anthropic and openai model interfaces (previously missing from the frontend type) and introduces the new google model interface. Correct alignment with the core Settings type.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Main as packages/main (processMessage)
    participant Invoke as packages/core (invokeAgent)
    participant Config as packages/core (config)
    participant GeminiCLI as gemini CLI

    Client->>Main: message
    Main->>Config: getSettings()
    Config-->>Main: settings (provider resolved)
    Main->>Invoke: invokeAgent(agent, ...)

    alt provider = 'custom:<id>' with harness='gemini'
        Invoke->>Config: lookup customProvider
        Config-->>Invoke: base_url, api_key, harness='gemini'
        Note over Invoke: Sets GOOGLE_API_KEY, GEMINI_API_KEY,<br/>GEMINI_SANDBOX=true<br/>(base_url silently ignored ⚠️)
        Invoke->>Invoke: provider = 'google'
    else provider = 'google' (built-in)
        Invoke->>Config: getSettings() for auth_token
        Config-->>Invoke: google.auth_token (optional)
        Note over Invoke: Sets GOOGLE_API_KEY, GEMINI_API_KEY<br/>(no GEMINI_SANDBOX set — inconsistent ⚠️)
    end

    Invoke->>Invoke: resolveGeminiModel(effectiveModel)
    Invoke->>Invoke: write system prompt to system.md
    Invoke->>GeminiCLI: gemini --approval-mode=yolo --output-format json [--resume latest] --model M --prompt P

    alt session resume fails
        GeminiCLI-->>Invoke: error: "No previous sessions found"
        Invoke->>GeminiCLI: retry without --resume
    end

    GeminiCLI-->>Invoke: JSON output
    Invoke->>Invoke: parse JSON → extract response field
    Invoke-->>Main: response text

    alt error thrown
        Main->>Main: resolve providerLabel (Claude/Codex/Gemini/OpenCode)
        Main->>Main: log ERROR with label
        Main-->>Client: error fallback message
    end

    Main-->>Client: response
Loading

Last reviewed commit: 11c99dd

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant