Skip to content

isReasoningTagProvider misses "google" provider — reasoning leaks to user with API key auth #26551

@steinbeck

Description

@steinbeck

Bug

isReasoningTagProvider() in src/utils/provider-utils.ts does not match the google provider (used by gemini-api-key auth), only google-gemini-cli and google-generative-ai. This causes reasoning/thinking output to leak directly to the end user instead of being filtered.

Steps to reproduce

  1. Authenticate with gemini-api-key (creates auth profile google:default with mode: "api_key")
  2. Set default model to google/gemini-3-pro-preview (the value from GOOGLE_GEMINI_DEFAULT_MODEL)
  3. Send a message with thinking enabled (e.g. thinking=low)
  4. The user receives raw <think> reasoning output instead of only the <final> response

Root cause

The model string google/gemini-3-pro-preview yields provider=google. But isReasoningTagProvider only checks for google-gemini-cli (OAuth) and google-generative-ai (API type, not provider ID):

// src/utils/provider-utils.ts
if (normalized === "google-gemini-cli" || normalized === "google-generative-ai") {
  return true;
}

This means:

  • reasoningTagHint is false — no <think>/<final> tag instructions in the system prompt
  • enforceFinalTag is false — no output filtering for <final> blocks
  • The model's thinking output passes through unfiltered to the user

Impact

  • enforceFinalTag is not set → <final> tag filtering is skipped (get-reply-run.ts:495, agent-runner-utils.ts:146)
  • reasoningTagHint is not set → system prompt omits <think>/<final> formatting instructions (system-prompt.ts:340)
  • Affects both Telegram/channel delivery and embedded agent runs

Suggested fix

Add google to the provider check in isReasoningTagProvider:

if (normalized === "google-gemini-cli" || normalized === "google-generative-ai" || normalized === "google") {
  return true;
}

This aligns with:

  • gemini-api-key auth creating profile with provider: "google" (auth-choice.apply.api-providers.ts:568)
  • GOOGLE_GEMINI_DEFAULT_MODEL = "google/gemini-3-pro-preview" (google-gemini-model-default.ts:4)
  • Model catalog tests using providers: { google: { api: "google-generative-ai", ... } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions