Skip to content

fix(model_runner): map Vertex AI headers via http_options and enable vertexai SDK extra#74

Merged
frostming merged 2 commits intobubbuild:mainfrom
MasakiMu319:main
Mar 3, 2026
Merged

fix(model_runner): map Vertex AI headers via http_options and enable vertexai SDK extra#74
frostming merged 2 commits intobubbuild:mainfrom
MasakiMu319:main

Conversation

@MasakiMu319
Copy link
Contributor

Summary

This PR fixes a provider-specific request mapping issue for Vertex AI and adds the required Vertex AI SDK
extra in dependencies.

When using vertexai:* models, Bub previously passed extra_headers into the LLM call. In the Vertex AI
path, that value is validated against GenerateContentConfig, where extra_headers is invalid, causing
runtime errors.

What Changed

  • Updated ModelRunner request construction:
  • For vertexai:* models, pass headers via http_options={"headers": ...}.
  • For non-Vertex providers, keep the default behavior and pass extra_headers.
  • Added regression coverage in tests/test_model_runner.py:
  • OpenRouter/non-Vertex path still uses extra_headers.
  • Vertex AI path uses http_options.headers and does not send extra_headers.
  • Unknown providers continue using default extra_headers.
  • Updated dependencies:
  • any-llm-sdk[anthropic] -> any-llm-sdk[anthropic,vertexai]
  • Synced lockfile accordingly.

Why

This PR fixes a provider-parameter mismatch that is reproducible with Vertex AI:

  • Set BUB_MODEL=vertexai:gemini-3.1-pro-preview
  • Run uv run bub and send a simple message
  • Before this change, Bub passed extra_headers in the model call
  • In the Vertex AI path, forwarded kwargs are validated against GenerateContentConfig, where
    extra_headers is invalid
  • This caused runtime failure: GenerateContentConfig ... extra_headers ... Extra inputs are not permitted

The fix maps headers correctly for Vertex AI (http_options.headers) while keeping default extra_headers
behavior for non-Vertex providers.

Validation

  • uv run pytest -q tests/test_model_runner.py (11 passed)

  • uv run ruff check src/bub/core/model_runner.py tests/test_model_runner.py (passed)

  • Fixes Vertex AI runtime failure (extra_headers validation error).

  • Preserves existing behavior for non-Vertex providers.

  • No public API changes.

@frostming frostming merged commit 8e7d4fb into bubbuild:main Mar 3, 2026
5 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.

2 participants