Skip to content

fix(cli): add google/ publisher prefix normalization for Vertex AI - #56805

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-56778-vertex-google-prefix
Closed

fix(cli): add google/ publisher prefix normalization for Vertex AI#56805
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-56778-vertex-google-prefix

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a dedicated normalization handler for the vertex provider in normalize_model_for_provider(). Vertex AI endpoints require model IDs in the google/MODEL_NAME format (e.g. google/gemini-3.1-flash-lite), but bare names like gemini-3.1-flash-lite were passed through unchanged, causing HTTP 400 INVALID_ARGUMENT errors from the Vertex API.

Related Issue

Fixes #56778

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • hermes_cli/model_normalize.py: Added a vertex provider block that prepends google/ to bare model names, preserves names already carrying the google/ prefix, and strips a matching vertex/ prefix before adding google/. Added two docstring examples.
  • tests/hermes_cli/test_vertex_provider.py: Added TestVertexModelNormalization class with 4 test methods covering bare names, already-prefixed names, vertex/ prefix stripping, and empty input.

How to Test

  1. Run the new normalization tests:

    python -m pytest tests/hermes_cli/test_vertex_provider.py -q -k "TestVertexModelNormalization"

    All 7 parametrized cases should pass.

  2. Run the full vertex provider test suite to check for regressions:

    python -m pytest tests/hermes_cli/test_vertex_provider.py -q

    All 29 tests should pass.

  3. Verify normalization behavior interactively:

    from hermes_cli.model_normalize import normalize_model_for_provider
    assert normalize_model_for_provider("gemini-3.1-flash-lite", "vertex") == "google/gemini-3.1-flash-lite"
    assert normalize_model_for_provider("google/gemini-2.5-pro", "vertex") == "google/gemini-2.5-pro"

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS (Python 3.12)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — docstring examples added
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — pure string normalization, no platform-specific code
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Vertex AI endpoints require model IDs in the format 'google/<model>'
but normalize_model_for_provider() had no handler for the 'vertex'
provider, causing bare names like 'gemini-3.1-flash-lite' to be sent
as-is and rejected with HTTP 400 INVALID_ARGUMENT.

Add a dedicated vertex block that:
- Prepends 'google/' to bare model names
- Preserves names already carrying the 'google/' prefix
- Strips a matching 'vertex/' prefix before adding 'google/'

Fixes NousResearch#56778
@tangtaizong666

Copy link
Copy Markdown
Contributor

Heads-up from working the same issue (overlap disclosed in #56809): _strip_matching_provider_prefix only strips a matching vertex/ prefix, so any other explicit publisher gets double-prefixed here — anthropic/claude-sonnet-4.6google/anthropic/claude-sonnet-4.6, meta/llama-3.3-70b-instruct-maasgoogle/meta/…, both malformed. Vertex's OpenAI-compat endpoint serves non-Google publishers (MaaS), so an explicit <publisher>/ probably needs to pass through unchanged rather than only exempting google/. Deferring to maintainers on which PR to take either way.

@liuhao1024

Copy link
Copy Markdown
Contributor Author

Closing in favor of #56809 which handles this correctly.

The current implementation has a bug: when the model name carries an explicit non-Google publisher prefix (e.g. anthropic/claude-sonnet-4.6, meta/llama-3.3-70b-instruct-maas), _strip_matching_provider_prefix returns it unchanged (correct), but then f"google/{bare}" produces a malformed double-prefixed name like google/anthropic/claude-sonnet-4.6.

@tangtaizong666's #56809 fixes this with if "/" in bare: return bare, which preserves explicit publisher prefixes — the right behavior since Vertex hosts non-Google publishers via its MaaS endpoint. It also adds alias handling (google-vertex, vertex-ai, gcp-vertex, vertexai) and comprehensive tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have provider/gemini Google Gemini (AI Studio, Cloud Code) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(providers): Vertex AI provider fails with HTTP 400 due to missing mandatory 'google/' publisher prefix

3 participants