Skip to content

Accept per-call keys in Gemini embedding batches - #166

Open
remote-controlled-man wants to merge 1 commit into
simonw:mainfrom
remote-controlled-man:codex/prflow-93262ef97a0c
Open

remote-controlled-man wants to merge 1 commit into
simonw:mainfrom
remote-controlled-man:codex/prflow-93262ef97a0c

Conversation

@remote-controlled-man

Copy link
Copy Markdown

GeminiEmbeddingModel.embed_batch() lacks LLM's per-call key parameter. With LLM 0.38, two interleaved embed_multi() iterators on the same model enter the compatibility path that temporarily assigns model.key: the second request uses the first call's key, and closing the iterators in starting order leaves that key selected for later requests.

Accept keyword-only key and pass it to get_key(), allowing LLM to use its per-call interface. Keep the existing instance-key and environment-key resolution rules. Regression tests exercise both embedding models and direct batch calls using HTTPX's in-memory transport and fake keys.

Validation on Python 3.12 / LLM 0.38:

  • The five new cases fail against the original implementation and pass with the fix.
  • python -m pytest --record-mode=none: 64 passed, no skips.
  • python -m cogapp --check README.md: passed.
  • The Python 3.11/3.13/3.14/3.15 matrix was not run locally.

Found through code analysis and reproduced locally. No live Gemini requests or paid inference were used. AI assistance (Codex) was used for investigation, implementation and tests.

Copilot AI balanced review requested due to automatic review settings November 29, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

2 participants