Skip to content

fix(gemini-adapter): pass request URL context for model extraction#8

Open
hariom888 wants to merge 1 commit into
Ruthwik000:mainfrom
hariom888:fix-gemini-model-context
Open

fix(gemini-adapter): pass request URL context for model extraction#8
hariom888 wants to merge 1 commit into
Ruthwik000:mainfrom
hariom888:fix-gemini-model-context

Conversation

@hariom888
Copy link
Copy Markdown

@hariom888 hariom888 commented May 16, 2026

Summary

Fixes Gemini model extraction fallback behavior caused by missing request context propagation.

Previously, standardFetch() called adapterRegistry.process(responseData) with only the response object, so the Gemini adapter's optional request parameter was always undefined. This caused the adapter to always fall back to the hardcoded default model gemini-1.5-flash.

Changes

  • Build a requestContext object { url, body } inside standardFetch()

  • Pass request context as the second argument to adapterRegistry.process()

  • Update Gemini adapter model extraction logic to parse model names from URL patterns:

    • /models/MODEL:action
  • Preserve modelVersion priority when present in responses

  • Added DOM typings support for Request compatibility

Impact

  • Fixes incorrect Gemini model attribution and pricing behaviour
  • Other adapters (OpenAI, Anthropic) remain unaffected because they ignore the extra argument

Verification

  • npm run build passes successfully
  • Verified request context propagation to Gemini adapter
  • Confirmed proper model extraction behaviour

Closes #5

…d to gemini-1.5-flash

The standardFetch function called adapterRegistry.process(responseData) with only the response, never passing the request. The Gemini adapter's normalize() function accepts an optional request parameter to extract the model name, but it was always undefined, causing the model to always fall back to the hardcoded default 'gemini-1.5-flash'.

Fix: build a requestContext object { url, body } in standardFetch and pass it as the second argument to adapterRegistry.process(). Update the Gemini adapter to extract the model name from the URL pattern /models/MODEL:action.

The modelVersion field in the response still takes priority when present.

Other adapters (OpenAI, Anthropic) are unaffected because they ignore the extra argument.
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.

fix(gemini-adapter): pass request context so model isn't always defaulted to gemini-1.5-flash

1 participant