-
Notifications
You must be signed in to change notification settings - Fork 703
[Go] Anthropic tool-calling on Vertex AI broken in v1.5.0 #4985
Description
Disclaimer: This bug was found and investigated by an LLM (Claude). The reproduction steps and analysis have been verified by a human.
Describe the bug
Genkit v1.5.0 unconditionally sets Strict: anthropic.Bool(true) on all tool definitions when using the Vertex AI Model Garden Anthropic plugin. The Vertex AI Anthropic endpoint does
not support the strict field on tools and rejects the request with:
400 Bad Request:
{"type":"error","error":{"type":"invalid_request_error","message":"tools.0.custom.strict: Extra inputs are not permitted"}}This is a regression from v1.4.0 where tool-calling with Anthropic models on Vertex AI worked correctly.
The problematic line is plugins/internal/anthropic/anthropic.go:355:
resp = append(resp, anthropic.ToolUnionParam{
OfTool: &anthropic.ToolParam{
Name: t.Name,
Description: anthropic.String(t.Description),
InputSchema: schema,
Strict: anthropic.Bool(true), // ← Vertex AI rejects this
},
})To Reproduce
Minimal repro — passes with v1.4.0, fails with v1.5.0 (verified):
package main
import (
"context"
"fmt"
"log"
"github.com/anthropics/anthropic-sdk-go"
"github.com/firebase/genkit/go/ai"
"github.com/firebase/genkit/go/genkit"
"github.com/firebase/genkit/go/plugins/vertexai/modelgarden"
)
func main() {
ctx := context.Background()
plugin := &modelgarden.Anthropic{
ProjectID: "your-gcp-project",
Location: "us-east5",
}
// Register a model (adjust name to one available in your project)
modelgarden.AnthropicModels["claude-sonnet-4-6"] = ai.ModelOptions{
Label: "Claude Sonnet 4.6",
Supports: &ai.ModelSupports{
Multiturn: true,
Tools: true,
SystemRole: true,
Media: true,
},
}
g := genkit.Init(ctx, genkit.WithPlugins(plugin))
model := modelgarden.AnthropicModel(g, "claude-sonnet-4-6")
greet := genkit.DefineTool(g, "greet", "Says hello to a person",
func(ctx *ai.ToolContext, input struct{ Name string }) (string, error) {
return fmt.Sprintf("Hello, %s!", input.Name), nil
},
)
resp, err := genkit.Generate(ctx, g,
ai.WithModel(model),
ai.WithPrompt("Greet Alice using the greet tool"),
ai.WithTools(greet),
ai.WithConfig(&anthropic.MessageNewParams{
MaxTokens: 1024,
Temperature: anthropic.Float(0),
}),
)
if err != nil {
// v1.4.0: prints "Hello, Alice!"
// v1.5.0: 400 Bad Request — tools.0.custom.strict: Extra inputs are not permitted
log.Fatal(err)
}
fmt.Println(resp.Text())
}v1.4.0 - Hello, Alice! (tool-calling works)
v1.5.0- 400 Bad Request: tools.0.custom.strict: Extra inputs are not permitted
Without tools (removing ai.WithTools(greet)), both versions work fine.
Expected behavior
Tool-calling with Anthropic models via Vertex AI Model Garden should work as it did in v1.4.0.
Runtime (please complete the following information):
- OS: macOS (Darwin 25.3.0 arm64)
Go version
- go1.26.1 darwin/arm64
Additional context
- github.com/firebase/genkit/go v1.5.0
- github.com/anthropics/anthropic-sdk-go v1.23.0
- The Strict field uses param.Opt[bool] with omitzero — simply not setting it would prevent serialization and fix the issue.
- The enforceStrictSchema helper (which adds additionalProperties: false recursively to tool input schemas) is fine — only the Strict field on ToolParam is problematic.
- Suggested fix: skip setting Strict when the provider is "vertexai", or make it opt-in via config.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status