Skip to content

Feature/vertex multi publisher#3522

Open
ggrandez wants to merge 17 commits intohigress-group:mainfrom
Attach-IA:feature/vertex-multi-publisher
Open

Feature/vertex multi publisher#3522
ggrandez wants to merge 17 commits intohigress-group:mainfrom
Attach-IA:feature/vertex-multi-publisher

Conversation

@ggrandez
Copy link
Copy Markdown

Summary

This PR improves Vertex AI support in ai-proxy with multi-publisher routing and protocol conversion robustness, especially for Claude/Mistral scenarios.

Main outcomes:

  • Adds automatic publisher-aware routing for Vertex models (Anthropic, Mistral, Codestral, Google/default).
  • Improves request conversion/sanitization for Claude-origin payloads before Vertex forwarding.
  • Extends tests to cover multi-publisher routing, endpoint selection, and compatibility behavior.
  • Adds technical documentation for the Claude protocol fix in Vertex provider.

What changed

1) Vertex multi-publisher routing

  • Introduced publisher routing strategy in Vertex provider:
    • routeRawPredict for publishers requiring rawPredict-style endpoints (e.g. Anthropic/Mistral).
    • routeOpenAICompatible for models using Vertex OpenAI-compatible endpoint.
    • routeNativeVertex fallback for Express Mode Google/native flow.
  • Added model-prefix based auto-detection and optional explicit override via vertexPublisher.
  • Added generic rawPredict path builders for arbitrary publishers (not only Anthropic).

2) Request conversion and protocol handling

  • Added Claude-request pre-conversion in Vertex request-body flow when Claude conversion context flag is present.
  • Added Claude request sanitization for Vertex compatibility (including schema cleanup and unsupported key handling).
  • Improved Claude/OpenAI conversion behavior:
    • Finish reason normalization (strings.ToLower before mapping).
    • Reasoning extraction from tagged text content and clean text reconstruction.
  • Ensured OpenAI-compatible path rewrites include proper publisher/model formatting (google/ prefix for unqualified models).

3) Tests

  • Added/expanded tests for:
    • Publisher resolution and routing decisions.
    • rawPredict path generation (standard + express mode).
    • OpenAI-compatible endpoint path generation.
    • Multi-publisher request-body behavior (Mistral rawPredict, Llama/DeepSeek/Qwen/Gemini openai-compatible, Claude backward compatibility, publisher override scenarios).
    • Claude→OpenAI tools conversion and schema handling.

4) Documentation

  • Added a technical write-up for Vertex Claude protocol fix:
    • plugins/wasm-go/extensions/ai-proxy/VERTEX_CLAUDE_PROTOCOL_FIX.md

Scope (files changed)

  • plugins/wasm-go/extensions/ai-proxy/provider/vertex.go
  • plugins/wasm-go/extensions/ai-proxy/provider/provider.go
  • plugins/wasm-go/extensions/ai-proxy/provider/claude_to_openai.go
  • plugins/wasm-go/extensions/ai-proxy/provider/vertex_test.go
  • plugins/wasm-go/extensions/ai-proxy/test/vertex.go
  • plugins/wasm-go/extensions/ai-proxy/provider/claude_to_openai_test.go
  • plugins/wasm-go/extensions/ai-proxy/main.go
  • plugins/wasm-go/extensions/ai-proxy/main_test.go

AI Coding Disclosure (required)

AI tools used

  • Claude Code
  • GitHub Copilot

Prompts / instructions used with AI tools

  1. "Implement Vertex AI multi-publisher support for chat completions, with automatic routing by model prefix and support for Anthropic/Mistral/Codestral plus OpenAI-compatible fallback."
  2. "Add configurable vertexPublisher override to force publisher routing regardless of model prefix."
  3. "Fix Claude /v1/messages compatibility in Vertex by converting/sanitizing request body before provider-specific handling."
  4. "Improve Claude/OpenAI conversion around finish_reason normalization and reasoning text extraction."
  5. "Add comprehensive tests for routing, rawPredict paths, OpenAI-compatible endpoint behavior, and backward compatibility."

AI Coding Summary

  • Key decisions made
    • Route by publisher strategy instead of single-provider assumptions.
    • Keep backward compatibility for Claude flows while enabling broader publisher support.
    • Use OpenAI-compatible endpoint as default in standard mode; use native Vertex route where appropriate in express mode.
  • Major changes implemented
    • New routing resolution and generic rawPredict path construction.
    • Request conversion/sanitization improvements for Claude-origin payloads.
    • New/expanded unit and integration-style tests across multi-publisher scenarios.
    • Added detailed technical fix documentation.
  • Important considerations / limitations
    • Behavior depends on model naming and mapping conventions; explicit vertexPublisher can override detection.
    • Express Mode and standard mode have different routing constraints.
    • Exact AI prompt text should be included verbatim by author if stricter traceability is required.

Commits included (author: Gad Grandez)

Hash Date Message
ad519f3 2026-01-22 Añadir soporte para la conversión de respuestas de Claude y mejorar la validación de herramientas
d858cd8 2026-01-23 Eliminar el manejo de conversión de respuesta de Claude en el proveedor Vertex
ed9b8ad 2026-01-23 Eliminar claves "$schema" no soportadas de los parámetros
a158cf8 2026-01-24 Agregar conversión de solicitudes de Claude a OpenAI en el cuerpo de la solicitud
34ede50 2026-01-24 Agregar corrección para la conversión de protocolo Claude en Vertex AI
930c48c 2026-01-24 Agregar función para sanitizar valores de esquema y eliminar claves no soportadas
d49d72a 2026-01-24 Agregar función para sanitizar solicitudes de Claude antes de enviarlas a Vertex AI
9bc4cd4 2026-01-24 Convert finish reason to lowercase in openAIFinishReasonToClaude function
eae18fd 2026-01-24 Agregar extracción y limpieza de razonamiento de texto en la conversión de respuesta
0b85e95 2026-02-12 feat(vertex): implement multi-publisher support and enhance routing logic
90b8d37 2026-02-13 feat(vertex): add automatic publisher prefix for models in multi-publisher support tests

…a validación de herramientas en las solicitudes de chat
…or Vertex y agregar advertencias sobre el uso de controladores de eventos obsoletos en la respuesta de transmisión.
…r con el esquema de herramientas de Vertex AI.
…I, permitiendo el uso del endpoint /v1/messages con herramientas.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 21, 2026

CLA assistant check
All committers have signed the CLA.

@ggrandez
Copy link
Copy Markdown
Author

Hi! CLA is now signed by all committers and this PR is ready for review.

Could a maintainer approve the pending workflow runs from this fork so CI can execute?

@johnlanni @rinfx @wydream — any feedback is welcome, thanks!

@ggrandez
Copy link
Copy Markdown
Author

ggrandez commented Mar 5, 2026

Hi @johnlanni @rinfx @wydream 👋 Just a friendly ping on this PR! The branch is recently updated with main and ready to go. Could one of you please approve the CI workflows so the checks can run? I'd really appreciate your review whenever you have a moment. Thanks!


大家好 @johnlanni @rinfx @wydream 👋 友好地提醒一下这个 PR!分支已与 main 保持同步,随时可以合并。能否请您批准 CI 工作流,以便检查可以运行?有时间的话非常感谢您的审阅!谢谢!

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.

3 participants