feat(vertex): add Google Cloud Vertex provider - #27356
Conversation
Mirrors the existing Bedrock provider pattern — uses AnthropicVertex SDK with ADC auth, full feature parity (prompt caching, thinking, 1M context).
This comment was marked as spam.
This comment was marked as spam.
|
Thanks for adding Vertex support. I found a couple of integration blockers against current main. Problems
Suggested changes
This is an automated hermes-sweeper review. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the Claude-on-Vertex contribution. The requested native Anthropic transport is not on current main, but this implementation predates—and conflicts with—the established Gemini Vertex provider.
Problems
- Current
vertexis already Gemini/OpenAI-compatible:plugins/model-providers/vertex/__init__.py:3-17,65-73andhermes_cli/runtime_provider.py:1579-1610mapvertex-ai/google-vertextochat_completions. This patch replaces that behavior withanthropic_messages(hermes_cli/runtime_provider.py:1394-1419) rather than preserving both transports. - The resolver returns
project_id/region(hermes_cli/runtime_provider.py:839-855), butagent/agent_init.py:542-543reads agent attributes that current runtime application does not propagate (hermes_cli/cli_agent_setup_mixin.py:78-128).GOOGLE_CLOUD_PROJECTcan therefore resolve successfully and still reachAnthropicVertexas an empty project. - Main’s profile-aware Vertex configuration lives in
agent/vertex_adapter.py:50-87; the patch instead uses raw environment reads. It also adds no tests or AnthropicVertex dependency integration. - Auxiliary Vertex routing is still OpenAI/Gemini-only at
agent/auxiliary_client.py:5024-5058.
Suggested changes
- Add a model-aware Claude path alongside the existing Gemini Vertex transport, reusing current Vertex config/credential resolution.
- Cover primary, rebuild, auxiliary, alias, configuration-precedence, and Gemini-regression paths.
This is an automated hermes-sweeper review.
| print(f"🤖 AI Agent initialized with model: {agent.model} (AWS Bedrock + AnthropicBedrock SDK, {_br_region})") | ||
| elif _is_vertex_anthropic: | ||
| from agent.anthropic_adapter import build_anthropic_vertex_client | ||
| _vertex_project = getattr(agent, "project_id", None) or os.environ.get("VERTEX_PROJECT_ID") or os.environ.get("ANTHROPIC_VERTEX_PROJECT_ID") or "" |
There was a problem hiding this comment.
runtime_provider returns project_id, but no current agent-construction path assigns it to agent.project_id; this also omits the resolver's GOOGLE_CLOUD_PROJECT fallback. Resolve the project through the shared Vertex configuration/credential helper, or explicitly propagate it through every construction path before invoking AnthropicVertex.
| return runtime | ||
|
|
||
| # Google Cloud Vertex AI (AnthropicVertex SDK via ADC) | ||
| if provider in {"vertex", "vertex-ai", "google-vertex"}: |
There was a problem hiding this comment.
Current main already owns these aliases for the Gemini OpenAI-compatible Vertex transport. Routing all vertex selections through anthropic_messages would break that existing provider; select the AnthropicVertex path only for supported Claude models while retaining the current Gemini path.
Address review feedback from teknium1: - Model-aware routing: Claude models use AnthropicVertex SDK (anthropic_messages), Gemini/other models use existing OpenAI-compatible path (chat_completions) - Use vertex_adapter.py for credential/config resolution (profile-safe) instead of raw os.environ reads - Add lazy_deps group provider.vertex.anthropic for on-demand install - Cover auxiliary client (vision, reflection, etc.) for Claude-on-Vertex - Preserve existing Gemini-on-Vertex behavior unchanged
Correction: current head uses the existing Vertex provider's dual-route/runtime and auxiliary-client integration, whereas #3569 registers a separate |
|
@teknium1 Addressed your review feedback. Merged upstream main and pushed a fix commit on top: Changes in the fix commit:
Ready for re-review. |
Summary
provider: anthropicis configured but no API key is found, detectsVERTEX_PROJECT_IDenv var and routes through Vertexprovider: vertex/vertex-ai/google-vertexConfiguration
Environment variables (priority order):
VERTEX_PROJECT_IDorANTHROPIC_VERTEX_PROJECT_IDorGOOGLE_CLOUD_PROJECT— GCP projectVERTEX_REGIONorCLOUD_ML_REGION— region (default:global)Auth uses the standard GCP ADC chain (gcloud login, service account, workload identity).
Files Changed
agent/anthropic_adapter.py—build_anthropic_vertex_client()factory (mirrorsbuild_anthropic_bedrock_client)hermes_cli/runtime_provider.py— Vertex provider resolution + auto-fallbackagent/agent_init.py— Vertex client initialization alongside Bedrockrun_agent.py— Vertex client rebuild in_rebuild_anthropic_clientTest Plan
python -m py_compile agent/anthropic_adapter.py agent/agent_init.py hermes_cli/runtime_provider.py run_agent.pyVERTEX_PROJECT_IDsetprovider: vertexwith valid GCP credentials, verify streaming works