Skip to content

fix(embedding): support stable Gemini Embedding 2 - #6383

Merged
qin-ctx merged 2 commits into
volcengine:mainfrom
ehz0ah:fix/gemini-stable-contract
Oct 21, 2026
Merged

qin-ctx merged 2 commits into
volcengine:mainfrom
ehz0ah:fix/gemini-stable-contract

Conversation

@ehz0ah

@ehz0ah ehz0ah commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Description

Migrate OpenViking's Gemini embedder from the retired gemini-embedding-2-preview default to stable gemini-embedding-2.

This is a request-contract change, not only a model-name update. Google documents that stable Gemini Embedding 2 does not accept EmbedContentConfig.task_type. It uses task instructions in the input text instead. The embedder now converts the existing OpenViking task options to Google's documented instruction formats for the stable model, while explicit legacy model configurations keep their field-based request behavior.

Official contracts:

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Fixes #6382

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Make gemini-embedding-2 the direct embedder default and register its 8192-token, 3072-dimension contract.
  • Convert all eight supported task types to Google's stable-model prompt instructions and omit unsupported task_type and title request fields.
  • Preserve the existing request shape for explicit preview and legacy models.
  • Update English and Chinese examples, integration fixtures, and migration guidance. Existing indexes must be re-embedded unless their embedding spaces are independently known to be compatible.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Validation results:

  • Ruff formatting and lint checks passed for all changed Python files.
  • Focused Gemini unit and configuration tests: 52 passed, 2 baseline cases deselected.
  • Gemini integration modules collected successfully without credentials: 29 skipped as designed.
  • Python 3.10 compilation passed for all changed Python files.
  • The source-pinned evidence audit passed 12 of 12 checks twice with byte-identical output.

The two deselected configuration assertions also fail on untouched upstream/main: their case-sensitive regex expects Invalid, while the existing validator emits invalid. Mypy reports the same nine pre-existing findings on this branch and untouched upstream/main. A live Gemini API run was not possible because GOOGLE_API_KEY was not available; request-shape coverage uses the official SDK types and mocked client boundary.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Not applicable.

Additional Notes

The preview model remains recognized for explicit legacy configuration so existing deployments do not change request shape silently. Google's service retirement schedule still determines whether that remote model remains callable.

@ZaynJarvis ZaynJarvis added the kernel Core server, runtime, storage, retrieval, SDK, and CLI. label Oct 21, 2026
@qin-ctx
qin-ctx marked this pull request as ready for review October 21, 2026 07:51
@qin-ctx
qin-ctx merged commit b5a3892 into volcengine:main Oct 21, 2026
2 of 6 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Core server, runtime, storage, retrieval, SDK, and CLI.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug] Gemini embedder defaults to the retired Embedding 2 preview

3 participants