Skip to content

feat(llm): GOOGLE_AI_PERSONAL — route Gemini to consumer AI Studio key#26

Merged
dnplkndll merged 2 commits into
feature/explorer-endpointsfrom
feat/gemini-personal-key
May 22, 2026
Merged

feat(llm): GOOGLE_AI_PERSONAL — route Gemini to consumer AI Studio key#26
dnplkndll merged 2 commits into
feature/explorer-endpointsfrom
feat/gemini-personal-key

Conversation

@dnplkndll

Copy link
Copy Markdown

Reopens #24 (auto-closed by GitHub when its base feat/summarize-flash-lite was deleted on PR #25 merge). Same diff, rebased onto current feature/explorer-endpoints.

Adds a config switch that points GeminiProvider at the consumer Gemini API (generativelanguage.googleapis.com) with a personal AI Studio key, instead of Vertex on GOOGLE_CLOUD_PROJECT. Used to peel high-volume traffic off the billed org project — consumer API has a free tier and bills the personal account.

When GOOGLE_AI_PERSONAL is set on AppConfig, get_client() returns genai.Client(api_key=...). Region/DE-lockout checks skipped (consumer API is globally routed). Empty string = disabled, default unchanged.

Use:

  1. Mint key at https://aistudio.google.com/app/apikey
  2. Add GOOGLE_AI_PERSONAL=AIza... to /opt/sentry-extra/secrets/seer.env
  3. Recreate seer container

Rollback: unset env + restart.

4 unit tests pin both branches of the routing decision (key-set, key-empty, region-skip, DE-bypass).

Bugbot review applied: properly fixed the B006 mutable-default-arg in construct_message_from_stream instead of papering over with # noqalist[str] = []list[str] | None = None + normalize-at-top guard. Confirmed callsite safety (only one production caller, passes explicitly).

dnplkndll added 2 commits May 22, 2026 07:44
Stacks on PR #23. Adds a config switch that points GeminiProvider at
the consumer Gemini API (generativelanguage.googleapis.com) with a
personal AI Studio key, instead of Vertex on GOOGLE_CLOUD_PROJECT.

When GOOGLE_AI_PERSONAL is set on AppConfig, GeminiProvider.get_client()
returns genai.Client(api_key=...) instead of genai.Client(vertexai=True,
location=...). Region selection is skipped on this path — the consumer
API is globally routed.

Empty string = disabled. Default behavior unchanged.

Use: mint a key at https://aistudio.google.com/app/apikey, drop into
/opt/sentry-extra/secrets/seer.env as GOOGLE_AI_PERSONAL=AIza...,
recreate seer container. Rollback = unset + restart.

4 unit tests pin both branches of the routing decision.
Bugbot finding on PR #24: the `# noqa: B006` was hiding a real bug
(shared-state across calls via the mutable default `list[str] = []`).
The proper fix is small enough to do here:

  - Default `thinking_content_chunks: list[str] = []` (mutable) →
    `thinking_content_chunks: list[str] | None = None` + a guard
    `if thinking_content_chunks is None: thinking_content_chunks = []`
    at the top of the function.

The Anthropic inner provider method expects a non-optional `list[str]`,
so the normalization happens in the LlmClient wrapper — provider
contract stays unchanged.

Confirmed callsite safety: the only production caller in
autofix_agent.py:232 passes `thinking_content_chunks` explicitly, so
no caller relies on the mutable-default's empty-list identity.

8 tests pass (4 personal-key + the existing construct_message_from_stream
coverage).
@dnplkndll dnplkndll merged commit 75a6234 into feature/explorer-endpoints May 22, 2026
6 checks passed
@dnplkndll dnplkndll deleted the feat/gemini-personal-key branch May 22, 2026 11:47
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