Skip to content

refactor(llm): consolidate the triplicated Gemini client - #17

Merged
devtofunmi merged 4 commits into
mainfrom
refactor/gemini-client
Aug 12, 2026
Merged

refactor(llm): consolidate the triplicated Gemini client#17
devtofunmi merged 4 commits into
mainfrom
refactor/gemini-client

Conversation

@devtofunmi

Copy link
Copy Markdown
Owner

What — Pulls the three copies of the Gemini plumbing into one shared client at src/server/llm/gemini.ts; adapters keep their own prompts/schema/parser.

Why — Three copies had already drifted (only review had retry/timeout); the earlier "reviews silently failing on a throttled model" incident traces to exactly this divergence.

Behavior — Review unchanged; scan gains timeout+retry; autofix keeps single-attempt with a 45s cap matching its outer budget.
Verified — tsc / lint / prettier all clean.

One place owns the Gemini HTTP call, the per-attempt timeout + optional retry on transient errors (429/5xx/network), the cost-controlled generationConfig (thinkingBudget 0, bounded maxOutputTokens), and token/cost accounting. Callers pass prompts, a response schema, and per-call overrides (temperature, timeoutMs, maxAttempts) and parse the returned text themselves.
Drop the duplicated PRICING map, estimateCost, GeminiResponse type, retry loop, and inline fetch; reviewDiff now calls callGemini() and parses the result. Same span attributes, return shape, model default, and 8192 output-token cap.
Remove the duplicated PRICING/estimateCost/GeminiResponse and inline fetch; scanCodebase now calls callGemini(). Behavior unchanged except scans now inherit the client's per-attempt timeout and single retry, matching reviews.
Replace the inline fetch with callGemini(temperature 0, 16384 output tokens). Keeps autofix's single-attempt, no-retry behavior and sets a 45s per-attempt timeout matching openFixPr's outer cap so a slow-but-valid fix isn't aborted early or retried past budget.
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
jargons-8yyz Ready Ready Preview Aug 12, 2026 9:28pm

@devtofunmi
devtofunmi merged commit c08b3ba into main Aug 12, 2026
3 checks passed
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