fix(providers): make native Vertex+Claude path accept Anthropic-style model IDs and tool schemas - #1084
Conversation
… model IDs and tool schemas Two compatibility gaps in the native @anthropic-ai/vertex-sdk path that broke deployments sharing one model/tool config across providers (e.g. TARA): 1) Model IDs: the Anthropic API dates models with a trailing dash segment (claude-haiku-4-5-20251001) but Vertex publisher IDs use "@" (claude-haiku-4-5@20251001). The native path passed the dash form through verbatim and Vertex 404'd (verified live on us-east5: dash form NOT_FOUND, @ form 200). toVertexAnthropicModelId() normalizes at both native call sites; @-form IDs, bare aliases and non-Claude models pass through. 2) Tool schemas: the native path converted tool input_schema and the final_result schema with the "openApi3" target (correct for Gemini, wrong for Claude) — Anthropic validates input_schema as JSON Schema draft 2020-12 and rejects OpenAPI-3 dialect output (nullable: true) with tools.N.custom.input_schema 400s. Use the default JSON Schema target, matching the direct anthropic provider. Verified e2e through curator (provider=vertex, claude-haiku-4-5-20251001 from remote config, 88 MCP tools registered): chat + structured attachment turns succeed with zero 404/400; deterministic unit suite covers the normalization (9 cases).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Single Commit Policy - COMPLIANTStatus: Policy requirements met • 1 commit • Valid format • Ready for merge 📊 View validation details📝 Commit Details
✅ Validation Results
🤖 Automated validation by NeuroLink Single Commit Enforcement |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR improves Anthropic-on-Vertex compatibility by introducing centralized Claude model ID normalization from Anthropic's dash-date format to Vertex's ChangesAnthropic Vertex Compatibility
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 AI Review & Build Compliance ✅Status: AI analysis complete • Build rules validated • Ready for review 📊 View detailed analysis results🛡️ Analysis Complete
📋 Ready for Merge When
🤖 AI analysis complete - check individual code comments for specific feedback |
Tara-ag
left a comment
There was a problem hiding this comment.
Review Summary
Files reviewed: 3
New issues found: 0
Status: ✅ APPROVE
Analysis
This PR fixes two interoperability issues between the native Vertex+Claude path and Anthropic-style configurations:
-
Model ID normalization (
toVertexAnthropicModelId): Correctly converts Anthropic API date format (claude-haiku-4-5-20251001) to Vertex publisher format (claude-haiku-4-5@20251001). The regex/^(claude-[a-z0-9-]+)-(\d{8})$/properly handles:- Standard conversions (haiku, sonnet, opus variants)
- Legacy 3.5 model IDs
- Pass-through for @-form IDs, bare aliases, and non-Claude models
- Correctly rejects non-8-digit suffixes
-
Tool schema dialect fix: Removing
"openApi3"from the native Anthropic paths is correct — verified that the directanthropicprovider also uses the default JSON Schema target (notopenApi3). This aligns the Vertex native path with the direct provider behavior. -
Test coverage: 9 deterministic test cases covering conversions and pass-through scenarios.
Verification Against Standards
- ✅ CLAUDE.md Rule 5: No breaking changes to public SDK API
- ✅ Security: No hardcoded secrets or injection risks
- ✅ Architecture: Changes are properly scoped to Vertex+Claude native paths only
- ✅ Type safety: Proper TypeScript types throughout
- ✅ Testing: New test file follows existing harness patterns
The fix is minimal, well-documented, and addresses the root cause verified through live testing against us-east5.
|
🎉 This PR is included in version 9.70.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Problem
Deployments that share one model/tool config across providers (e.g. TARA/curator, where the model ID comes from a Superposition flag) break on the native
@anthropic-ai/vertex-sdkpath introduced in 9.61:Model-ID dialect. The Anthropic API dates models with a trailing dash segment (
claude-haiku-4-5-20251001) but Vertex publisher IDs use@(claude-haiku-4-5@20251001). The native path passed the dash form through verbatim → Vertex 404Publisher Model ... was not foundon every call.Verified live against
us-east5(project with Anthropic integration):claude-haiku-4-5-20251001claude-haiku-4-5@20251001claude-sonnet-4-6(bare alias)Tool-schema dialect. Once requests reach Vertex, the native Anthropic paths converted tool
input_schema/ thefinal_resultschema with the"openApi3"target (correct for Gemini, wrong for Claude). Anthropic validatesinput_schemaas JSON Schema draft 2020-12 and rejects OpenAPI-3 output (nullable: true) withtools.N.custom.input_schema: JSON schema is invalid400s.Fix
toVertexAnthropicModelId()inmodelDetection.ts— normalizes trailing-YYYYMMDDto@YYYYMMDDforclaude-*IDs at both native call sites (executeNativeAnthropicStream/executeNativeAnthropicGenerate).@-form IDs, bare aliases, and non-Claude models pass through untouched. Legacy v2-suffixed Vertex IDs have no dash-date equivalent and stay out of scope (they 404 before and after — no regression).final_resultschema conversions now use the default JSON Schema target, matching the directanthropicprovider. All Gemini paths keep"openApi3".Verification
npx tsx test/continuous-test-suite-vertex-model-id.ts(9 cases — conversions + pass-throughs).vertex,claude-haiku-4-5-20251001from remote config, 88 MCP tools registered): chat + structured-attachment turns succeed with zero 404/400; before the fix the identical config failed every turn.pre-commitcheck/format/lint green.Summary by CodeRabbit
New Features
Improvements
Tests